Skip to content

Commit

Permalink
show error when DetourGetEntryPoint() fails
Browse files Browse the repository at this point in the history
  • Loading branch information
Rosalie241 committed Jul 7, 2022
1 parent c7fc11c commit c502410
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions SporeModLoader/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
if (dwReason == DLL_PROCESS_ATTACH)
{
DetourRestoreAfterWith();

SporeAppEntry_real = (int (WINAPI*)(VOID))DetourGetEntryPoint(nullptr);

if (SporeAppEntry_real == nullptr)
{
MessageBoxW(nullptr, L"DetourGetEntryPoint() Failed!", L"SporeModLoader", MB_OK | MB_ICONERROR);
}
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourAttach(&(PVOID&)SporeAppEntry_real, SporeAppEntry_detoured);
Expand All @@ -71,7 +73,10 @@ BOOL WINAPI DllMain(HINSTANCE hinst, DWORD dwReason, LPVOID reserved)
{
DetourTransactionBegin();
DetourUpdateThread(GetCurrentThread());
DetourDetach(&(PVOID&)SporeAppEntry_real, SporeAppEntry_detoured);
if (SporeAppEntry_real != nullptr)
{
DetourDetach(&(PVOID&)SporeAppEntry_real, SporeAppEntry_detoured);
}
DetourTransactionCommit();
}

Expand Down

0 comments on commit c502410

Please sign in to comment.