-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheat.cpp
More file actions
63 lines (55 loc) · 1.95 KB
/
Cheat.cpp
File metadata and controls
63 lines (55 loc) · 1.95 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
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
DWORD FindProcessID(const std::wstring& processName) {
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hSnapshot == INVALID_HANDLE_VALUE) {
std::cerr << "Failed to create snapshot. Error: " << GetLastError() << std::endl;
return 0;
}
PROCESSENTRY32 pe;
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &pe)) {
do {
if (processName == pe.szExeFile) {
CloseHandle(hSnapshot);
return pe.th32ProcessID;
}
} while (Process32Next(hSnapshot, &pe));
}
CloseHandle(hSnapshot);
return 0;
}
int main() {
DWORD processID = FindProcessID(L"ch.exe");
if (processID == 0) {
std::cerr << "Failed to find process ID." << std::endl;
return 1;
}
LPCVOID address = (LPCVOID)0x7FF7FEC0A440;
HANDLE hProcess = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_VM_OPERATION, FALSE, processID);
if (hProcess == NULL) {
std::cerr << "Failed to open process. Error: " << GetLastError() << std::endl;
return 1;
}
int currentValue;
if (!ReadProcessMemory(hProcess, address, ¤tValue, sizeof(currentValue), NULL)) {
std::cerr << "Failed to read memory. Error: " << GetLastError() << std::endl;
CloseHandle(hProcess);
return 1;
}
std::cout << "Current coins : " << currentValue << std::endl;
int newValue;
std::cout << "Enter the new value for coins: ";
std::cin >> newValue;
if (!WriteProcessMemory(hProcess, (LPVOID)address, &newValue, sizeof(newValue), NULL)) {
std::cerr << "Failed to write memory. Error: " << GetLastError() << std::endl;
CloseHandle(hProcess);
return 1;
}
std::cout << "Coins successfully changed to " << newValue << std::endl;
CloseHandle(hProcess);
getchar();
getchar();
return 0;
}