mirror of
https://github.com/Detanup01/gbe_fork.git
synced 2026-02-04 05:21:16 +01:00
35 lines
776 B
C++
35 lines
776 B
C++
#include "steam_old_lib.hpp"
|
|
|
|
|
|
static bool dll_loaded = false;
|
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
|
|
{
|
|
switch (reason) {
|
|
case DLL_PROCESS_ATTACH: {
|
|
if (!soldlib::patch((void*)hModule)) {
|
|
|
|
#ifdef SOLD_EXTRA_DEBUG
|
|
MessageBoxA(nullptr, "Failed to initialize", "Main", MB_OK | MB_ICONERROR);
|
|
#endif
|
|
|
|
// https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
|
|
// "The system immediately calls your entry-point function with DLL_PROCESS_DETACH and unloads the DLL"
|
|
return FALSE;
|
|
}
|
|
|
|
dll_loaded = true;
|
|
}
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH: {
|
|
if (dll_loaded) {
|
|
soldlib::restore();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
return TRUE;
|
|
}
|