https://github.com/idouble/simple-memory-reading-writing
🔍 Very Simple Template to read / write Process Memory with C++ 🔧
https://github.com/idouble/simple-memory-reading-writing
cplusplus cpp dword findwindow handle hwnd memory process read readprocessmemory simple snippets template thread windows write writeprocessmemory
Last synced: about 1 month ago
JSON representation
🔍 Very Simple Template to read / write Process Memory with C++ 🔧
- Host: GitHub
- URL: https://github.com/idouble/simple-memory-reading-writing
- Owner: IDouble
- License: mit
- Created: 2019-08-10T05:49:07.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-29T17:00:31.000Z (over 1 year ago)
- Last Synced: 2025-04-26T07:15:56.039Z (about 1 month ago)
- Topics: cplusplus, cpp, dword, findwindow, handle, hwnd, memory, process, read, readprocessmemory, simple, snippets, template, thread, windows, write, writeprocessmemory
- Language: C++
- Size: 843 KB
- Stars: 62
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# 🔍 Simple Memory Reading Writing 🔧
🔍 Very Simple Template to read / write Process Memory with C++ 🔧## 🔍 Read Process Memory (ReadProcessMemory) 🔍
```
#include
#includeusing namespace std;
int main(){
int readTest = 0; // We store the Value we read from the Process here
HWND hwnd = FindWindowA(NULL, "Tutorial-x86_64"); // HWND (Windows window) by Window Name
// Check if HWND found the Window
if (hwnd == NULL) {
cout << "Can't find Process." << endl;
Sleep(2000); // Sleep 2 seconds
exit(-1); // Exit the program if it did not find the Window
} else {
DWORD procID; // A 32-bit unsigned integer, DWORDS are mostly used to store Hexadecimal Addresses
GetWindowThreadProcessId(hwnd, &procID); // Getting our Process ID, as an ex. like 000027AC
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID); // Opening the Process with All Accessif (procID == NULL) {
cout << "Can't find Process." << endl;
Sleep(2000); // Sleep 2 seconds
exit(-1); // Exit the program if it did not find the Window
} else {
// Read the Process Memory, 03007640 is the Address, we read the Value from and save it in readTest
ReadProcessMemory(handle, (PBYTE*)0x03007640, &readTest, sizeof(readTest), 0);
cout << readTest << endl;
Sleep(5000); // Sleep 5 seconds
}
}
}
```
## 🔧 Write into Process Memory (WriteProcessMemory) 🔧
```
#include
#includeusing namespace std;
int main() {
int newValue = 5000; // The new Value we set on the address
HWND hwnd = FindWindowA(NULL, "Tutorial-x86_64"); // HWND (Windows window) by Window Name
// Check if HWND found the Window
if (hwnd == NULL) {
cout << "Can't find Process." << endl;
Sleep(2000); // Sleep 2 seconds
exit(-1); // Exit the program if it did not find the Window
}
else {
DWORD procID; // A 32-bit unsigned integer, DWORDS are mostly used to store Hexadecimal Addresses
GetWindowThreadProcessId(hwnd, &procID); // Getting our Process ID, as an ex. like 000027AC
HANDLE handle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procID); // Opening the Process with All Accessif (procID == NULL) {
cout << "Can't find Process." << endl;
Sleep(2000); // Sleep 2 seconds
exit(-1); // Exit the program if it did not find the Window
}
else {
// Write the newValue into the Process Memory, 03007640 is the Address
WriteProcessMemory(handle, (PBYTE*)0x03007640, &newValue, sizeof(newValue), 0);
Sleep(5000); // Sleep 5 seconds
}
}
}
```
