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 


[masm] ReadProcessMemory error

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

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Sat Sep 15, 2007 7:44 pm    Post subject: [masm] ReadProcessMemory error Reply with quote

Ok here is a snippet from a masm program I was toying with;

Code:

   .if process == NULL
      ; throw error not finding process
   .else
      invoke   VirtualProtectEx,process,theoffsettopatch,100,PAGE_EXECUTE_READWRITE,ADDR OldProtected
      .if eax == 0
         ; error unprotecting memory
      .else
         invoke ReadProcessMemory,process,theoffsettopatch,ADDR TheReadValue,SIZEOF TheReadValue,0
         invoke GetLastError
         invoke wsprintf,ADDR outBuffer,ADDR decimalformat,eax
         invoke MessageBox, NULL, addr outBuffer, addr caption, MB_OK
      .endif
   .endif


Well I can get the process fine - and the VirtualProtectEx appears to be working fine. The ReadProcessMemory is failing with error code 5. This is an access restriction error...

Hopefully someone can point me in the right direction with this one, I'm probably just doing something dumb. Is the VirtualProtectEx not working as I am expecting it to be? Or is my ReadProcessMemory bad...

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
Back to top
View user's profile Send private message
appalsap
Moderator
Reputation: 0

Joined: 27 Apr 2006
Posts: 6753
Location: Pakistan

PostPosted: Sat Sep 15, 2007 7:49 pm    Post subject: Reply with quote

Did you open the process with PROCESS_VM_READ and PROCESS_VM_OPERATION rights?
Back to top
View user's profile Send private message
zart
Master Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Sat Sep 15, 2007 7:51 pm    Post subject: Reply with quote

appalsap wrote:
Did you open the process with PROCESS_VM_READ and PROCESS_VM_OPERATION rights?


DOH!

Figured it would be something simple like that... I was opening it with PROCESS_VM_WRITE OR PROCESS_VM_OPERATION...

Thanks app Very Happy

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
Back to top
View user's profile Send private message
zart
Master Cheater
Reputation: 0

Joined: 20 Aug 2007
Posts: 351
Location: russia

PostPosted: Sat Sep 15, 2007 8:01 pm    Post subject: Reply with quote

x0r wrote:
Well all the parameters for VirtualProtectEx & ReadProcessMemory seem to be correct so I'm just going on the process identifier (handle) being wrong, why? It makes no sense for VirtualProtectEx to pass and not ReadProcessMemory when they both seem to have valid parameters. So maybe you accidentally entered the PID instead of getting correct access to the process (OpenProcess) then using the returned handle.

EDIT: Damn, appalsap beat me Sad


Thanks xor - thats actually what I had thought to start off with and that's why I was stumped. Of course I just wasn't looking at the obvious.

_________________
0x7A 0x61 0x72 0x74

TEAM RESURRECTiON
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