-
-
Notifications
You must be signed in to change notification settings - Fork 230
/
Copy pathdllmain.cpp
47 lines (41 loc) · 1.22 KB
/
dllmain.cpp
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
#include "stdafx.h"
struct Screen
{
int32_t Width;
int32_t Height;
float fWidth;
float fHeight;
float fAspectRatio;
} Screen;
void Init()
{
if (!Screen.Width || !Screen.Height)
std::tie(Screen.Width, Screen.Height) = GetDesktopRes();
Screen.fWidth = static_cast<float>(Screen.Width);
Screen.fHeight = static_cast<float>(Screen.Height);
Screen.fAspectRatio = (Screen.fWidth / Screen.fHeight);
auto pattern = hook::pattern("D9 05 ? ? ? ? D8 73 68 D9 05 ? ? ? ? D8 73 6C D9 C9"); //0x4460E7
struct SetScaleHook
{
void operator()(injector::reg_pack& regs)
{
static float fScaleValue = ((1.0f / Screen.fAspectRatio) * (4.0f / 3.0f));
_asm fld dword ptr[fScaleValue]
}
}; injector::MakeInline<SetScaleHook>(pattern.get_first(0), pattern.get_first(6));
}
CEXP void InitializeASI()
{
std::call_once(CallbackHandler::flag, []()
{
CallbackHandler::RegisterCallback(Init, hook::pattern("83 EC 58 53 56 57 89 65 E8"));
});
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
if (!IsUALPresent()) { InitializeASI(); }
}
return TRUE;
}