-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix crash
- Loading branch information
Showing
4 changed files
with
1,697 additions
and
1,718 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,59 @@ | ||
#include "hooks/hooks.h" | ||
|
||
DWORD WINAPI initialize(HMODULE base) | ||
BOOL WINAPI dll_detach() | ||
{ | ||
hooks::shutdown(); | ||
render_manager::shutdown(); | ||
|
||
#ifdef _DEBUG | ||
utilities::detach_console(); | ||
#endif | ||
|
||
return TRUE; | ||
} | ||
|
||
DWORD WINAPI dll_entry(LPVOID thread_parameter) | ||
{ | ||
while (!utilities::game_is_full_loaded()) | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
|
||
#ifdef _DEBUG | ||
utilities::attach_console(); | ||
#endif | ||
|
||
interfaces::initialize(); | ||
hooks::initialize(); | ||
|
||
while (!globals::unload) | ||
std::this_thread::sleep_for(std::chrono::milliseconds(100)); | ||
|
||
FreeLibraryAndExitThread(base, EXIT_SUCCESS); | ||
dll_detach(); | ||
|
||
return TRUE; | ||
FreeLibraryAndExitThread(static_cast<HMODULE>(thread_parameter), EXIT_SUCCESS); | ||
} | ||
|
||
BOOL WINAPI shutdown() | ||
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, LPVOID reserved) | ||
{ | ||
#ifdef _DEBUG | ||
utilities::detach_console(); | ||
#endif | ||
|
||
hooks::shutdown(); | ||
render_manager::shutdown(); | ||
|
||
return TRUE; | ||
} | ||
|
||
BOOL WINAPI DllMain(HMODULE base, DWORD ul_reason_for_call, LPVOID reserved) | ||
{ | ||
switch (ul_reason_for_call) | ||
switch (reason) | ||
{ | ||
case DLL_PROCESS_ATTACH: | ||
DisableThreadLibraryCalls(base); | ||
CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)initialize, base, 0, nullptr); | ||
return TRUE; | ||
{ | ||
DisableThreadLibraryCalls(instance); | ||
|
||
HANDLE handle = CreateThread(nullptr, NULL, dll_entry, instance, NULL, nullptr); | ||
if (handle) | ||
CloseHandle(handle); | ||
|
||
break; | ||
} | ||
case DLL_PROCESS_DETACH: | ||
{ | ||
if (reserved == nullptr) | ||
return shutdown(); | ||
return TRUE; | ||
dll_detach(); | ||
|
||
default: | ||
return TRUE; | ||
break; | ||
} | ||
} | ||
|
||
return TRUE; | ||
} |
Oops, something went wrong.