iw4x-client/src/Main.cpp

44 lines
756 B
C++
Raw Normal View History

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:06:52 -05:00
EntryPointHook.Uninstall();
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:06:52 -05:00
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
if (ul_reason_for_call == DLL_PROCESS_ATTACH)
{
DWORD oldProtect;
VirtualProtect(GetModuleHandle(NULL), 0x6C73000, PAGE_EXECUTE_READWRITE, &oldProtect);
EntryPointHook.Initialize(0x6BAC0F, [] ()
{
__asm
{
call Main::Initialize
mov eax, 6BAC0Fh
jmp eax
}
})->Install();
}
else if (ul_reason_for_call == DLL_PROCESS_DETACH)
{
Main::Uninitialize();
}
return TRUE;
}
2015-12-23 08:45:53 -05:00
}