Hi, I’m trying to read the memory of a program:
```
// Test
include
include <Windows.h>
using namespace std;
int main(){
string test = “test”;
cout <<&test<<endl;
while(1){
cout << "s="<<test<<endl;
system("pause");
}
}
When you execute this code, it prints the address of "test", and then, every time you press enter, it tells you its value.
include
include <Windows.h>
using namespace std;
int main(){
char PROCNAME[50] = "C:\\Users\\Usuario\\Desktop\\test.exe";
cout << "Press enter to start."<<endl;
HWND hwnd = FindWindow(NULL, PROCNAME);
cout << "[*] Searching process...";
if (hwnd == NULL){
cout << " [!]"<<endl;
MessageBoxA(NULL, "Couldn't find window", "ERROR", MB_OK | MB_ICONERROR);
exit(-1);
}
cout << "[DONE]"<<endl;
DWORD procId;
GetWindowThreadProcessId(hwnd, &procId);
cout << "[+] "<<PROCNAME << " is on: "<<procId<<endl;
cout << "[*] Opening process...";
HANDLE process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, procId);
if (process == NULL){
cout << " [ERROR]"<<endl;
MessageBoxA(NULL, "Cannot obtain process!", "Error", MB_OK | MB_ICONERROR);
exit(-1);
}
cout << " [DONE]"<<endl;
char buffer[500];
LPCVOID addr = (LPCVOID)0xb4fd70;
ReadProcessMemory(process, addr, &buffer, sizeof(buffer), 0);
cout << "Buffer: "<<buffer<<endl;
return 0;
}
```
With this code I’m trying to read that variable, but I can’t (Returns me strange ASCII letters).
Can someone tell me whats wrong??
Edit: I can attach to the process correctly, but when I use ReadProcessMemory() , Doesn’t return what it should