Einzelnen Beitrag anzeigen

Yakumo500

Registriert seit: 15. Nov 2008
Ort: Darmstadt
106 Beiträge
 
#7

Re: MemorySpeicher effektiv durchsuchen

  Alt 24. Sep 2009, 20:55
So hab das Problem behoben leider ist mein Programm trotzdem noch langsam!
Kann jmd helfen und mir Tipps geben wie es schneller geht?

Delphi-Quellcode:
function MemorySearch(Process: Cardinal; FromAddr: DWORD = $00000000; ToAddr: DWORD = $FFFFFFFF): boolean;
var _FromAddr: DWORD;
    mbi: _MEMORY_BASIC_INFORMATION;
    StartValue: longint;
    EndValue: longint;
    buffer: integer;
    i: longint;
    bytesread: cardinal;
begin
  _FromAddr := FromAddr;

  while _FromAddr < ToAddr do
  begin
    VirtualQueryEx(Process, Ptr(_FromAddr), mbi, sizeof(_MEMORY_BASIC_INFORMATION));
                //<> MEM_FREE oder = MEM_COMMIT and (mbi.Protect = PAGE_READWRITE) and (mbi.Type_9 = MEM_PRIVATE)
    if (mbi.State = MEM_COMMIT) and (mbi.Protect <> PAGE_NOACCESS) and (mbi.Type_9 = MEM_PRIVATE) then
    begin
      StartValue := Integer(mbi.BaseAddress);
      EndValue := Integer(mbi.BaseAddress) + mbi.RegionSize;

      for i := StartValue to EndValue - 1 do
      begin
        if ReadProcessMemory(Process, Ptr(i), @buffer, Sizeof(integer), bytesread) = False then
        begin
          Continue;
        end
        else
        begin
          if buffer = 1 then
                   Form1.ListBox1.Items.Add('Start: $' + inttohex(i, 8) + ' Value: ' + inttostr(buffer));
        end;
          Form1.Label1.Caption := inttostr(form1.ListBox1.Items.Count);
        Application.ProcessMessages;
      end;
      Form1.Label1.Caption := inttostr(form1.ListBox1.Items.Count);

      Application.ProcessMessages;
    end;
    _FromAddr := _FromAddr + mbi.RegionSize;
  end;
  Showmessage('Ready');
end;
  Mit Zitat antworten Zitat