Finish integrating TX
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
||||
// Create shared memory for the restart flag
|
||||
HANDLE hRestartFlag = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(int), "Global\\JadeiteRestartFlag");
|
||||
int *restartFlag = MapViewOfFile(hRestartFlag, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(int));
|
||||
if (!restartFlag) {
|
||||
MessageBoxW(NULL, L"Failed to create shared memory!", J_MB_TITLE, MB_OK | MB_ICONERROR);
|
||||
exit(1);
|
||||
}
|
||||
// Get restart flag file path
|
||||
wchar_t restartFlagFile[MAX_PATH];
|
||||
GetTempPathW(MAX_PATH, restartFlagFile);
|
||||
wcscat(restartFlagFile, L"jadeite\\restart_flag");
|
||||
|
||||
do {
|
||||
// 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;
|
||||
inject(pi.hProcess, payloadStart, payloadSize, injectDll);
|
||||
|
||||
// Clear the restart flag
|
||||
*restartFlag = 0;
|
||||
// Remove the restart flag file
|
||||
DeleteFileW(restartFlagFile);
|
||||
|
||||
// Optional: wait for user input before resuming (useful for debugging)
|
||||
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
|
||||
WaitForSingleObject(pi.hProcess, INFINITE);
|
||||
} while (*restartFlag);
|
||||
} while (GetFileAttributesW(restartFlagFile) != INVALID_FILE_ATTRIBUTES);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user