Skip to content

My tools for fate/stay night Remastered (steam ver), epk unpack&repack

Notifications You must be signed in to change notification settings

kurikomoe/FSNr_tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Usage

Important

Only tested on windows

Remember to put SomeKey.bin along with main.exe

*.bin

python scripts/dec.py --input pack01d.bin --key_bin decryptKey.bin --output_dir unpack

files in pack folder

python scripts/unpack.py --input-dir <path_to_pack_folder> --output-dir unpack

*.epk files unpacked from *.bin

g++ --std=c++20 -O2 main.cpp -o main.exe

./main.exe dec "[path to epk]"
./main.exe enc "[path to epk.epk_dec]"

# example
# ./main.exe dec root#data#locale#ck#epk#uistring.epk
# and find the dec file in the same folder: root#data#locale#ck#epk#uistring.epk_dec

# ./main.exe enc root#data#locale#ck#epk#uistring.epk_dec
# and find the enc file in the same folder: root#data#locale#ck#epk#uistring.epk_enc

Note

There may be something wrong in the readme, please refer to code, I wrote this at 2 am, and was quite unconscious.

struct EPK {
  char*  variantLengthBuf;
  char   paddingZero[0x10];
  word  bufSize;         // variantLengthBuf size, big endian
  char paddingZero[0x10-sizeof(word)]
  char md5[0x10];         // Auto calculate when enc in main.exe, calc based on bufSize
}

the md5 is calculated from buf + "8FE9D249BD2689BB4B70F5AE88A9E645"(ascii char, 32bytes)

the buffer is always zero padded to word, but bufSize is the actual size, and md5, enc/dec are based on the word aligned buffer (aka padded size).

Note

SomeKey.bin dumps from 0x1409E6500

FDT file decrypt script can be found in scripts folder, (but badly written in python)

Someone on steam community successfully repacked the epk with modified content: https://steamcommunity.com/app/2396980/discussions/0/4513255384647123281/

The game load epks from C:\Users<username>\AppData\Local\typemoon\fsn2\data by default (with subdirs root/data/locale/ck/epk/uistring.epk for example), though I dont think creating such patch/mod and delivering to players is a fancy idea XD.

Tip

The game determines the %LOCALAPPDATA% by env $env.LOCALAPPDATA. So starting the game with modified $env.LOCALAPPDATA will redirect all things to the desired location, see FSNr_bonus.7z

Then you can ship a mod/patch without hooking or repacking the .bin/.dat.

Related Projects

DaZombieKiller/FatePackageManager: They helped me a lot when reversing the package format.

About

My tools for fate/stay night Remastered (steam ver), epk unpack&repack

Resources

Stars

Watchers

Forks

Packages

No packages published