-
Notifications
You must be signed in to change notification settings - Fork 0
/
dllmain.cpp
170 lines (142 loc) · 3.69 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
// dllmain.cpp : Defines the entry point for the DLL application.
#include "pch.h"
#include "mem.h"
#include "Addresses.h"
#include "Offsets.h"
#include "Options.h"
#include "DX11.h"
using namespace d3d11Menu;
#include "info.h"
#include "console.h"
#define isEjecting options->isEjecting
DWORD WINAPI MainThread(HMODULE hModule)
{
// Create Console
cmd->Init();
std::cout << "[+] Dll Injection succeeded!" << std::endl;
Sleep(500);
std::cout << "[+] Initializing Cheat Menu... ";
Sleep(500);
// Hook d3d11, render ImGUI
if (!InitMenu())
{
std::cout << "FAILED" << std::endl;
std::cout << "[+] Hook failed. Ejecting dll... ";
isEjecting = true;
Sleep(1500);
}
else
{
std::cout << "OK" << std::endl;
std::cout << "[+] Success! Initializing cheats... ";
}
Sleep(500);
// Close console
cmd->Stop();
// Hack loop
while (!isEjecting)
{
// Press END to eject dll
isEjecting = ((GetAsyncKeyState(VK_END)) ? true : false);
// Calculate game memory addresses
if (!isEjecting) addr->calcAddresses();
if (isEjecting)
{
options->SetAllFalse();
}
// -- Menu
if (GetAsyncKeyState(VK_INSERT) & 1)
{
options->bMenu = !options->bMenu;
}
// check if the address is valid
info::checkBadPointers();
// -- HP
if (cHealth->isInvincible) // need this for extra security
{
if (options->bHealth)
{
*(int*)cHealth->isInvincible = 1;
}
else
{
*(int*)cHealth->isInvincible = 0;
}
}
// -- Ammo
if (cAmmo->infiniteAmmo)
{
if (options->bAmmo)
{
*(int*)cAmmo->infiniteAmmo = 1;
}
else
{
*(int*)cAmmo->infiniteAmmo = 0;
}
}
// -- Speed
if (cPlayerController->movementSpeed)
{
// reset movementSpeed
if (!options->bSpeedHack)
{
*(float*)cPlayerController->movementSpeed = 3;
}
}
// -- XP
if (cStatMod->multiplierBonus)
{
// reset xp multiplier
if (!options->bDoubleXP)
{
*(float*)cStatMod->multiplierBonus = 0;
}
}
// -- Timer
if (cGameTimer->timer)
{
if (options->bFinishGame)
{
*(float*)cGameTimer->timer = 1200.f; // 1200s = 20m
options->bFinishGame = false;
}
}
if (GetAsyncKeyState(VK_F1) & 1)
{
options->SetAllFalse();
}
if (GetAsyncKeyState(VK_F2) & 1)
{
options->SetAllTrue();
}
}
// Cleanup/Eject
if (!StopMenu()) {
return 1;
}
FreeLibraryAndExitThread(hModule, 0);
return 0;
}
BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)MainThread, hModule, NULL, NULL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
/*
auto end = std::chrono::system_clock::now();
if (((std::chrono::duration<double>)(end - t)).count() > 0.5 && !isEjecting)
{
// reset timer
t = std::chrono::system_clock::now();
}
auto t = std::chrono::system_clock::now();
*/