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 


Problem with WriteProcessMemory

 
Post new topic   This topic is locked: you cannot edit posts or make replies.    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Stok3r
Guest





PostPosted: Tue Dec 04, 2012 7:48 am    Post subject: Problem with WriteProcessMemory Reply with quote

Hi, I have a problem to create a trainer, this is the code:

Code:
Var WindowName : integer;
    ProcessId : integer;
    ThreadId : integer;
    buf : PChar;
    HandleWindow : Integer;
    write : cardinal;
   
Const WindowTitle = 'Spider Solitaire';
      Address = $0011DAC4;
      PokeValue = $1F4; //500
      NumberOfBytes = 4;

procedure TForm1.Button1Click(Sender: TObject);
begin
WindowName := FindWindow(nil,WindowTitle);
  If WindowName = 0 then
  begin
    MessageDlg('The game must be running in the background.Run it now, and then try again.', mtwarning,[mbOK],0);
  end;

  ThreadId := GetWindowThreadProcessId(WindowName,@ProcessId);
  HandleWindow := OpenProcess(PROCESS_ALL_ACCESS,False,ProcessId);

  GetMem(buf,1);
  buf^ := Chr(PokeValue);
  WriteProcessMemory(HandleWindow,ptr(Address),buf,NumberOfBytes,write);
  FreeMem(buf);
  closehandle(HandleWindow);
end;


I tried when spider solitaire, but the problem is that I can only put 255 in pokevalue, if I overcome the 255 starts to go backwards, I put NumberOfByte = 4, but the maximum is always 255, why? Thank you all.

Sorry for my bad English.
Back to top
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Tue Dec 04, 2012 9:45 am    Post subject: Reply with quote

Your buffer type is PChar, use a type that can hold more data.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Stok3r
Guest





PostPosted: Wed Dec 05, 2012 8:06 am    Post subject: Reply with quote

Wiccaan wrote:
Your buffer type is PChar, use a type that can hold more data.


I solved when using this code:

Code:
var
value:dword

{...}

value:=100;

WriteProcessMemory(HandleWindow,ptr(Address),@value,NumberOfBytes,write);


I have another problem, I found the pointer, but now how do I read the pointer address? Thanks!
Back to top
Stok3r
Guest





PostPosted: Thu Dec 06, 2012 6:42 pm    Post subject: Reply with quote

up
Back to top
Screitor
Cheater
Reputation: 1

Joined: 26 Nov 2012
Posts: 33
Location: Venezuela

PostPosted: Thu Dec 06, 2012 7:14 pm    Post subject: Reply with quote

Stok3r wrote:
I have another problem, I found the pointer, but now how do I read the pointer address? Thanks!


C'mon...

ReadProcessMemory.

_________________
Everybody lies.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   This topic is locked: you cannot edit posts or make replies.    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