AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

CPP nach Delphi Übersetzung

Ein Thema von Gehstock · begonnen am 11. Feb 2010 · letzter Beitrag vom 11. Feb 2010
Antwort Antwort
Gehstock

Registriert seit: 28. Jan 2006
Ort: Görlitz / Sachsen
489 Beiträge
 
Delphi 2007 Professional
 
#1

Re: CPP nach Delphi Übersetzung

  Alt 11. Feb 2010, 14:59
Ok habs etwas umgestellt und jetzt scheint es zu klappen

Delphi-Quellcode:
function GetProcessID(Exename: string): DWord;
var
  hProcSnap: THandle;
  pe32: TProcessEntry32;
begin
  result := 0;
  hProcSnap := CreateToolHelp32SnapShot(TH32CS_SNAPPROCESS, 0);
  if hProcSnap <> INVALID_HANDLE_VALUE then
  begin
    pe32.dwSize := SizeOf(ProcessEntry32);
    if Process32First(hProcSnap, pe32) = true then
    begin
      while Process32Next(hProcSnap, pe32) = true do
      begin
        if pos(Exename, pe32.szExeFile) <> 0 then
          result := pe32.th32ProcessID;
      end;
    end;
    CloseHandle(hProcSnap);
  end;
end;

Function GetModuleBaseAddress(dwProcID: DWord; szModule: pChar): Cardinal;
var
  xModule: TMODULEENTRY32;
  hSnap: THandle;
begin
  hSnap := CreateToolHelp32SnapShot(TH32CS_SNAPMODULE, dwProcID);
  xModule.dwSize := SizeOf(MODULEENTRY32);
  Module32First(hSnap, xModule);
  repeat
    if LowerCase(xModule.szModule) = LowerCase(szModule) then
    begin
      result := Cardinal(xModule.modBaseAddr);
      break;
    end;
  until (not(Module32Next(hSnap, xModule)));
  CloseHandle(hSnap);
end;

procedure TForm2.Button1Click(Sender: TObject);
var
  pe32: TProcessEntry32;
  dwClientBase, dwBytes, dwProcID: DWord;
  dwEngineBase : Cardinal;
  hProcess: THandle;
begin
  dwProcID := GetProcessID('xxx.exe');
  if dwProcID <> 0 then
  begin
    // Showmessage(inttostr(dwProcID));
    hProcess := OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwProcID);
    // Showmessage(inttostr(hProcess));
    if (hProcess = INVALID_HANDLE_VALUE) then
    begin
      Showmessage('Finde Handle nicht');
      exit;
    end;
    // This seems to crash on Vista, which I'm running atm. works on XP.
    dwEngineBase := GetModuleBaseAddress(dwProcID, 'xxxx.exe');
    Showmessage(inttostr(dwEngineBase));
    // dwClientBase := GetModuleBaseAddress( dwProcID, 'xxxxx.dll' );
    // Putting manual addresses right now instead.
    // dwEngineBase := $20000000;
    // dwClientBase := $24000000;
    dwBytes := 0;
  end
  else
  begin
    Showmessage('Finde Prozess nicht');
  end;
end;
Marcel
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:59 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz