Load table dynamically from FS

This commit is contained in:
mkrsym1 2023-08-04 23:22:26 +03:00
parent 9a3d623883
commit b8aa6f968b
3 changed files with 11 additions and 11 deletions

Binary file not shown.

View File

@ -4,6 +4,6 @@
#include <game.h> #include <game.h>
void core_setup_patcher(struct game_data *game, HMODULE baseModule); void core_setup_patcher(struct game_data *game, HMODULE baseModule, wchar_t *txFile);
void *core_perform_tx(size_t *outLength); void *core_perform_tx(size_t *outLength);

View File

@ -38,7 +38,7 @@ void request_restart() {
CloseHandle(hRestartFlag); CloseHandle(hRestartFlag);
} }
static void _run_game(struct game_data *game) { static void _run_game(struct game_data *game, wchar_t *txFile) {
// Create fake ACE driver files // Create fake ACE driver files
ace_fake_driver_files(); ace_fake_driver_files();
@ -47,14 +47,14 @@ static void _run_game(struct game_data *game) {
ace_load_driver_module(); ace_load_driver_module();
// ...magic // ...magic
core_setup_patcher(game, baseModule); core_setup_patcher(game, baseModule, txFile);
// Load the UnityPlayer module and invoke the callback // Load the UnityPlayer module and invoke the callback
HMODULE unityModule = LoadLibraryA("UnityPlayer.dll"); HMODULE unityModule = LoadLibraryA("UnityPlayer.dll");
INVOKE_CALLBACK(game->unityplayer_callback, unityModule); INVOKE_CALLBACK(game->unityplayer_callback, unityModule);
} }
static void _run_tx(struct game_data *game, wchar_t *tableFile) { static void _run_tx(struct game_data *game, wchar_t *txFile) {
// Load unpatched base module // Load unpatched base module
HMODULE baseModule = LoadLibraryA(game->base_module_name); HMODULE baseModule = LoadLibraryA(game->base_module_name);
if (!baseModule) { if (!baseModule) {
@ -66,8 +66,8 @@ static void _run_tx(struct game_data *game, wchar_t *tableFile) {
void *table = core_perform_tx(&tableSize); void *table = core_perform_tx(&tableSize);
// Save to file // Save to file
utils_create_dir_recursively(tableFile); utils_create_dir_recursively(txFile);
utils_save_to_file(tableFile, table, tableSize); utils_save_to_file(txFile, table, tableSize);
// Cleanup // Cleanup
free(table); free(table);
@ -93,13 +93,13 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
game_detect(&game); game_detect(&game);
// Get required table file path // Get required table file path
wchar_t tableFile[MAX_PATH]; wchar_t txFile[MAX_PATH];
tx_table_file(&game, tableFile); tx_table_file(&game, txFile);
if (utils_path_exists(tableFile)) { if (utils_path_exists(txFile)) {
_run_game(&game); _run_game(&game, txFile);
} else { } else {
_run_tx(&game, tableFile); _run_tx(&game, txFile);
} }
return TRUE; return TRUE;