| View previous topic :: View next topic |
| Author |
Message |
Zeroblue Newbie cheater
Reputation: 0
Joined: 25 Oct 2015 Posts: 19
|
Posted: Fri Feb 03, 2017 7:05 pm Post subject: C++ ReadProcessMemory Partial reads |
|
|
Hi,
My RPM calls sometimes return partial results (Last bytes read is less than what I had called in the parameters). The memory region looks accessible in Cheat Engine, so I must be missing some debugging permissions with my code.
It works correctly 99% of the time. I am already using VirtualQueryEx to get the memory regions, so this isn't the problem.
Can anyone offer some insight? Thank you.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Feb 04, 2017 3:32 am Post subject: |
|
|
You can read the full info on ReadProcessMemory here:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms680553(v=vs.85).aspx
In short, if you get a partial read return, then you need to offset the address you originally read at with the returned size within lpNumberOfBytesRead and read the rest of the data a second time. This can fail multiple times with the same error so you should be handling this as needed.
Also if you are reading over page bounds, the two pages may have different access rights preventing the read from working properly.
_________________
- Retired. |
|
| Back to top |
|
 |
Zeroblue Newbie cheater
Reputation: 0
Joined: 25 Oct 2015 Posts: 19
|
Posted: Sat Feb 04, 2017 4:26 pm Post subject: |
|
|
I am aware of the documentation but it offers nothing as far as helping to resolve the issue.
The error code 299 gives no info to troubleshoot further.
Continuing the read operation where it failed still results in a 299. Reading at the affected address directly also yields the same error code, except with ZERO bytes read. Again, this memory region is visible in cheat engine (with meaningful values) while my function call is unable to read it.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Feb 04, 2017 5:16 pm Post subject: |
|
|
Check the access on the region. Is it guarded? You may need to use VirtualProtect/VirtualProtectEx yourself to reset the pages protection to allow you to read it.
_________________
- Retired. |
|
| Back to top |
|
 |
Viloresi Expert Cheater
Reputation: 0
Joined: 02 Feb 2017 Posts: 149
|
Posted: Wed Feb 15, 2017 6:35 am Post subject: |
|
|
If cheat engine is able to read that memory region with readprocessmemory, then your program must do the same if you didn't type something wrong.
Probably what you are misding is if the page is guarded or not... But if you don't post your code, you will never receive answers, but just guessings... I remember when I did my first memory scanner there were a lot of specific stuff to pay attention to avoid a crash due to unaccessible memoryparts
|
|
| Back to top |
|
 |
|