diff --git a/thcrap/src/bp_file.cpp b/thcrap/src/bp_file.cpp index d89d3b0c..3129c77f 100644 --- a/thcrap/src/bp_file.cpp +++ b/thcrap/src/bp_file.cpp @@ -137,14 +137,14 @@ int BP_file_load(x86_reg_t *regs, json_t *bp_info) } // Cool function name. -int DumpDatFile(const char *dir, const char *name, const void *buffer, size_t size) +int DumpDatFile(const char *dir, const char *name, const void *buffer, size_t size, bool overwrite_existing) { if unexpected(!buffer || !name) { return -1; } BUILD_VLA_STR(char, fn, dir, "/", name); - if (!PathFileExistsU(fn)) { + if (overwrite_existing || !PathFileExistsU(fn)) { file_write(fn, buffer, size); } VLA_FREE(fn); @@ -171,7 +171,7 @@ int BP_file_loaded(x86_reg_t *regs, json_t *bp_info) } dat_dump = runconfig_dat_dump_get(); if(dat_dump) { - DumpDatFile(dat_dump, fr->name, fr->game_buffer, fr->pre_json_size); + DumpDatFile(dat_dump, fr->name, fr->game_buffer, fr->pre_json_size, false); } file_rep_hooks_run(fr); diff --git a/thcrap/src/bp_file.h b/thcrap/src/bp_file.h index 97ffdf74..7c28fd5b 100644 --- a/thcrap/src/bp_file.h +++ b/thcrap/src/bp_file.h @@ -146,7 +146,7 @@ TH_IMPORT int BP_file_size(x86_reg_t *regs, json_t *bp_info); THCRAP_BREAKPOINT_API int BP_file_loaded(x86_reg_t *regs, json_t *bp_info); // Cool function name. -THCRAP_API int DumpDatFile(const char *dir, const char *name, const void *buffer, size_t size); +THCRAP_API int DumpDatFile(const char *dir, const char *name, const void *buffer, size_t size, bool overwrite_existing); int bp_file_init(void); void bp_file_mod_thread_exit(void); diff --git a/thcrap/src/patchfile.cpp b/thcrap/src/patchfile.cpp index 58b702b5..7660408d 100644 --- a/thcrap/src/patchfile.cpp +++ b/thcrap/src/patchfile.cpp @@ -655,7 +655,7 @@ int patchhooks_run(const patchhook_t *hook_array, void *file_inout, size_t size_ if (func(file_inout, size_out, size_in, fn, patch) > 0) { const char *patched_files_dump = runconfig_patched_files_dump_get(); if unexpected(patched_files_dump) { - DumpDatFile(patched_files_dump, fn, file_inout, size_out); + DumpDatFile(patched_files_dump, fn, file_inout, size_out, true); } ret = 1; } diff --git a/thcrap_tasofro/src/tasofro_file.cpp b/thcrap_tasofro/src/tasofro_file.cpp index a1135da0..1af909c9 100644 --- a/thcrap_tasofro/src/tasofro_file.cpp +++ b/thcrap_tasofro/src/tasofro_file.cpp @@ -151,7 +151,7 @@ void TasofroFile::replace_ReadFile_init(ReadFileStack *stack, decrypt(this, (BYTE*)game_buffer, pre_json_size); if unexpected(dat_dump) { - DumpDatFile(dat_dump, this->name, game_buffer, pre_json_size); + DumpDatFile(dat_dump, this->name, game_buffer, pre_json_size, false); } // If there are hooks and no replacement file // then just pass the original file to the