Is there a way to know how much memory I can read from another process using ReadProcessMemory?
If I try to read too much memory from a specific address, it will return error code 299, and will read 0 bytes.
I'm guessing it's because I'm trying to read beyond the allocated buffer of the process.
Asked
Active
Viewed 208 times
1

Idov
- 5,006
- 17
- 69
- 106
-
3See http://stackoverflow.com/q/5571995/225757. In short, you want to use `VirtualQueryEx` to find out about the memory regions and then read them individually. – Roland Illig Oct 01 '11 at 11:26
-
This may not be relevant, but I wrote a program to read one byte from every committed page of a process, and [this question](http://stackoverflow.com/questions/2939599/is-it-possible-to-unpage-all-memory-in-windows) contains the core algorithm. – Kerrek SB Oct 01 '11 at 11:46
1 Answers
0
As far as I know, the only way is trying to read it. ReadProcessMemory
will return 0 if the memory block you want to read is not fully accessible in the process, e.g., part of it is not allocated.
Use a smaller nSize
(1024 or 512 or even 1) is a workaround.

CTQY
- 31
- 2