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 


Readprocessmemory?

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

Joined: 25 Aug 2009
Posts: 37

PostPosted: Thu Apr 01, 2010 11:16 am    Post subject: Readprocessmemory? Reply with quote

I want to read one address but it shows me a wrong value.
I use this
Code:
var
  hProcess,HandleWindow: THandle;
  Struct: TProcessEntry32;
  ProcessID,temp:cardinal;
  buf:pchar;
begin
  HandleWindow :=FindWindow(nil,'The window title ;)');
  GetWindowThreadProcessId(HandleWindow,@ProcessID);
  hProcess := OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessID);
  getmem(buf,4);
  readprocessmemory(hProcess,ptr($00A56AA8),buf,4,temp);
  showmessage(string(buf));
  freemem(buf);
  if hProcess <> 0 then
    CloseHandle(hProcess);
end;

and use this
Code:
showmessage(inttostr(integer(buf)));
to show me a real value. The message shows wrong value Sad Can someone help me?

Kind regards Megaz0r
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Thu Apr 01, 2010 2:38 pm    Post subject: Reply with quote

buf is a pointer to a block of 4 bytes, so try dereferencing it first:
showmessage(inttostr(integer(buf^)));

alternatively:
Code:

var
  myinteger: integer;
...
  readprocessmemory(hProcess,ptr($00A56AA8),@myinteger,4,temp);

showmessage(inttostr(myinteger));

_________________
Tools give you results. Knowledge gives you control.

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

Joined: 27 Jun 2009
Posts: 529
Location: Canada

PostPosted: Thu Apr 01, 2010 5:02 pm    Post subject: Reply with quote

Problem HERE:

Code:

hProcess,HandleWindow: THandle;


Change that to:

Code:

hProcess : THandle;
HandleWindow : HWND;


Another one:



Code:
readprocessmemory(hProcess,ptr($00A56AA8),buf,4,temp);


To:

Code:
readprocessmemory(hProcess,ptr($00A56AA8),[b]@[/b]buf, 4,temp);
Back to top
View user's profile Send private message MSN Messenger
Dark Byte
Site Admin
Reputation: 475

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

PostPosted: Thu Apr 01, 2010 7:55 pm    Post subject: Reply with quote

Code:

hProcess,HandleWindow: THandle;

is ok, HWND is just another name for System.THandle

Code:

readprocessmemory(hProcess,ptr($00A56AA8),@buf, 4,temp);

that is bad, and you should never do that
Using pchar to allocate a 4 byte block and then store 4 bytes in that block isn't useful, but overwriting the pointer with data is worse

freemem(buf); will then cause massive damage

_________________
Tools give you results. Knowledge gives you control.

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

Joined: 25 Aug 2009
Posts: 37

PostPosted: Fri Apr 02, 2010 2:53 am    Post subject: Reply with quote

10q DarkByte and iPromise. NOW IT WORKS Razz
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