Implement table saving functionality

This commit is contained in:
mkrsym1
2023-08-04 22:55:10 +03:00
parent 7eac309372
commit 400729a3dc
6 changed files with 56 additions and 7 deletions

View File

@ -55,8 +55,24 @@ static void _run_game(struct game_data *game) {
}
static void _run_tx(struct game_data *game, wchar_t *tableFile) {
// Load unpatched base module
HMODULE baseModule = LoadLibraryA(game->base_module_name);
if (!baseModule) {
msg_err_a("Failed to load base module: %s", game->base_module_name);
}
// ...more magic
size_t tableSize;
void *table = core_perform_tx(&tableSize);
// Save to file
utils_create_dir_recursively(tableFile);
utils_save_to_file(tableFile, table, tableSize);
// Cleanup
free(table);
// The file should now exist: restart and launch the game
request_restart();
exit(0);
}
@ -80,10 +96,7 @@ BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) {
wchar_t tableFile[MAX_PATH];
tx_table_file(&game, tableFile);
// Remove this
msg_err_w(tableFile);
if (1) {
if (utils_path_exists(tableFile)) {
_run_game(&game);
} else {
_run_tx(&game, tableFile);