mirror of
https://github.com/mon/ifs_layeredfs.git
synced 2026-04-26 09:34:06 -05:00
Add automatic pkfs dumper
This commit is contained in:
parent
b8ef54e614
commit
450d9aacda
4
build.sh
4
build.sh
|
|
@ -7,11 +7,11 @@ rm -rf dist/
|
||||||
# x86
|
# x86
|
||||||
meson setup --cross-file cross-i686-w64-mingw32.txt build32
|
meson setup --cross-file cross-i686-w64-mingw32.txt build32
|
||||||
# without `--tags runtime`, the .a files are also installed
|
# without `--tags runtime`, the .a files are also installed
|
||||||
meson install -C build32 --destdir ../dist/32bit --tags runtime
|
meson install -C build32 --destdir ../dist/32bit --tags runtime,doc
|
||||||
|
|
||||||
# x86_64
|
# x86_64
|
||||||
meson setup --cross-file cross-x86_64-w64-mingw32.txt build64
|
meson setup --cross-file cross-x86_64-w64-mingw32.txt build64
|
||||||
meson install -C build64 --destdir ../dist/64bit --tags runtime
|
meson install -C build64 --destdir ../dist/64bit --tags runtime,doc
|
||||||
|
|
||||||
# docs
|
# docs
|
||||||
cp -R data_mods dist/
|
cp -R data_mods dist/
|
||||||
|
|
|
||||||
25
meson.build
25
meson.build
|
|
@ -8,6 +8,7 @@ project('layeredfs', 'c', 'cpp', version: '3.0_BETA4',
|
||||||
)
|
)
|
||||||
|
|
||||||
add_project_link_arguments('-static', language: 'cpp')
|
add_project_link_arguments('-static', language: 'cpp')
|
||||||
|
add_project_arguments('-DVER_STRING="' + meson.project_version() + '"', language: 'cpp')
|
||||||
|
|
||||||
third_party = static_library('3rd_party',
|
third_party = static_library('3rd_party',
|
||||||
sources: [
|
sources: [
|
||||||
|
|
@ -40,7 +41,6 @@ layeredfs_lib = static_library('layeredfs',
|
||||||
sources: [
|
sources: [
|
||||||
'src/avs.cpp',
|
'src/avs.cpp',
|
||||||
'src/dllmain.cpp',
|
'src/dllmain.cpp',
|
||||||
'src/hook.cpp',
|
|
||||||
'src/imagefs.cpp',
|
'src/imagefs.cpp',
|
||||||
'src/log.cpp',
|
'src/log.cpp',
|
||||||
'src/modpath_handler.cpp',
|
'src/modpath_handler.cpp',
|
||||||
|
|
@ -51,12 +51,14 @@ layeredfs_lib = static_library('layeredfs',
|
||||||
'src/utils.cpp',
|
'src/utils.cpp',
|
||||||
],
|
],
|
||||||
link_with: third_party,
|
link_with: third_party,
|
||||||
cpp_args: '-DVER_STRING="' + meson.project_version() + '"',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# has to be bare source so each special version gets a different copy
|
# has to be bare source so each special version gets a different copy
|
||||||
layeredfs_cfg_dep = declare_dependency(
|
layeredfs_cfg_dep = declare_dependency(
|
||||||
sources: 'src/config.cpp'
|
sources: [
|
||||||
|
'src/config.cpp',
|
||||||
|
'src/hook.cpp',
|
||||||
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
executable('playpen',
|
executable('playpen',
|
||||||
|
|
@ -84,12 +86,27 @@ special_cfgs = [
|
||||||
['always_devmode_and_logs_to_file', ['-DCFG_DEVMODE', '-DCFG_LOGFILE']],
|
['always_devmode_and_logs_to_file', ['-DCFG_DEVMODE', '-DCFG_LOGFILE']],
|
||||||
# "Why isn't it working???"
|
# "Why isn't it working???"
|
||||||
['always_devmode_verbose_and_logs_to_file', ['-DCFG_DEVMODE', '-DCFG_VERBOSE', '-DCFG_LOGFILE']],
|
['always_devmode_verbose_and_logs_to_file', ['-DCFG_DEVMODE', '-DCFG_VERBOSE', '-DCFG_LOGFILE']],
|
||||||
|
# dump every file accessed via pkfs APIs to data_unpak
|
||||||
|
['pkfs_unpack', ['-DUNPAK']]
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# documentation for pkfs_unpak
|
||||||
|
if host_machine.cpu_family() == 'x86'
|
||||||
|
install_data(
|
||||||
|
'pkfs_unpack_readme.txt',
|
||||||
|
install_dir: '/special_builds/pkfs_unpack',
|
||||||
|
install_tag: 'doc',
|
||||||
|
)
|
||||||
|
endif
|
||||||
|
|
||||||
foreach cfg : special_cfgs
|
foreach cfg : special_cfgs
|
||||||
folder_name = cfg[0]
|
folder_name = cfg[0]
|
||||||
defines = cfg[1]
|
defines = cfg[1]
|
||||||
|
|
||||||
|
if folder_name == 'pkfs_unpack' and host_machine.cpu_family() != 'x86'
|
||||||
|
continue
|
||||||
|
endif
|
||||||
|
|
||||||
shared_library('ifs_hook_' + folder_name,
|
shared_library('ifs_hook_' + folder_name,
|
||||||
link_with: layeredfs_lib,
|
link_with: layeredfs_lib,
|
||||||
dependencies: layeredfs_cfg_dep,
|
dependencies: layeredfs_cfg_dep,
|
||||||
|
|
@ -113,7 +130,7 @@ foreach cfg : injector_cfgs
|
||||||
def_file = 'src_injector' / dll_name + '.def'
|
def_file = 'src_injector' / dll_name + '.def'
|
||||||
|
|
||||||
if dll_name == 'dxgi_for_bombergirl'
|
if dll_name == 'dxgi_for_bombergirl'
|
||||||
if host_machine.cpu_family() == 'x86'
|
if host_machine.cpu_family() != 'x86_64'
|
||||||
continue
|
continue
|
||||||
endif
|
endif
|
||||||
def_file = 'src_injector/dxgi.def'
|
def_file = 'src_injector/dxgi.def'
|
||||||
|
|
|
||||||
11
pkfs_unpack_readme.txt
Normal file
11
pkfs_unpack_readme.txt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
For games that use pkfs functionality (gfdm/jubeat 2008/jubeat ripples), this
|
||||||
|
will export every accessed file to a `data_unpak` folder so you can easily
|
||||||
|
extract it using gitadora-textool and make mods.
|
||||||
|
|
||||||
|
You can tell if your game uses pkfs if the `data` folder contains
|
||||||
|
`finfolist.bin`, a `pack` folder, and a bunch of `.pak` files.
|
||||||
|
|
||||||
|
Because .pak files do not contain a table of filenames, you have to brute-force
|
||||||
|
filenames to fully extract them. This is why there isn't an easy one-stop tool
|
||||||
|
to extract everything for editing. The "pakdump" github project comes close, but
|
||||||
|
misses a few files.
|
||||||
29
src/hook.cpp
29
src/hook.cpp
|
|
@ -131,7 +131,7 @@ class PkfsHookFile : public HookFile {
|
||||||
std::optional<std::vector<uint8_t>> load_to_vec() override {
|
std::optional<std::vector<uint8_t>> load_to_vec() override {
|
||||||
AVS_FILE f = pkfs_fs_open(get_path_to_open().c_str());
|
AVS_FILE f = pkfs_fs_open(get_path_to_open().c_str());
|
||||||
if (f != 0) {
|
if (f != 0) {
|
||||||
avs_stat stat = {0}; // file type is shared!
|
avs_stat stat = {0}; // stat type is shared!
|
||||||
pkfs_fs_fstat(f, &stat);
|
pkfs_fs_fstat(f, &stat);
|
||||||
std::vector<uint8_t> ret;
|
std::vector<uint8_t> ret;
|
||||||
ret.resize(stat.filesize);
|
ret.resize(stat.filesize);
|
||||||
|
|
@ -398,6 +398,30 @@ unsigned int hook_pkfs_open(const char *name) {
|
||||||
// unpack success
|
// unpack success
|
||||||
PkfsHookFile file(path, *norm_path);
|
PkfsHookFile file(path, *norm_path);
|
||||||
|
|
||||||
|
#ifdef UNPAK
|
||||||
|
string pakdump_loc = "./data_unpak/" + file.norm_path;
|
||||||
|
if(!file_exists(pakdump_loc.c_str())) {
|
||||||
|
auto folder_terminator = pakdump_loc.rfind("/");
|
||||||
|
auto out_folder = pakdump_loc.substr(0, folder_terminator);
|
||||||
|
auto data = file.load_to_vec();
|
||||||
|
if(data) {
|
||||||
|
if(mkdir_p(out_folder)) {
|
||||||
|
auto dump = fopen(pakdump_loc.c_str(), "wb");
|
||||||
|
if(dump) {
|
||||||
|
fwrite(&(*data)[0], 1, data->size(), dump);
|
||||||
|
fclose(dump);
|
||||||
|
|
||||||
|
log_info("Dumped new pkfs file!");
|
||||||
|
} else {
|
||||||
|
log_warning("Pakdump: Couldn't open output file");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log_warning("Pakdump: Couldn't create output folder");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return handle_file_open(file);
|
return handle_file_open(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -430,6 +454,9 @@ extern "C" {
|
||||||
log_info("IFS layeredFS v" VERSION " init");
|
log_info("IFS layeredFS v" VERSION " init");
|
||||||
log_info("AVS DLL detected: %s", avs_loaded_dll_name);
|
log_info("AVS DLL detected: %s", avs_loaded_dll_name);
|
||||||
print_config();
|
print_config();
|
||||||
|
#ifdef UNPAK
|
||||||
|
log_info(".pak dumper mode enabled");
|
||||||
|
#endif
|
||||||
|
|
||||||
cache_mods();
|
cache_mods();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user