Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


C++ ReadProcessMemory Partial reads

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Zeroblue
Newbie cheater
Reputation: 0

Joined: 25 Oct 2015
Posts: 19

PostPosted: Fri Feb 03, 2017 7:05 pm    Post subject: C++ ReadProcessMemory Partial reads Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Feb 04, 2017 3:32 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Zeroblue
Newbie cheater
Reputation: 0

Joined: 25 Oct 2015
Posts: 19

PostPosted: Sat Feb 04, 2017 4:26 pm    Post subject: Reply with quote

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
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Feb 04, 2017 5:16 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
Viloresi
Expert Cheater
Reputation: 0

Joined: 02 Feb 2017
Posts: 149

PostPosted: Wed Feb 15, 2017 6:35 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites