-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproc.cpp
180 lines (149 loc) · 4.88 KB
/
proc.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
#include "proc.h"
DWORD GetProcId(const wchar_t* procName)
{
DWORD procId = 0;
// Get Process snapshot
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnap != INVALID_HANDLE_VALUE)
{
// Struct that contains process information
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hSnap, &procEntry))
{
//std::cout << "Failed to retrieve information about the first process." << std::endl;
return procId;
}
while (Process32Next(hSnap, &procEntry))
{
//std::wcout << "\nProcess " << procEntry.th32ProcessID << ": " << procEntry.szExeFile;
if (!_wcsicmp(procEntry.szExeFile, procName))
{
//std::cout << " <- Process Found!" << std::endl;
procId = procEntry.th32ProcessID;
break;
}
}
}
CloseHandle(hSnap);
return procId;
}
DWORD_PTR GetModuleBaseAddress64(DWORD processID)
{
DWORD_PTR baseAddress = 0;
HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processID);
HMODULE* moduleArray;
LPBYTE moduleArrayBytes;
DWORD bytesRequired;
if (hProc)
{
if (EnumProcessModules(hProc, NULL, 0, &bytesRequired))
{
if (bytesRequired)
{
moduleArrayBytes = (LPBYTE)LocalAlloc(LPTR, bytesRequired);
if (moduleArrayBytes)
{
unsigned int moduleCount;
moduleCount = bytesRequired / sizeof(HMODULE);
moduleArray = (HMODULE*)moduleArrayBytes;
if (EnumProcessModules(hProc, moduleArray, bytesRequired, &bytesRequired))
{
baseAddress = (DWORD_PTR)moduleArray[0];
}
LocalFree(moduleArrayBytes);
}
}
}
CloseHandle(hProc);
}
return baseAddress;
}
// Get the dynamic address given the offsets
uintptr_t FindDMAAddy(HANDLE hProc, uintptr_t ptr, std::vector<unsigned int> offsets)
{
uintptr_t addr = ptr;
for (unsigned int i = 0; i < offsets.size(); ++i)
{
ReadProcessMemory(hProc, (BYTE*)addr, &addr, sizeof(addr), 0);
addr += offsets[i];
}
return addr;
}
int GetProcInfo()
{
Values::procId = GetProcId(L"plutonium-bootstrapper-win32.exe");
if (!Values::procId)
{
std::cout << "\nProcess not found";
return 0;
}
Values::hProcess = OpenProcess(PROCESS_ALL_ACCESS, NULL, Values::procId);
return 1;
}
/*
void WriteToMemory(HANDLE hProcess, uintptr_t moduleBaseAddr, uintptr_t playerPtrBase, bool bHealth, bool bAmmo, bool bFireRate, bool bRecoil, PlayerAddr *_pAddrPtr)
{
// Ammo
if (bAmmo)
{
//Write to memory ammo
int newAmmo = 420;
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->ammo1, &newAmmo, sizeof(newAmmo), nullptr);
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->ammo2, &newAmmo, sizeof(newAmmo), nullptr);
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->ammo3, &newAmmo, sizeof(newAmmo), nullptr);
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->ammo4, &newAmmo, sizeof(newAmmo), nullptr);
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->ammo5, &newAmmo, sizeof(newAmmo), nullptr);
}
// Health
if (bHealth)
{
// 01 B7 A8010000 = add [edi+000001A8],esi
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x429E69), (BYTE*)("\x01\xB7\xA8\x01\x00\x00"), 6, hProcess);
}
else
{
// 29 B7 A8010000 = sub [edi+000001A8],esi
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x429E69), (BYTE*)("\x29\xB7\xA8\x01\x00\x00"), 6, hProcess);
}
// Fire Rate
if (bFireRate)
{
// 90 = nop
mem::NopEx((BYTE*)(moduleBaseAddr + 0x54B4CA), 2, hProcess);
}
else
{
// 89 03 = mov [ebx],eax
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x54B4CA), (BYTE*)("\x89\x03"), 2, hProcess);
}
// Recoil not so recoil
if (bRecoil)
{
// Cursor size increment nop //
int crossHairSize = 0;
// F3 0F11 8E 88050000 - movss [esi+00000588],xmm1 (general)
mem::NopEx((BYTE*)(moduleBaseAddr + 0x1BB552), 8, hProcess);
// F3 0F11 86 88050000 - movss [esi+00000588],xmm0 (shooting)
mem::NopEx((BYTE*)(moduleBaseAddr + 0x54B8F5), 8, hProcess);
// F3 0F11 86 88050000 - movss [esi+00000588],xmm0 (hit)
mem::NopEx((BYTE*)(moduleBaseAddr + 0x2675E5), 8, hProcess);
// D9 96 88050000 - fst dword ptr [esi+00000588] (jump)
mem::NopEx((BYTE*)(moduleBaseAddr + 0x53B702), 6, hProcess);
WriteProcessMemory(hProcess, (BYTE*)_pAddrPtr->crossHair, &crossHairSize, sizeof(crossHairSize), nullptr);
// Animation nop //
// 89 96 80050000 - mov[esi + 00000580], edx (gun shooting animation)
mem::NopEx((BYTE*)(moduleBaseAddr + 0x54B8A7), 6, hProcess);
}
else
{
// Cursor size op restore
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x1BB552), (BYTE*)("\xF3\x0F\x11\x8E\x88\x05\x00\x00"), 8, hProcess);
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x54B8F5), (BYTE*)("\xF3\x0F\x11\x86\x88\x05\x00\x00"), 8, hProcess);
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x2675E5), (BYTE*)("\xF3\x0F\x11\x86\x88\x05\x00\x00"), 8, hProcess);
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x53B702), (BYTE*)("\xD9\x96\x88\x05\x00\x00"), 6, hProcess);
// Animation restore
mem::PatchEx((BYTE*)(moduleBaseAddr + 0x54B8A7), (BYTE*)("\x89\x96\x80\x05\x00\x00"), 6, hProcess);
}
}
*/