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 


[Delphi]GetModuleBase + address and offset

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
matx132
How do I cheat?
Reputation: 0

Joined: 22 Dec 2010
Posts: 5

PostPosted: Wed Dec 22, 2010 6:33 am    Post subject: [Delphi]GetModuleBase + address and offset Reply with quote

welcome,
I had problem with getmodulebase Sad
my code:
Code:

p:=strtoint('$1386E080')+strtoint('$88');
ReadProcessMemory(ProcessHandle, pointer(p), @buffer, 4, rw);
edit2.text:='$'+inttohex(buffer[0],2);
p:=strtoint(edit2.text)+strtoint('$214');
ReadProcessMemory(ProcessHandle, pointer(p), @buffer, 4, rw);
edit3.text:='$'+inttohex(buffer[0],2);
p:=strtoint(edit3.text)+strtoint('$6C');
ReadProcessMemory(ProcessHandle, pointer(p), @buffer, 4, rw);
edit4.text:='$'+inttohex(buffer[0],2);
p:=strtoint(edit4.text)+strtoint('$24');
ReadProcessMemory(ProcessHandle, pointer(p), @buffer, 4, rw);
edit5.text:='$'+inttohex(buffer[0],2);
p:=strtoint(edit5.text)+strtoint('$230');
ReadProcessMemory(ProcessHandle, pointer(p), @buffer, 4, rw);
edit6.text:=inttostr(buffer[0]);



When i write p:=strtoint('$1386E080')+strtoint('$88');
and all is correct but address 1386E080 always diffrent when i restart game.
i know e.g. address 1386E080 is engine.dll+0153B5E0
and when i read in CE engine.dll +0153B5E0 and write in program all is correct but i try write function to get address from "engine.dll +0153B5E0"


i try this function but not work:
Code:

var
  hSnap: Cardinal;
  tm: TModuleEntry32;
begin
  result := 0;
  hSnap := CreateToolHelp32Snapshot(TH32CS_SNAPMODULE, hProcID);
  if hSnap <> 0 then
  begin
    tm.dwSize := sizeof(TModuleEntry32);
    if Module32First(hSnap, tm) = true then
    begin
      while Module32Next(hSnap, tm) = true do
      begin
        if lstrcmpi(tm.szModule, lpModName) = 0 then
        begin
          result := Cardinal(tm.modBaseAddr);
          break;
        end;
      end;
    end;
    CloseHandle(hSnap);
  end;


used:
Code:
GetModuleBase(ID,'engine.dll')+strtoint('$0153B5E0')

but is wrong address why?

Please help me
and sorry for my english.

Best regards,
Matx132
Back to top
View user's profile Send private message
M.CORP
Grandmaster Cheater Supreme
Reputation: 28

Joined: 28 Oct 2009
Posts: 1010

PostPosted: Wed Dec 22, 2010 1:40 pm    Post subject: Reply with quote

The address keeps on shifting each time you launch it.
Probably you are hacking a flash game or just an application that has hack protection.
If it's an app game, find the pointer.

_________________
Shameless Self Advertising Very Happy!
Steam
Just lurking around...
Back to top
View user's profile Send private message
matx132
How do I cheat?
Reputation: 0

Joined: 22 Dec 2010
Posts: 5

PostPosted: Wed Dec 22, 2010 1:50 pm    Post subject: Reply with quote

this is app game,
and i had
engine.dll + 0153B5E0
and 5 offset,
but in CE when i write engine.dll + 0153B5E0 i get address and can add offset
but in program (delphi/C++) i get get this address from engine.dll + 0153B5E0
please help me with this because i can't read this address,

How CE know when i wirte engine.dll + 0153B5E0 What is to be address??
i must create exactly the same mechanism, which is in the CE.

Somebody know how to do it?

Thanks for help
Back to top
View user's profile Send private message
matx132
How do I cheat?
Reputation: 0

Joined: 22 Dec 2010
Posts: 5

PostPosted: Thu Dec 23, 2010 8:01 am    Post subject: Reply with quote

i try get this from CE source but is too much for me and i can't,
Please somebody help me



/edit

i try used some code from CE

Code:

function getAddressFromName(name: string; waitforsymbols: boolean):dword;
var
    offset: dword;
    mi:tmoduleinfo;
    sn: string;
    i: integer;
    ws: widestring;
    error: boolean;
    processhandle: thandle;
  ths: thandle;
  me32:MODULEENTRY32;
  x: pchar;
  processid,tyt: dword;
begin
GetWindowThreadProcessId(FindWindow(nil,'my game'), @processid);
form1.label1.caption:=inttostr(processid);
try
    //first cut of the name from the offset
    offset:=0;
    for i:=length(name) downto 1 do
      if name[i] in ['+','-'] then
      begin
        sn:=copy(name,i+1,length(name));
        offset:=strtoint('$'+sn);
        name:=copy(name,1,i-1);
        break;
      end
      else
      if name[i] in ['[',']'] then
        break;
  except
//    raise symexception.create(sn+' is not a valid value');
  end;
  if getreg(uppercase(name),false)<>9 then
begin
end;
  try
    modulelistpos:=0;
    if processid=0 then exit;
    ths:=CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,processid);
   if ths<>0 then
    begin
      me32.dwSize:=sizeof(MODULEENTRY32);
      if ths<>0 then
      begin
        try
          if module32first(ths,me32) then
          repeat
            if modulelistpos+1>=length(modulelist) then
              setlength(modulelist,length(modulelist)*2);

            x:=me32.szExePath;
            if(extractfilename(x)='Engine.dll') then
              begin
                tyt:=dword(me32.modBaseAddr);
               //result:=dword(me32.modBaseAddr)+offset;
              end;

            inc(modulelistpos);

          until not module32next(ths,me32);
        finally
          closehandle(ths);
        end;
      end;
    end;
  finally
  end;
  //form1.Timer1.Interval:=10000;
   result:=tyt+offset;
end;




used:

Code:

tt:=form1.Edit1.Text;
currentaddress:=getAddressFromName(tt,true);
check:=readprocessmemory(FindWindow(nil,'my game'),pointer(currentaddress),@currentaddress2,4,read);


and not work why?
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