2015-12-23 08:45:53 -05:00
|
|
|
#include "STDInclude.hpp"
|
|
|
|
|
2016-01-24 07:06:52 -05:00
|
|
|
namespace Main
|
2015-12-23 08:45:53 -05:00
|
|
|
{
|
2015-12-23 09:00:01 -05:00
|
|
|
static Utils::Hook EntryPointHook;
|
|
|
|
|
2016-01-24 07:06:52 -05:00
|
|
|
void Initialize()
|
2015-12-23 08:45:53 -05:00
|
|
|
{
|
2016-01-24 07:44:42 -05:00
|
|
|
Main::EntryPointHook.Uninstall();
|
2016-01-24 07:06:52 -05:00
|
|
|
Components::Loader::Initialize();
|
2015-12-23 08:45:53 -05:00
|
|
|
}
|
2016-01-24 07:06:52 -05:00
|
|
|
|
|
|
|
void Uninitialize()
|
2015-12-23 08:45:53 -05:00
|
|
|
{
|
|
|
|
Components::Loader::Uninitialize();
|
|
|
|
}
|
2016-01-24 07:44:42 -05:00
|
|
|
}
|
2015-12-23 08:45:53 -05:00
|
|
|
|
2016-01-24 07:44:42 -05:00
|
|
|
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
|
|
|
{
|
|
|
|
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
|
2016-01-24 07:06:52 -05:00
|
|
|
{
|
2016-01-25 19:41:21 -05:00
|
|
|
// Ensure we're working with our desired binary
|
2016-01-26 10:12:41 -05:00
|
|
|
if (Utils::Hook::Get<DWORD>(0x4C0FFF) != 0x6824748B)
|
2016-01-25 19:41:21 -05:00
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2016-01-24 07:44:42 -05:00
|
|
|
DWORD oldProtect;
|
|
|
|
VirtualProtect(GetModuleHandle(NULL), 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect);
|
2016-01-24 07:06:52 -05:00
|
|
|
|
2016-01-24 07:44:42 -05:00
|
|
|
Main::EntryPointHook.Initialize(0x6BAC0F, [] ()
|
2016-01-24 07:06:52 -05:00
|
|
|
{
|
2016-01-24 07:44:42 -05:00
|
|
|
__asm
|
|
|
|
{
|
2016-01-24 07:54:36 -05:00
|
|
|
// This has to be called, otherwise the hook is not uninstalled and we're deadlocking
|
2016-01-24 07:44:42 -05:00
|
|
|
call Main::Initialize
|
2016-01-24 07:54:36 -05:00
|
|
|
|
2016-01-24 07:44:42 -05:00
|
|
|
mov eax, 6BAC0Fh
|
|
|
|
jmp eax
|
|
|
|
}
|
2016-01-24 07:06:52 -05:00
|
|
|
|
2016-01-24 07:44:42 -05:00
|
|
|
})->Install();
|
|
|
|
}
|
|
|
|
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
|
|
|
|
{
|
|
|
|
Main::Uninitialize();
|
2016-01-24 07:06:52 -05:00
|
|
|
}
|
2016-01-24 07:44:42 -05:00
|
|
|
|
|
|
|
return TRUE;
|
2015-12-23 08:45:53 -05:00
|
|
|
}
|