Finish integrating TX
This commit is contained in:
parent
505d4b12dd
commit
79cf7d20cc
Binary file not shown.
@ -6,4 +6,4 @@
|
|||||||
|
|
||||||
void core_setup_patcher(struct game_data *game, HMODULE baseModule, wchar_t *txFile);
|
void core_setup_patcher(struct game_data *game, HMODULE baseModule, wchar_t *txFile);
|
||||||
|
|
||||||
void *core_perform_tx(size_t *outLength);
|
void *core_perform_tx(struct game_data *game, size_t *outLength);
|
||||||
|
@ -26,15 +26,11 @@ void unload_ctr_dec() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void request_restart() {
|
void request_restart() {
|
||||||
HANDLE hRestartFlag = OpenFileMappingA(FILE_MAP_ALL_ACCESS, FALSE, "Global\\JadeiteRestartFlag");
|
wchar_t restartFlagFile[MAX_PATH];
|
||||||
int *restartFlag = MapViewOfFile(hRestartFlag, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(int));
|
GetTempPathW(MAX_PATH, restartFlagFile);
|
||||||
if (!restartFlag) {
|
wcscat(restartFlagFile, L"jadeite\\restart_flag");
|
||||||
msg_err_a("Could not map shared memory to set restart flag");
|
|
||||||
}
|
|
||||||
|
|
||||||
*restartFlag = 1;
|
HANDLE hRestartFlag = CreateFileW(restartFlagFile, FILE_WRITE_ACCESS, FILE_SHARE_READ, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||||
|
|
||||||
UnmapViewOfFile(restartFlag);
|
|
||||||
CloseHandle(hRestartFlag);
|
CloseHandle(hRestartFlag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +59,7 @@ static void _run_tx(struct game_data *game, wchar_t *txFile) {
|
|||||||
|
|
||||||
// ...more magic
|
// ...more magic
|
||||||
size_t tableSize;
|
size_t tableSize;
|
||||||
void *table = core_perform_tx(&tableSize);
|
void *table = core_perform_tx(game, &tableSize);
|
||||||
|
|
||||||
// Save to file
|
// Save to file
|
||||||
utils_create_dir_recursively(txFile);
|
utils_create_dir_recursively(txFile);
|
||||||
|
@ -61,13 +61,10 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
|||||||
MessageBoxW(NULL, L"Could not find wine_get_unix_file_name! Wine version too old?", J_MB_TITLE, MB_OK | MB_ICONWARNING);
|
MessageBoxW(NULL, L"Could not find wine_get_unix_file_name! Wine version too old?", J_MB_TITLE, MB_OK | MB_ICONWARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create shared memory for the restart flag
|
// Get restart flag file path
|
||||||
HANDLE hRestartFlag = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(int), "Global\\JadeiteRestartFlag");
|
wchar_t restartFlagFile[MAX_PATH];
|
||||||
int *restartFlag = MapViewOfFile(hRestartFlag, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(int));
|
GetTempPathW(MAX_PATH, restartFlagFile);
|
||||||
if (!restartFlag) {
|
wcscat(restartFlagFile, L"jadeite\\restart_flag");
|
||||||
MessageBoxW(NULL, L"Failed to create shared memory!", J_MB_TITLE, MB_OK | MB_ICONERROR);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
do {
|
do {
|
||||||
// Start the game
|
// Start the game
|
||||||
@ -102,8 +99,8 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
|||||||
size_t payloadSize = (size_t)&_binary_game_p_o_p_game_p_bin_size;
|
size_t payloadSize = (size_t)&_binary_game_p_o_p_game_p_bin_size;
|
||||||
inject(pi.hProcess, payloadStart, payloadSize, injectDll);
|
inject(pi.hProcess, payloadStart, payloadSize, injectDll);
|
||||||
|
|
||||||
// Clear the restart flag
|
// Remove the restart flag file
|
||||||
*restartFlag = 0;
|
DeleteFileW(restartFlagFile);
|
||||||
|
|
||||||
// Optional: wait for user input before resuming (useful for debugging)
|
// Optional: wait for user input before resuming (useful for debugging)
|
||||||
char *waitEnabled = getenv("WAIT_BEFORE_RESUME");
|
char *waitEnabled = getenv("WAIT_BEFORE_RESUME");
|
||||||
@ -118,7 +115,7 @@ BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved) {
|
|||||||
|
|
||||||
// The launcher process should now hang untill the game terminates
|
// The launcher process should now hang untill the game terminates
|
||||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||||
} while (*restartFlag);
|
} while (GetFileAttributesW(restartFlagFile) != INVALID_FILE_ATTRIBUTES);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user