高手帮我分析一下,数据指针类型转换问题(0分)

  • 主题发起人 主题发起人 16cy
  • 开始时间 开始时间
1

16cy

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm2.Button8Click(Sender: TObject);<br>var<br>vq,paddr:longword;<br>address:longword;<br>xy:pByte;<br>nsize:longword;<br>x,y:integer;<br>meminfo:_MEMORY_BASIC_INFORMATION;<br>Number: longword;<br>i,j,k:integer;<br>token:cardinal;<br>begin<br>i:=0;<br>paddr:=1024;<br>nsize:=4;<br>xy:=AllocMem(nSize);<br>getwindowthreadprocessid(hnd,@Pid);//获得游戏相对应的进程的句柄<br>openprocess(PROCESS_ALL_ACCESS,false,pid);//获得进程控制权<br>//OpenProcessToken(pid,TOKEN_ADJUST_PRIVILEGES,token);//获得进程句柄的令牌环句柄<br>//AdjustTokenPrivileges(token,TRUE,ae,0,NULL,null); //修改权限<br>//扫描内存<br>vq:=VirtualQueryEx(pid,@paddr,meminfo,sizeof(meminfo));<br>[green]address:=meminfo.BaseAddress;[/green]<br>form2.Label9.Caption :=inttostr(address);<br>k:=meminfo.RegionSize div 2*nsize;<br>while vq=sizeof(meminfo) do<br>begin<br> &nbsp; if meminfo.state=MEM_COMMIT &nbsp;then<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; for j := 0 to k &nbsp;do<br> &nbsp; &nbsp; &nbsp; begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ReadProcessMemory(pid,pointer(address),xy,nsize,Number);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;x:=xy^;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;address:=address+nsize;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ReadProcessMemory(pid,pointer(address),xy,nsize,Number);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;y:=xy^;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;address:=address+nsize;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//如果x,y值等于100,100,就得到x,y坐标的地址<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if x=100 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if y=100 then<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;XYaddress:=address-2*nsize;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp; end;<br> &nbsp; &nbsp; &nbsp;vq:=VirtualQueryEx(pid,@paddr,meminfo,sizeof(meminfo));<br> &nbsp; &nbsp; &nbsp;i:=i+1;<br> &nbsp; &nbsp; &nbsp;end<br> &nbsp; else &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br> &nbsp; &nbsp; &nbsp;begin<br> &nbsp; &nbsp; &nbsp;paddr:=paddr+ meminfo.RegionSize;<br> &nbsp; &nbsp; &nbsp;vq:=VirtualQueryEx(pid,@paddr,meminfo,sizeof(meminfo));<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; if i=9 then break;<br> &nbsp; <br>end;<br>freemem(xy);<br>closehandle(pid);<br>end;<br><br>绿色的那段不知道如何转换。老是通不过编译,有没有高手帮我分析一下啊,我急啊!!!!55555555555555555555555<br>address:=meminfo.BaseAddress;<br>address定义为longword类型,meminfo.baseaddress是pointer类型。如何转换?<br>我把这句写成:<br>address:=dword(meminfo.baseaddress);<br>会提示:external exception c0000008 的错误<br>访问内存地址冲突 <br>有没有高手给我指点一下迷津啊?
 
用汇编试试吧<br>ASM<br>MOV EAX meminfo.baseaddress<br>MOV EBX DWORD PTR [EAX]<br>MOV ADDRESS EBX<br>END;
 
问题应该不是出在类型转换上.<br>这里有一个错误:<br>openprocess(PROCESS_ALL_ACCESS,false,pid);//获得进程控制权<br>vq:=VirtualQueryEx(pid,@paddr,meminfo,sizeof(meminfo));<br>ReadProcessMemory(pid,pointer(address),xy,nsize,Number);<br>应该改为:<br>var<br>ProcessHndle: HWND;<br>begin<br>ProcessHndle:=openprocess(PROCESS_ALL_ACCESS,false,pid);//获得进程控制权<br>vq:=VirtualQueryEx(ProcessHndle,@paddr,meminfo,sizeof(meminfo));<br>ReadProcessMemory(ProcessHndle,pointer(address),xy,nsize,Number);<br>...........
 
openprocess(PROCESS_ALL_ACCESS,false,pid);//获得进程控制权<br><br>你后面的注释是错误的,或者说是不准确的.<br>openprocess函数的作用是以参数1指定的权限打开指定进程,返回打开线程的句柄.<br>获得这个句柄,也是功能之一.
 
接受答案了.
 
后退
顶部