iw4x-client/src/Main.cpp

44 lines
746 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: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-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
{
call Main::Initialize
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
}