雨落空林 发表于 2011-3-29 09:33:08

delphi中读取指定内存地址的值的问题

我想读取地址为1005334的值,应该写..我写了个就是读不出数据




procedure TForm1.Button1Click(Sender: TObject);

var
hwnd:cardinal;
pid:Dword;
hProcess:cardinal;
x:widechar;
Num: cardinal;


begin

hwnd := FindWindow(nil, '扫雷');
GetWindowThreadProcessId (hwnd, @pid);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, false, pid);
    If hProcess <> 0 Then
    begin
      ReadProcessMemory(hprocess,Pointer($1005334),@x,sizeof(x),num);
      label1.Caption := string(x);

    end

    else

    showmessage('未启动游戏');
    CloseHandle(hProcess);

end;

Angell开心果 发表于 2011-3-29 09:33:26

ReadProcessMemory(hprocess,Pointer($1005334),@x,sizeof(x),num);
x:widechar;
SizeOf(x)是什么?
这里是读出的长度.

374919318 发表于 2011-3-29 09:33:37

procedure TForm1.Button1Click(Sender: TObject);
var
hwnd:cardinal;
pid:Dword;
hProcess:cardinal;
x:string;
Num: cardinal;


begin
setlength(X,$10);
hwnd := FindWindow(nil, 'Cheat Engine 5.3');
GetWindowThreadProcessId (hwnd, @pid);
hProcess := OpenProcess(PROCESS_ALL_ACCESS, false, pid);
    If hProcess <> 0 Then
    begin
      if ReadProcessMemory(hprocess,Pointer($1005334),@x,$10,num) then
      label1.Caption := string(x)
      else
      showmessage('读数失败~!');
    end
    else
      showmessage('未启动游戏');
    CloseHandle(hProcess);

end;
页: [1]
查看完整版本: delphi中读取指定内存地址的值的问题