Einzelnen Beitrag anzeigen

Fridolin Walther

Registriert seit: 11. Mai 2008
Ort: Kühlungsborn
446 Beiträge
 
Delphi 2009 Professional
 
#12

Re: String mit ReadMemoryProcess auslesen

  Alt 11. Jul 2009, 20:57
Simpler wäre es wahrscheinlich die ReadWideStringFromProcessMemory Funktion anzupassen, so daß "Offline" zurückgegeben wird statt einem leeren String.

Delphi-Quellcode:
function ReadWideStringFromProcessMemory(PID : Cardinal; AddressOfString : Cardinal) : WideString;
var
  ProcessHandle : THandle;
  WideCharRead : WideChar;
  BytesRead : Cardinal;
begin
  Result := '';
  ProcessHandle := OpenProcess(PROCESS_VM_READ, FALSE, PID);
  if ProcessHandle <> INVALID_HANDLE_VALUE then
    begin
      repeat
        ReadProcessMemory(ProcessHandle, Pointer(AddressOfString), @WideCharRead, SizeOf(WideCharRead), BytesRead);
        Inc(AddressOfString, SizeOf(WideCharRead));
        Result := Result + WideCharRead;
      until (Word(WideCharRead) = 0) or (BytesRead <> SizeOf(WideCharRead));
      CloseHandle(ProcessHandle);
    end;
  if Result = 'then Result := 'Offline';
end;
Fridolin Walther
"While Mr. Kim, by virtue of youth and naiveté, has fallen prey to the inexplicable need for human contact, let me step in and assure you that my research will go on uninterrupted, and that social relationships will continue to baffle and repulse me."
  Mit Zitat antworten Zitat