delphi指针指向的值怎么显示在edit中 ( 积分: 10 )

  • 主题发起人 主题发起人 angel725
  • 开始时间 开始时间
A

angel725

Unregistered / Unconfirmed
GUEST, unregistred user!
var&nbsp;<br>hp:pointer;&nbsp;<br>begin&nbsp;<br>...<br>ReadProcessMemory(handle,pointer(i),hp,nsize,&nbsp;lpNumberOfBytesRead);&nbsp;<br>edit1.text:=?;&nbsp;&nbsp;&nbsp;//这里?号的地方要怎么写??&nbsp;<br>end;&nbsp;<br><br>?号的地方要怎么写??&nbsp;<br>让edit显示出HP的值
 
PString(hp);
 
不对哦<br><br>功能很简单,就是读程序中指定地址的值,<br>var<br>&nbsp;&nbsp;a:Thandle;<br>&nbsp;&nbsp;pid:longword;<br>&nbsp;&nbsp;jb,i:integer;<br>&nbsp;&nbsp;hp:pointer;<br>&nbsp;&nbsp;nsize,lpNumberOfBytesRead:dword;<br>begin<br>&nbsp;&nbsp;&nbsp;i:=$0c0890c0;<br>&nbsp;&nbsp;&nbsp;nSize:=4;<br>&nbsp;&nbsp;&nbsp;hp:=AllocMem(nsize);<br>&nbsp;&nbsp;&nbsp;a:=FindWindow(nil,'XXXXX');<br>&nbsp;&nbsp;&nbsp;GetWindowThreadProcessId(a,pid);<br>&nbsp;&nbsp;&nbsp;jb:=OpenProcess(PROCESS_ALL_ACCESS,false,pid);<br>&nbsp;&nbsp;&nbsp;ReadProcessMemory(jb,pointer(i),hp,nsize,&nbsp;lpNumberOfBytesRead);<br>&nbsp;&nbsp;&nbsp;edit1.Text:=PString(hp);&nbsp;//错在这行;<br><br>错误:<br>[Error]&nbsp;Unit1.pas(42):&nbsp;Incompatible&nbsp;types:&nbsp;'String'&nbsp;and&nbsp;'PAnsiString'<br>[Fatal&nbsp;Error]&nbsp;Project1.dpr(5):&nbsp;Could&nbsp;not&nbsp;compile&nbsp;used&nbsp;unit&nbsp;'Unit1.pas'
 
Edit1.Text&nbsp;:=&nbsp;HP^;
 
edit1.Text:=HP^;<br><br>错误:<br>[Error]&nbsp;Unit1.pas(42):&nbsp;Incompatible&nbsp;types:&nbsp;'String'&nbsp;and&nbsp;'procedure,&nbsp;untyped&nbsp;pointer&nbsp;or&nbsp;untyped&nbsp;parameter'<br>[Fatal&nbsp;Error]&nbsp;Project1.dpr(5):&nbsp;Could&nbsp;not&nbsp;compile&nbsp;used&nbsp;unit&nbsp;'Unit1.pas'
 
试试&nbsp;StrPCopy
 
var<br>&nbsp;&nbsp;a:Thandle;<br>&nbsp;&nbsp;pid:longword;<br>&nbsp;&nbsp;jb,i:integer;<br>&nbsp;&nbsp;hp:pointer;<br>&nbsp;&nbsp;nsize,lpNumberOfBytesRead:dword;<br>begin<br>&nbsp;&nbsp;&nbsp;i:=$0c0890c0;<br>&nbsp;&nbsp;&nbsp;nSize:=4;<br>&nbsp;&nbsp;&nbsp;hp:=AllocMem(nsize);<br>&nbsp;&nbsp;&nbsp;a:=FindWindow(nil,'Form1');<br>&nbsp;&nbsp;&nbsp;GetWindowThreadProcessId(a,pid);<br>&nbsp;&nbsp;&nbsp;jb:=OpenProcess(PROCESS_ALL_ACCESS,false,pid);<br>&nbsp;&nbsp;&nbsp;ReadProcessMemory(jb,pointer(i),hp,nsize,&nbsp;lpNumberOfBytesRead);<br>&nbsp;&nbsp;//修改成这样就可以了.&nbsp;win32指针是32位所以8位十六进制就可以了<br>&nbsp;&nbsp;&nbsp;edit1.Text:=&nbsp;IntToHex(integer(hp),&nbsp;8)&nbsp;;&nbsp;//错在这行;
 
按楼上的倒是可以读出来,<br>不过,不管程序运行没运行。<br>我上面的代码运行结果总是00D543BC,换成十进制13976508<br>不是我要的,<br><br>为什么呢??<br><br>PID我看了,没有错,和任务管理器的一样。是哪的问题呢
 
楼上的是什么意思,<br>是这样写吗:<br>edit1.Text&nbsp;:=StrPas(hp);<br>也对啊结果是个?号
 
接受答案了.
 
后退
顶部