读内存的字符串变成了乱码(100分)

  • 主题发起人 主题发起人 全文检索
  • 开始时间 开始时间

全文检索

Unregistered / Unconfirmed
GUEST, unregistred user!
function getmaptext(hand:longint;id: Pointer):string;<br> var<br> &nbsp;ProcessID:dword;<br> &nbsp;ProcessHndle: HWND;<br> &nbsp;lpNumberOfBytesRead: DWORD;<br> &nbsp;s:string;<br> &nbsp;ok:boolean;<br> begin<br> &nbsp;result:='';<br> &nbsp;getwindowthreadprocessid(hand, ProcessID);<br> &nbsp;ProcessHndle := OpenProcess(PROCESS_VM_READ OR PROCESS_VM_OPERATION ,false,<br> &nbsp;ProcessID);<br> &nbsp;if ProcessHndle &lt;= 0 then exit;<br> &nbsp;setlength(s,256);<br> &nbsp;ok:=ReadProcessMemory(ProcessHndle,id,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;pchar(s),256, lpNumberOfBytesRead);<br> &nbsp; &nbsp; &nbsp; &nbsp; if ok then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=s;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end;<br> CloseHandle(ProcessHndle);<br> end;<br><br>请帮我看看为什么我读取一个内存地址的字符串时读出来的是乱码<br><br>而用金山游侠查看这个地址是却不是乱码<br><br>用金山游侠查看了一下,再调用这个函数得到的就不会是乱码了<br><br><br><br>我是这样调用的<br><br>memo1.Lines.Text :=getmaptext(handle,pointer($00388f20));
 
指针参数有问题。<br>ok:=ReadProcessMemory(ProcessHndle,id,pchar(s),256, lpNumberOfBytesRead);<br>=&gt;<br>ok:=ReadProcessMemory(ProcessHndle,id,@s[1],256,lpNumberOfBytesRead);
 
谢了,我也找到一样的方法<br><br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;p:=@s;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result:=string(p^);<br><br><br>接受答案了
 
后退
顶部