iw4x-client/iw4/Main.cpp

30 lines
656 B
C++
Raw Normal View History

2015-12-23 08:45:53 -05:00
#include "STDInclude.hpp"
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
2015-12-23 09:00:01 -05:00
static Utils::Hook EntryPointHook;
2015-12-23 08:45:53 -05:00
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
FreeConsole();
DWORD oldProtect;
VirtualProtect(GetModuleHandle(NULL), 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect);
EntryPointHook.Initialize(0x6BAC0F, static_cast<void __declspec(naked)(*)()>([] ()
{
EntryPointHook.Uninstall();
Components::Loader::Initialize();
__asm jmp EntryPointHook.Place
2015-12-23 09:00:01 -05:00
2015-12-23 08:45:53 -05:00
}))->Install();
}
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
Components::Loader::Uninitialize();
}
return TRUE;
}