-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cpp
166 lines (139 loc) · 4.04 KB
/
Game.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
#include "Game.h"
bool CGame::InitAddress()
{
this->Address.ClientDLL = reinterpret_cast<DWORD64>(ProcessMgr.GetProcessModuleHandle("client.dll"));
this->Address.ServerDLL = reinterpret_cast<DWORD64>(ProcessMgr.GetProcessModuleHandle("server.dll"));
this->Address.EntityList = GetClientDLLAddress() + Offset::EntityList;
this->Address.Matrix = GetClientDLLAddress() + Offset::Matrix;
this->Address.ViewAngle = GetClientDLLAddress() + Offset::ViewAngle;
this->Address.LocalController = GetClientDLLAddress() + Offset::LocalPlayerController;
this->Address.LocalPawn = GetClientDLLAddress() + Offset::LocalPlayerPawn;
this->Address.ServerPawn = GetServerDLLAddress() + Offset::LocalPlayerPawn;
this->Address.ForceJump = GetClientDLLAddress() + Offset::ForceJump;
this->Address.ForceCrouch = GetClientDLLAddress() + Offset::ForceCrouch;
this->Address.ForceForward = GetClientDLLAddress() + Offset::ForceForward;
this->Address.ForceLeft = GetClientDLLAddress() + Offset::ForceLeft;
this->Address.ForceRight = GetClientDLLAddress() + Offset::ForceRight;
this->Address.GlobalVars = GetClientDLLAddress() + Offset::GlobalVars;
return this->Address.ClientDLL != 0;
}
DWORD64 CGame::GetClientDLLAddress()
{
return this->Address.ClientDLL;
}
DWORD64 CGame::GetServerDLLAddress()
{
return this->Address.ServerDLL;
}
DWORD64 CGame::GetEntityListAddress()
{
return this->Address.EntityList;
}
DWORD64 CGame::GetMatrixAddress()
{
return this->Address.Matrix;
}
DWORD64 CGame::GetViewAngleAddress()
{
return this->Address.ViewAngle;
}
DWORD64 CGame::GetEntityListEntry()
{
return this->Address.EntityListEntry;
}
DWORD64 CGame::GetLocalControllerAddress()
{
return this->Address.LocalController;
}
DWORD64 CGame::GetLocalPawnAddress()
{
return this->Address.LocalPawn;
}
DWORD64 CGame::GetServerPawnAddress()
{
return this->Address.ServerPawn;
}
DWORD64 CGame::GetGlobalVarsAddress()
{
return this->Address.GlobalVars;
}
bool CGame::UpdateEntityListEntry()
{
DWORD64 EntityListEntry = 0;
if (!ProcessMgr.ReadMemory<DWORD64>(gGame.GetEntityListAddress(), EntityListEntry))
return false;
if (!ProcessMgr.ReadMemory<DWORD64>(EntityListEntry + 0x10, EntityListEntry))
return false;
this->Address.EntityListEntry = EntityListEntry;
return this->Address.EntityListEntry != 0;
}
bool CGame::SetViewAngle(float Yaw, float Pitch)
{
Vec2 Angle{ Pitch,Yaw };
if (!ProcessMgr.WriteMemory<Vec2>(this->Address.ViewAngle, Angle))
return false;
return true;
}
bool CGame::SetForceJump(int value)
{
if (!ProcessMgr.WriteMemory<int>(this->Address.ForceJump, value))
return false;
return true;
}
bool CGame::GetForceJump(int& value)
{
if (!ProcessMgr.ReadMemory<int>(this->Address.ForceJump, value))
return false;
return true;
}
bool CGame::SetForceCrouch(int value)
{
if (!ProcessMgr.WriteMemory<int>(this->Address.ForceCrouch, value))
return false;
return true;
}
bool CGame::GetForceCrouch(int& value)
{
if (!ProcessMgr.ReadMemory<int>(this->Address.ForceCrouch, value))
return false;
return true;
}
// MovingType: 0 = Forward, 1 = Left, 2 = Right
bool CGame::SetForceMove(int MovingType, int Value)
{
switch (MovingType)
{
case 0:
if (!ProcessMgr.WriteMemory<int>(this->Address.ForceForward, Value)) return false;
break;
case 1:
if (!ProcessMgr.WriteMemory<int>(this->Address.ForceLeft, Value)) return false;
break;
case 2:
if (!ProcessMgr.WriteMemory<int>(this->Address.ForceRight, Value)) return false;
break;
default:
return false;
break;
}
return true;
}
bool CGame::GetForceMove(int MovingType, int& Value)
{
switch (MovingType)
{
case 0:
if (!ProcessMgr.ReadMemory<int>(this->Address.ForceForward, Value)) return false;
break;
case 1:
if (!ProcessMgr.ReadMemory<int>(this->Address.ForceLeft, Value)) return false;
break;
case 2:
if (!ProcessMgr.ReadMemory<int>(this->Address.ForceRight, Value)) return false;
break;
default:
return false;
break;
}
return true;
}