For external processes, you need VirtualQuery and ReadProcessMemory. If you are searching for something within your own memory space (same process), you just need VirtualQuery and the rest is possible by casting.
I can't think of a way to do this without a windows API providing the information. Does such an API exist?
I am trying to code a function for a hack that will find an address given a pattern of bytes starting at that address -- I know this already exists, but I want to find out how by myself.
Thanks.
For external processes, you need VirtualQuery and ReadProcessMemory. If you are searching for something within your own memory space (same process), you just need VirtualQuery and the rest is possible by casting.
yodaliketaco (07-08-2011)
KK. Using that, I came up with this for the function:
Now it's time for me to see if it works.Code:bool matchPattern(PBYTE address, BYTE bytes) { if(*address == bytes) return true; else return false; } DWORD* scanAdd(BYTE bytes) { VirtualQuery(NULL, &procMem, sizeof(procMem)); int n; VOID *currentaddress; for(n = 0; n < procMem.RegionSize; n++) { currentaddress = ((PBYTE)procMem.BaseAddress + n); if(matchPattern((PBYTE)currentaddress, bytes)) return (DWORD*)currentaddress; } return 0; }