-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
236 lines (204 loc) · 7.55 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
// dllmain.cpp : Определяет точку входа для приложения DLL.
#include <Windows.h>
//#include "sdk.h"
//#include "d3d11draw/rD3D11.h"
//#include "d3d11draw/pch.h"
//#include "imgui/imgui.h"
//#include "imgui/imgui_impl_dx11.h"
//#include "imgui/imgui_impl_win32.h"
#include "Menu.h"
rD3D11 rd11;
std::vector<uintptr_t> healthcomponentplayer_offsets = { 0x8 ,0x10 ,0x30 ,0x118 ,0x28 ,0x0 };
std::vector<uintptr_t> CameraRigControllerPtr_offsets = { 0x0 ,0x10 ,0x30 ,0xC8 ,0x28 ,0xA0,0x0 };
std::vector<uintptr_t> CharacterBodyPtr_offsets = { 0x8 ,0x10 ,0x30 ,0xC8 ,0x28 ,0x48,0x0 };
std::vector<uintptr_t> CharacterMasterPtr_offsets = { 0x8 ,0x10 ,0x30 ,0x48 ,0x28 ,0x68,0x0 };
HealthComponent* PlayerHC = nullptr;
CameraRigController* PlayerCRC = nullptr;
CharacterBody* PlayerCB = nullptr;
CharacterMaster* PlayerCM = nullptr;
uintptr_t CAMERA_HEALTH_CHARACTER_PLAYER_BASE;
template <typename T>
T* SetPointerTo(T*& _where, uintptr_t baseaddr, std::vector<uintptr_t>& vec)
{
_where = nullptr;
do
{
_where = reinterpret_cast<T*>(FindAddressByOffset(baseaddr, vec));
} while (_where == nullptr);
return _where;
}
bool IsLoadedCorrect(HealthComponent*& one, CameraRigController*& two, CharacterBody*& three,CharacterMaster*& four)
{
if (one != nullptr && two != nullptr && three != nullptr && four != nullptr)
{
return true;
}
else
return false;
}
HRESULT __stdcall hkPresent(IDXGISwapChain* pThis, UINT SyncInterval, UINT Flags)
{
if (!rd11.pDevice || rd11.pSwapchain != pThis)
{
rd11.InitD3DDraw(pThis);
}
MenuMainFunc(rd11.pDevice, rd11.pContext);
return rd11.oPresentTramp(pThis, SyncInterval, Flags);
}
DWORD ScreenCastRoutine()
{
if (rd11.HookD3D())
{
while (true)
{
};
}
rd11.UnHook();
return 0;
}
DWORD MainHackRoutine()
{
while (true)
{
if (bInGame)
{
if (!bCheatInit)
{
CAMERA_HEALTH_CHARACTER_PLAYER_BASE = reinterpret_cast<uintptr_t>(GetModuleHandle(L"UnityPlayer.dll")) + 0x01563A28;
SetPointerTo<HealthComponent>(PlayerHC, CAMERA_HEALTH_CHARACTER_PLAYER_BASE, healthcomponentplayer_offsets);
SetPointerTo<CameraRigController>(PlayerCRC, CAMERA_HEALTH_CHARACTER_PLAYER_BASE, CameraRigControllerPtr_offsets);
SetPointerTo<CharacterBody>(PlayerCB, CAMERA_HEALTH_CHARACTER_PLAYER_BASE, CharacterBodyPtr_offsets);
SetPointerTo<CharacterMaster>(PlayerCM, CAMERA_HEALTH_CHARACTER_PLAYER_BASE, CharacterMasterPtr_offsets);
if (!IsLoadedCorrect(PlayerHC, PlayerCRC, PlayerCB, PlayerCM))
{
bInGame = false;
bCheatInit = false;
bKillByCoursor = false;
bCameraSettingsEnable = false;
bWriteInPY = false;
bCharacterSettingsWrite = false;
bGodModEnable = false;
}
else
{
bCheatInit = true;
}
}
}
else
{
bCheatInit = false;
bKillByCoursor = false;
bCameraSettingsEnable = false;
bWriteInPY = false;
bCharacterSettingsWrite = false;
bGodModEnable = false;
PlayerHC = nullptr;
PlayerCRC = nullptr;
PlayerCB = nullptr;
PlayerCM = nullptr;
}
if (IsLoadedCorrect(PlayerHC, PlayerCRC, PlayerCB,PlayerCM) && bCheatInit)
{
PlayerCM->_money = MenuPlayerCM._money;
if (bKillByCoursor)
{
if (PlayerCRC->lastCrosshairHurtBox != nullptr)
{
PlayerCRC->lastCrosshairHurtBox->healthComponent->health = 0;
}
}
if (bGodModEnable)
{
PlayerHC->godMode = true;
}
else
{
PlayerHC->godMode = false;
}
if (bCameraSettingsEnable)
{
if (bWriteInPY)
{
PlayerCRC->pitch = MenuPlayerCRC.pitch;
PlayerCRC->yaw = MenuPlayerCRC.yaw;
}
PlayerCRC->baseFov = MenuPlayerCRC.baseFov;
PlayerCRC->currentFov = MenuPlayerCRC.currentFov;
PlayerCRC->currentCameraDistance = MenuPlayerCRC.currentCameraDistance;
PlayerCRC->disableSpectating = MenuPlayerCRC.disableSpectating;
PlayerCRC->enableFading = MenuPlayerCRC.enableFading;
PlayerCRC->fadeEndDistance = MenuPlayerCRC.fadeEndDistance;
PlayerCRC->fadeStartDistance = MenuPlayerCRC.fadeStartDistance;
PlayerCRC->fovVelocity = MenuPlayerCRC.fovVelocity;
PlayerCRC->maxAimRaycastDistance = MenuPlayerCRC.maxAimRaycastDistance;
}
else
{
MenuPlayerCRC.pitch = PlayerCRC->pitch;
MenuPlayerCRC.yaw = PlayerCRC->yaw;
MenuPlayerCRC.baseFov = PlayerCRC->baseFov;
MenuPlayerCRC.currentFov = PlayerCRC->currentFov;
MenuPlayerCRC.crosshairWorldPosition = PlayerCRC->crosshairWorldPosition;
MenuPlayerCRC.currentCameraDistance = PlayerCRC->currentCameraDistance;
MenuPlayerCRC.disableSpectating = PlayerCRC->disableSpectating;
MenuPlayerCRC.enableFading = PlayerCRC->enableFading;
MenuPlayerCRC.fadeEndDistance = PlayerCRC->fadeEndDistance;
MenuPlayerCRC.fadeStartDistance = PlayerCRC->fadeStartDistance;
MenuPlayerCRC.fovVelocity = PlayerCRC->fovVelocity;
MenuPlayerCRC.maxAimRaycastDistance = PlayerCRC->maxAimRaycastDistance;
}
if (bCharacterSettingsWrite)
{
*PlayerCB = MenuPlayerCB;
}
else
{
MenuPlayerCB = *PlayerCB;
}
}
else
{
bInGame = false;
}
Sleep(1);
Sleep(10);
}
return 0;
}
DWORD ClickHandler()
{
while (true)
{
if (GetAsyncKeyState(VK_INSERT) & 1)
{
menuMainShow = !menuMainShow;
if (menuCameraSettingsShow)
{
menuCameraSettingsShow = false;
}
if (menuCharacterSettingsShow)
{
menuCharacterSettingsShow = false;
}
}
Sleep(10);
}
}
BOOL APIENTRY DllMain( HMODULE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH: CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(MainHackRoutine), hModule, NULL, NULL);
CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(ScreenCastRoutine), hModule, NULL, NULL);
CreateThread(NULL, NULL, reinterpret_cast<LPTHREAD_START_ROUTINE>(ClickHandler), hModule, NULL, NULL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}