Repository navigation
Expand file tree
/
Copy pathdllmain.cpp
More file actions
51 lines (44 loc) · 1.45 KB
/
Copy pathdllmain.cpp
File metadata and controls
51 lines (44 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "hudfix.h"
#include <MinHook.h>
#include <Windows.h>
#include <cstring>
#pragma comment(linker, "/export:getBuildInfo=Engine_BuildInfo_orig.getBuildInfo")
namespace
{
// UIMovieInstance::onViewResized sub esp, 48h / push ebx
constexpr BYTE readyBytes[] = { 0x83, 0xEC, 0x48, 0x53 };
DWORD WINAPI initThread(LPVOID)
{
const auto* probe = reinterpret_cast<const BYTE*>(OFF_UIMovieInstance_onViewResized);
while (std::memcmp(probe, readyBytes, sizeof(readyBytes)) != 0)
Sleep(1);
if (MH_Initialize() != MH_OK)
{
hudfix::log("MinHook init failed");
return 0;
}
hudfix::installScaleHooks();
hudfix::installWidgetHooks();
hudfix::installMenuHooks();
hudfix::installSettingsHooks();
hudfix::installPerfHooks();
hudfix::installGameplayHooks();
hudfix::installScopeHooks();
hudfix::installInputHooks();
hudfix::installVisualHooks();
const MH_STATUS status = MH_EnableHook(MH_ALL_HOOKS);
hudfix::log("hooks: {}", MH_StatusToString(status));
hudfix::loadSettings();
return 0;
}
}
BOOL APIENTRY DllMain(HMODULE module, DWORD reason, LPVOID)
{
if (reason == DLL_PROCESS_ATTACH)
{
DisableThreadLibraryCalls(module);
if (HANDLE thread = CreateThread(nullptr, 0, &initThread, nullptr, 0, nullptr))
CloseHandle(thread);
}
return TRUE;
}