Skip to content

Commit

Permalink
offload initialization to a new thread
Browse files Browse the repository at this point in the history
  • Loading branch information
wictornogueira committed Jan 14, 2022
1 parent 265dfe6 commit cc93ffe
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion nfsu2-rpc/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,16 @@ void init(HMODULE hModule) {
} catch (exception e) {}
}

// Prevents game from going kaboom
static DWORD WINAPI ThreadEntry(LPVOID lpParam) {
init((HMODULE)lpParam);
return 0;
}

BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
if (ul_reason_for_call == DLL_PROCESS_ATTACH) {
init(hModule);
DisableThreadLibraryCalls(hModule);
CreateThread(0, 0, ThreadEntry, hModule, 0, 0);
}

return TRUE;
Expand Down

0 comments on commit cc93ffe

Please sign in to comment.