-
ReadProcessMemory() help
i am trying to use ReadProcessMemory to find a string in the running processs..
now the second param states it needs the address in which to read
what if i want to read all the addresss's . from 0 to the end of the code
is it possible ,
Code:
#include <iostream>
#include <windows.h>
using namespace std;
char buffer[500];
int main()
{
HANDLE T = OpenProcess(PROCESS_ALL_ACCESS , true , 3128);
ReadProcessMemory(T,0000000, buffer , sizeof(buffer) , NULL);
cout<<buffer<<endl;
return 0;
}
-
Um, I don't know, but don't really care because it's a really stupid idea.
-
Quote:
read all the addresss's
The address space of a process is 4GB. (Not all of which may be available.) Good luck going byte by byte through it. Allocated space could be anywhere in those 4GB, but probably constrained to the high or lower 2GB. (Which isn't much help.)
What exactly are you wanting to do? (There might be a lot easier way to solve your problem.)
While I've never dreamed of trying such a thing, you should be able to scan through a process's memory using VirtualQueryEx() - set lpAddress to 0 or 4KB to start, and it'll return info on that range. If the range is allocated, scan it for your data, if not, skip it, and call VirtualQueryEx() with lpAddress incremented by the size of the range. That's what I'd try, at least.
-
> what if i want to read all the addresss's
Same way as you read files which might be larger than your own memory - a smaller buffer and a for loop.
-
any examples guys? really stuck
-
Really helpless more like - if you can't do this without help, my impression is you're one typo away from hosing your machine.
for ( i = 0 ; i <= 0xffffffff ; i+= 0x10000 ) if ( readprocessmem(i,buff,bufsiz) == success )......
yada yada yada
-
thought you said use VirtualQueryEx()
-