Skip to content

Commit

Permalink
fix crash
Browse files Browse the repository at this point in the history
fix crash
  • Loading branch information
pa1n-dev committed Jun 26, 2024
1 parent c4564bf commit b2d0fda
Show file tree
Hide file tree
Showing 4 changed files with 1,697 additions and 1,718 deletions.
57 changes: 32 additions & 25 deletions dllmain.cpp
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;
}
Loading

0 comments on commit b2d0fda

Please sign in to comment.