-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathSDK.h
More file actions
480 lines (395 loc) · 11.5 KB
/
SDK.h
File metadata and controls
480 lines (395 loc) · 11.5 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
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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
#pragma once
namespace M
{
__forceinline const char* ReadASCII(QWORD Address)
{
char Data[64];
Driver.ReadArr(Address, Data, 64);
return Data;
}
/*__forceinline const char**/std::string ReadArmaString(QWORD Address)
{
//std::string String = {};
int Len = Driver.Read<int>(Address + Offsets::ArmaString::Length);
// auto buffer = std::make_unique<char[]>(Len);
// ReadArr(Address + 0x10, buffer.get(), Len);
// char Data[64];
if (Len > 120)
{
TRACE("[WARN] Too long str len > 64 (%d)\n", Len);
return {};
}
//char* pBuffer = new char[Len + 1];
char Buffer[120] = {};
//RtlZeroMemory(pBuffer, Len);
Driver.ReadArr(Address + Offsets::ArmaString::Data, Buffer, Len);
//String.reserve(Len);
//Driver.ReadArr(Address + Offsets::ArmaString::Data, (PVOID)String.data(), Len);
return std::string(Buffer, Len);
}
template <typename T>
__forceinline T ReadChain(std::initializer_list<uint64_t> Offsets, bool ReadFirstOffset = true)
{
auto Start = Offsets.begin();
size_t ReadSize = Offsets.size();
uint64_t LastPtr = read<uint64_t>((ReadFirstOffset ? read<uint64_t>(Start[0]) : Start[0]) + Start[1]);
for (size_t i = 2; i < ReadSize - 1; i++)
if (!(LastPtr = read<uint64_t>(LastPtr + Start[i])))
return T{};
return read<T>(LastPtr + Start[ReadSize - 1]);
}
template <typename T>
__forceinline bool WriteChain(std::initializer_list<uint64_t> Offsets, T Value, bool ReadFirstOffset = true)
{
auto Start = Offsets.begin();
size_t ReadSize = Offsets.size();
uint64_t LastPtr = read<uint64_t>((ReadFirstOffset ? read<uint64_t>(Start[0]) : Start[0]) + Start[1]);
for (size_t i = 2; i < ReadSize - 1; i++)
if (!(LastPtr = read<uint64_t>(LastPtr + Start[i])))
return false;
Driver.Write(LastPtr + Start[ReadSize - 1], Value);
}
}
namespace Enfusion
{
class CCamera;
class CEntity;
class CSortedObject;
//NOTE: custom wrapper
template <typename T>
class CList
{
public:
CList(QWORD dwListBase, QWORD dwSizeOffset = sizeof(PVOID)) :
m_dwListBase(dwListBase), m_dwSizeOffset(dwSizeOffset)
{}
QWORD GetBase()
{
return m_dwListBase;
}
uint32_t GetSize()
{
// printf("[DBG] [%s] 0x%p\n", __FUNCSIG__, this->m_dwListBase + this->m_dwSizeOffset);
return Driver.Read<uint32_t>(this->m_dwSizeOffset);
}
T* Get(DWORD32 Position)
{
/*
Ïðèâåäåíèå òèïîâ áåç ïðîâåðêè.
reinterpret_cast — íåïîñðåäñòâåííîå óêàçàíèå êîìïèëÿòîðó.
Ïðèìåíÿåòñÿ òîëüêî â ñëó÷àå ïîëíîé óâåðåííîñòè ïðîãðàììèñòà â ñîáñòâåííûõ äåéñòâèÿõ.
Íå ñíèìàåò êîíñòàíòíîñòü è volatile. ïðèìåíÿåòñÿ äëÿ ïðèâåäåíèÿ óêàçàòåëÿ ê óêàçàòåëþ, óêàçàòåëÿ ê öåëîìó è íàîáîðîò.
*/
QWORD Element = Driver.Read<QWORD>(this->m_dwListBase + (Position * 0x8));
return reinterpret_cast<T*>(Element);
}
T* GetLoot(DWORD32 Position)
{
DWORD32 ValidCheck = Driver.Read<DWORD32>(this->m_dwListBase + (Position * 0x18));
if (ValidCheck == 1)
return Driver.Read<T*>(this->m_dwListBase + (Position * 0x18) + 0x8);
return nullptr;
// return reinterpret_cast<T*>(Element);
}
private:
QWORD m_dwListBase = 0x0ull;
QWORD m_dwSizeOffset = 0x0ull;
};
class CPlayerIdentity
{
public:
std::uint32_t GetNetworkID()
{
return Driver.Read<std::uint32_t>((QWORD)this + Offsets::PlayerIdentity::NetworkID);
}
std::string GetPlayerName()
{
QWORD ArmaSring = Driver.Read<QWORD>((QWORD)this + Offsets::PlayerIdentity::PlayerName);
return M::ReadArmaString(ArmaSring);
}
};
class CWorld
{
public:
CCamera* GetCamera()
{
return Driver.Read<CCamera*>((QWORD)this + Offsets::World::Camera);
}
CSortedObject* GetCameraOn()
{
return Driver.Read<CSortedObject*>((QWORD)this + Offsets::World::CameraOn);
}
// Near:
QWORD GetNearAnimalTablePtr()
{
return Driver.Read<QWORD>((QWORD)this + Offsets::World::NearAnimalTable);
}
QWORD GetNearAnimalTableSize()
{
return /*Driver.Read<DWORD32>*/((QWORD)this + Offsets::World::NearAnimalTable + sizeof(PVOID));
}
// Far:
QWORD GetFarAnimalTablePtr()
{
return Driver.Read<QWORD>((QWORD)this + Offsets::World::FarAnimalTable);
}
QWORD GetFarAnimalTableSize()
{
return /*Driver.Read<DWORD32>*/((QWORD)this + Offsets::World::FarAnimalTable + sizeof(PVOID));
}
// Slow:
QWORD GetSlowAnimalTablePtr()
{
return Driver.Read<QWORD>((QWORD)this + Offsets::World::SlowAnimalTable);
}
QWORD GetSlowAnimalTableSize()
{
return /*Driver.Read<QWORD>*/((QWORD)this + Offsets::World::SlowAnimalTable + sizeof(PVOID));
}
QWORD GetItemTablePtr(DWORD64 Index)
{
return Driver.Read<QWORD>((QWORD)this + Offsets::World::ItemTable + (Index * 0x20));
}
QWORD GetItemTableSize(DWORD64 Index)
{
return /*Driver.Read<QWORD>*/((QWORD)this + Offsets::World::ItemTable + (Index * 0x20) + sizeof(PVOID));
}
QWORD GetBulletTablePtr()
{
return Driver.Read<QWORD>((QWORD)this + Offsets::World::BulletTable);
}
QWORD GetBulletTableSize()
{
return /*Driver.Read<QWORD>*/((QWORD)this + Offsets::World::BulletTable + sizeof(PVOID));
}
};
class CSortedObject
{
public:
CEntity* GetEntity()
{
return Driver.Read<CEntity*>((QWORD)this + 0x8);
//return reinterpret_cast<CEntity*>((DWORD64)this - 0xA8);
}
CEntity* GetLocal()
{
// NOTE: Do not read, just cast
return reinterpret_cast<CEntity*>((QWORD)this->GetEntity() - 0xA8);
}
};
/*
* std::vector<uint32_t> human_bone_indices = {
0, 19, 20, 21, 24, // pelvis to head
94, 97, 99, // left arm
61, 63, 65, // right arm
9, 12, 14, 16, // left leg
1, 4, 6, 8 // right leg
};
std::vector<uint32_t> zombie_bone_indices =
{
0, 15, 16, 19, 21, // pelvis to head
56, 59, 60, // left arm
24, 25, 27, // right arm
9, 12, 13, 14, // left leg
1, 4, 6, 7 // right leg
};
*/
class CDayZPlayerType
{
public:
std::string GetTypeName()
{
QWORD Pointer = Driver.Read<QWORD>((QWORD)this + Offsets::PlayerType::TypeName);
return M::ReadArmaString(Pointer);
}
std::string GetModelName()
{
QWORD Pointer = Driver.Read<QWORD>((QWORD)this + Offsets::PlayerType::ModelName);
return M::ReadArmaString(Pointer);
}
std::string GetConfigName()
{
QWORD Pointer = Driver.Read<QWORD>((QWORD)this + Offsets::PlayerType::ConfigName);
return M::ReadArmaString(Pointer);
}
std::string GetCleanName()
{
QWORD Pointer = Driver.Read<QWORD>((QWORD)this + Offsets::PlayerType::CleanName);
return M::ReadArmaString(Pointer);
}
};
class CEntityVisualState
{
public:
Math::Vector3D GetPosition()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::VisualState::Location);
}
Math::Vector3D GetHeadPosition()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::VisualState::HeadPosition);
}
void SetPosition(Math::Vector3D Pos)
{
Driver.Write<Math::Vector3D>((QWORD)this + Offsets::VisualState::Location, Pos);
}
};
class CInventory
{
public:
CEntity* GetItemInHands()
{
return Driver.Read<CEntity*>((QWORD)this + Offsets::Inventory::ItemInHands);
}
};
class CEntity
{
public:
CEntity* GetBaseEntity()
{
return /*read*/reinterpret_cast<CEntity*>((QWORD)this - 0xA8);
}
CDayZPlayerType* GetRendererEntityType()
{
return Driver.Read<CDayZPlayerType*>((QWORD)this + Offsets::Entity::RendererEntityType);
}
#if 0 // Siggied
QWORD GetSkeleton()
{
QWORD PlayerSkeleton = read<QWORD>((QWORD)this + Offsets::PlayerSkeleton);
if (!PlayerSkeleton) // Zombie?
{
QWORD ZombieSkeleton = read<QWORD>((QWORD)this + Offsets::ZombieSkeleton);
if (ZombieSkeleton) return ZombieSkeleton;
}
else
return PlayerSkeleton;
return NULL;
}
#endif
CEntityVisualState* GetRendererVisualState()
{
return Driver.Read<CEntityVisualState*>((QWORD)this + Offsets::Entity::VisualState);
}
CEntityVisualState* GetFutureVisualState()
{
return Driver.Read<CEntityVisualState*>((QWORD)this + Offsets::Entity::FutureVisualState);
}
bool IsDead()
{
return Driver.Read<bool>((QWORD)this + Offsets::Entity::IsDamagedOrDestroyed);
}
DWORD32 GetNetworkID()
{
return Driver.Read<DWORD32>((QWORD)this + Offsets::Entity::NetworkID);
}
CInventory* GetInventory()
{
return Driver.Read<CInventory*>((QWORD)this + Offsets::Entity::Inventory);
}
};
class CNetworkClient
{
public:
QWORD GetScoreBoard()
{
return Driver.Read<QWORD>((QWORD)this + Offsets::NetworkClient::ScoreBoard);
}
CPlayerIdentity* GetPlayerIdentity(std::uint32_t dwNetworkID)
{
void* pScoreBoard = reinterpret_cast<void*>(this->GetScoreBoard());
if (!pScoreBoard)
return nullptr;
for (std::uint64_t i = 0; i < this->GetPlayersCount(); i++)
{
CPlayerIdentity* pIdentity = /*read*/reinterpret_cast<CPlayerIdentity*>((DWORD64)pScoreBoard + (i * 0x160));
if (!pIdentity)
continue;
// TRACE("[FACE] [DBG] pIdentity: 0x%p [%d]\n", pIdentity, this->GetPlayersCount());
if (pIdentity->GetNetworkID() == dwNetworkID)
return pIdentity;
}
return nullptr;
}
std::string GetServerName()
{
QWORD ArmaString = Driver.Read<QWORD>((QWORD)this + Offsets::NetworkClient::ServerName);
return M::ReadArmaString(ArmaString);
}
std::uint32_t GetPlayersCount()
{
return Driver.Read<std::uint32_t>((QWORD)this + Offsets::NetworkClient::PlayersCount);
}
std::string GetPlayerName(CEntity* pEntity)
{
CPlayerIdentity* pIdentity = GetPlayerIdentity(pEntity->GetNetworkID());
if (!pIdentity)
return {};
return pIdentity->GetPlayerName();
}
};
class CCamera
{
public:
Math::Vector3D GetInvertedViewTranslation()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetInvertedViewTranslation);
}
Math::Vector3D GetInvertedViewRight()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetInvertedViewRight);
}
Math::Vector3D GetInvertedViewUp()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetInvertedViewUp);
}
Math::Vector3D GetInvertedViewForward()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetInvertedViewForward);
}
Math::Vector3D GetViewportSize()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetViewportSize);
}
Math::Vector3D GetProjectionD1()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetProjectionD1);
}
Math::Vector3D GetProjectionD2()
{
return Driver.Read<Math::Vector3D>((QWORD)this + Offsets::Camera::GetProjectionD2);
}
};
class CWinEngine
{
public:
int GetRight()
{
return Driver.Read<int>((QWORD)this + Offsets::WinEngine::Right);
}
int GetBottom()
{
return Driver.Read<int>((QWORD)this + Offsets::WinEngine::Bottom);
}
int GetLeft()
{
return Driver.Read<int>((QWORD)this + Offsets::WinEngine::Left);
}
int GetTop()
{
return Driver.Read<int>((QWORD)this + Offsets::WinEngine::Top);
}
void* GetInputDevice()
{
return Driver.Read<void*>((QWORD)this + Offsets::WinEngine::InputDevice);
}
void* GetRenderer()
{
return Driver.Read<void*>((QWORD)this + Offsets::WinEngine::Renderer);
}
HWND GetWindow()
{
return Driver.Read<HWND>((QWORD)this + Offsets::WinEngine::hWnd);
}
};
}