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 


RPM sometimes gives 0 bytes read

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Sun May 03, 2020 5:36 pm    Post subject: RPM sometimes gives 0 bytes read Reply with quote

RPM will not read anything if it hits an inaccessible memory region. Recently I upgraded my code from reading 4 by 4 into reading memory chunks for increased speed, but now SOMETIMES it can't read anything (gives 0 bytes read). Such cases happen for example when reading an object's structure, most objects have ~4096 structure size (no errors reading that much) but rarely there's an object with address like 1C52CBB8 and it's size is ~400 bytes (due to it's different type but like every object it shares the same basics) - that's where RPM fails and the object is invisible to the application. GetLastError gives "only a part of request was completed" but I don't even get the part that could be read. So my question is, is it possible to somehow just get whatever part of memory is readable, or do I have to write separate code for each type of object that there's to read due to their difference in sizes? (I'd really rather avoid that)
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 155

Joined: 25 Jan 2006
Posts: 7986
Location: 127.0.0.1

PostPosted: Sun May 03, 2020 6:35 pm    Post subject: Reply with quote

Some things to check:
- Make sure you have proper access to the process from the handle you opened.
- Make sure the memory page has valid access to be read from. (If not, use VirtualProtectEx to adjust it as needed.)
- Make sure you are using valid memory types for your address and not over/underflowing the variable holding the desired address to read. (ie. if you are targeting a 64bit process/address.)

And no, you don't need to write custom handlers for each object unless you want to. ReadProcessMemory already contains a mechanism to deal with partial reads which you can use to loop the call and complete a read as needed based on a given return and read size.

Your issue is more than likely due to one of the above issues or something similar if it's giving you this error and not reading/returning anything read at all.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Sun May 03, 2020 8:12 pm    Post subject: Reply with quote

atom0s wrote:
Some things to check:
- Make sure you have proper access to the process from the handle you opened.
- Make sure the memory page has valid access to be read from. (If not, use VirtualProtectEx to adjust it as needed.)
- Make sure you are using valid memory types for your address and not over/underflowing the variable holding the desired address to read. (ie. if you are targeting a 64bit process/address.)

And no, you don't need to write custom handlers for each object unless you want to. ReadProcessMemory already contains a mechanism to deal with partial reads which you can use to loop the call and complete a read as needed based on a given return and read size.

Your issue is more than likely due to one of the above issues or something similar if it's giving you this error and not reading/returning anything read at all.

As I said in the first post, it's none of these. I probably should have mentioned though that for reading chunks of memory I use char array of various sizes, but every time RPM is set to read as much as the char array can hold.
So if RPM can read memory until it hits an error, how do I make it do that? Currently if it hits error it returns 0 bytes read even if the first 100 were readable.
Also, earlier I checked with cheat engine and it wasn't able to read "after certain offset" either.

Edit: I never had issues reading memory. As I also mentioned in the first post, reading smaller chunks works fine - the problem was offset 448 - that was outside the readable range (even CE couldn't read it). But it happened just for this one address and it sometimes happens in other cases. All I need is being able to read memory from specific address, up to the point where it's unreadable or enough bytes were read. Right now RPM will read NOTHING if it reads from address and steps into inaccessible area.
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 155

Joined: 25 Jan 2006
Posts: 7986
Location: 127.0.0.1

PostPosted: Sun May 03, 2020 11:49 pm    Post subject: Reply with quote

Use VirtualQueryEx to pull the page information, align to the page your address falls inside of that is valid/readable.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Dark Byte
Site Admin
Reputation: 379

Joined: 09 May 2003
Posts: 22682
Location: The netherlands

PostPosted: Mon May 04, 2020 1:22 am    Post subject: Reply with quote

if RPM fail with 0 bytes read change the size to:
Code:
 
4096-(lastaddress & 0xfff)


rpm doesn't properly handle read errors from a non page aligned base address that overlaps a page boundary, so first read the full page to get to a page boundary and then go from there

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Mon May 04, 2020 3:25 am    Post subject: Reply with quote

Thank you kind sirs.
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 programming 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