Getting Adress of variable in another process

hello i can simply handle process by using HANDLE hProcess = OpenProcess(stuffhere);

how can i basicly go throught all the adresses in the process and find the exactly one which is equal to the value i entered

so lets say i entered 50

then i want to find all the adresses of the process which after dereferencing contains the value 50 is this possible ?
Last edited on
It is indeed possible.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
char getbytefromprocess(DWORD pid, uint64_t loc) {
  HANDLE pHandle;
  SYSTEM_INFO si;
  MEMORY_BASIC_INFORMATION mbi;
  LPVOID lpMem;
  DWORD ret, totalRead;

  pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid);
  if (pHandle == NULL) {
    return false; //You may want to do some error handling here
  }

  lpMem = (void*)loc;

  char buf;
  ReadProcessMemory(pHandle, lpMem, (LPVOID)(&buf), 1, &totalRead);

  CloseHandle(pHandle);
  return buf;
}
Last edited on
not just one variable might containt the value so basicly i need loop? 0x0400000 to 0xFFFFFFF or smth like that?
Windows program's memory location changes between executions, you'll have to generally either have to search for it every time or possibly start the other program as a child process.
Topic archived. No new replies allowed.