Einzelnen Beitrag anzeigen

brechi

Registriert seit: 30. Jan 2004
823 Beiträge
 
#8

Re: vergleichen von zwei librarys im speicher

  Alt 2. Jun 2005, 14:27
zusäzlich zu

http://www.delphipraxis.net/internal...ct.php?t=55308

noch nen bisl code
wenn ich gleich noch zeit habe kann ich dir noch die CompareExecuteSection machen aber da haste jedenfalls schonmal die beiden dll im speicher (die originale und die von dem spiel)

Delphi-Quellcode:
procedure IsCorrectExecuteSection(dlln,processname: string);
  function CompareExecuteSections(p1,p2: pointer): boolean;
  begin
    result := true;
  end;
var h1,h2, pr, dllprocsize: integer;
    read: cardinal;
    buf, buf2: pointer;
begin
  pr := uallProcess.FindProcess(processname);
  if pr = 0 then
    messagebox(0,'process not loaded',nil,0) else
  begin
    h1 := LoadLibrary(pchar(dlln));
    if h1 = 0 then
      messagebox(0,'cant load dll',nil,0) else
    begin
      h2 := uallProcess.GetModuleOffset(dlln,pr);
      if h2 = 0 then
        MessageBox(0,'dll in process not found',nil,0) else
      begin
        buf := VirtualAlloc(nil,$1000,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
        pr := OpenProcess(PROCESS_ALL_ACCESS,false,pr);
        ReadProcessMemory(pr,pointer(h2),buf,$1000,read);
        dllprocsize := uallUtil.GetModuleVirtualSize(integer(buf));
        if uallUtil.GetModuleVirtualSize(h1) <> dllprocsize then
          MessageBox(0,'other dll loaded',nil,0) else
        begin
          buf2 := VirtualAlloc(nil,dllprocsize,MEM_COMMIT,PAGE_EXECUTE_READWRITE);
          if CompareExecuteSections(pointer(h1),buf2) then
            MessageBox(0,'ok',nil,0) else
            MessageBox(0,'execute sections not same',nil,0);
          VirtualFree(buf2,dllprocsize,MEM_DECOMMIT);
        end;
        VirtualFree(buf,$1000,MEM_DECOMMIT);
      end;
    end;
    FreeLibrary(h1);
  end;
end;
  Mit Zitat antworten Zitat