-
Notifications
You must be signed in to change notification settings - Fork 1
/
firstExternalTrainer.cpp
132 lines (79 loc) · 3.03 KB
/
firstExternalTrainer.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
// firstExternalTrainer.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include "pch.h"
#include "ProcessManager.h"
#include "MemoryManager.h"
#include "player.h"
#include "entityList.h"
#include "WindowManager.h"
#include "OverlayWindow.h"
void espThreadFunc(WindowManager gameWindow);
Player findLocalPlayer(uintptr_t moduleBaseAdd, MemoryManager * mm);
EntityList* findEntityList(uintptr_t moduleBaseAdd, MemoryManager * mm);
using String = std::string ;
void espThreadFunc( WindowManager gameWindow)
{
std::wstring overLayname = L"ESP-HACK";
OverlayWindow hackOverlay(overLayname, gameWindow);
hackOverlay.runEventLoop();
}
Player findLocalPlayer( uintptr_t moduleBaseAdd, MemoryManager * mm)
{
uintptr_t dynamicPtrTolocalPlayer = moduleBaseAdd + PLAYER_OFFSET;
uintptr_t playerAddr = 0;
mm->ReadMemValue(dynamicPtrTolocalPlayer, &playerAddr , sizeof(playerAddr));
if (!playerAddr)
{
std::cout << "Local player address not found";
exit(-1);
}
std::cout << "player address found at 0x" << std::hex << playerAddr << std::dec << " (" << std::hex << dynamicPtrTolocalPlayer << std::dec << "-> )" << std::endl;
Player localPlayer(playerAddr);
return localPlayer;
}
EntityList * findEntityList(uintptr_t moduleBaseAdd, MemoryManager * mm)
{
uintptr_t ptrToEntityList = moduleBaseAdd + ENTITY_LIST_OFFSET;
uintptr_t entityListAddress = 0;
if (!mm->ReadMemValue(ptrToEntityList, &entityListAddress, sizeof(entityListAddress)) || entityListAddress == 0)
{
std::cout << "entity list not found";
exit(-1);
}
std::cout << "entity list found at 0x" << std::hex << entityListAddress << std::hex << std::endl;
EntityList* entListInstance = EntityList::createInstance(*mm, entityListAddress);
entListInstance->populate(100);
return entListInstance;
}
int main()
{
const wchar_t * name = L"ac_client.exe";
std::vector<unsigned int> playerObjOffsets = { 0x0 };
std::vector<unsigned int> entityListOffsets = { 0x0 };
ProcessManager pm(name, name);
MemoryManager * memoryManager = MemoryManager::createInstance(pm);
Player::setmemoryManger(memoryManager);
if (!pm.getProcId())
{
std::cout << "process not found" << std::endl;
return 0;
}
uintptr_t moduleBaseAddress = pm.getModuleBaseAddress();
std::cout << "module base address = " << "0x" << std::hex << moduleBaseAddress << std::endl;
Player localPlayer = findLocalPlayer(moduleBaseAddress, memoryManager);
EntityList* entitylistInstance = findEntityList(moduleBaseAddress, memoryManager);
entitylistInstance->setLocalPlayer(&localPlayer);
DWORD dwExit;
std::cout << std::dec << "localPlayer Health = " << localPlayer.getHealth() << std::endl;
std::cout << "localPlayer name = " << localPlayer.getName() << std::endl;
WindowManager * gameWindow = WindowManager::create(&pm);
std::thread espThread( &espThreadFunc , *gameWindow);
int i = 0;
while (GetExitCodeProcess( memoryManager->getHandle(), &dwExit) && dwExit == STILL_ACTIVE )
{
Sleep(1000);
}
espThread.join();
memoryManager->Close();
return 0;
}