!!!!高分求教ReadProcessMemory读取内存.有关内存偏移量的问题!

!!!!高分求教ReadProcessMemory读取内存.有关内存偏移量的问题! Delphi / Windows SDK/API
http://www.delphi2007.net/DelphiBase/html/delphi_20061207125413246.html
已知一基地址$010EA0CC,偏移量为$2A4,先在用ReadProcessMemory函数连读取内存数据,为什么我用其他工具(例如:CE)可以读取到正常的数据,但  
  ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);  
  却为0?是不是$010EA0CC是一个指针地址.请大家赐教  
   
  procedure   TForm1.Button1Click(Sender:   TObject);  
  var   gameHwnd:Hwnd;  
          pid:   dword;  
          h:   THandle;  
          lpNumberOfBytes:   DWord;  
          buf:DWord;  
          buf2:Pointer;  
          Buffer   :   Array[0..3]   Of   DWord;  
          addr:DWORD;  
          nSize:   DWORD;  
          s:WideString;  
          i:Integer;  
  begin  
      gameHwnd:=FindWindow(nil,'Element   Client');  
      if   gameHwnd<>0   then  
          begin  
              GetWindowThreadProcessId(gameHwnd,   @pid);  
              h:=OpenProcess(PROCESS_ALL_ACCESS,   false,   pid);  
              if   h<>0   then  
                  begin  
                      addr:=$010EA0CC;  
                      edit2.Text:=Inttostr(gameHwnd);  
                      edit3.Text:=Inttostr(h);  
                      nSize:=4;  
                      ReadProcessMemory(h,Pointer(addr+$2A4),@buf,nSize,lpNumberOfBytes);  
                      s:=inttoStr(buf);  
                      edit1.Text:=s;  
                      showmessage(s);  
                  end;  
              closeHandle(h);  
          end   else   begin  
              showmessage('游戏未运行!');  
          end;  
  end;  
 

Return   Values  
   
  If   the   function   succeeds,   the   return   value   is   nonzero.  
  If   the   function   fails,   the   return   value   is   zero.   To   get   extended   error   information,   call   GetLastError.  
  The   function   fails   if   the   requested   read   operation   crosses   into   an   area   of   the   process   that   is   inaccessible.    
   
  看帮助   第一句话   函数成功的时候   这个值是非0    
   
   
   
 

楼上的。不是这个意思.或许是我描述能力太差了。  
   
  不过已经解决了。多谢啊.  
   
  放分。

噢   呵呵   是参数的问题还是?

不是。具体我也不太懂.我是在网上找到的一个函数搞定的,你看看能看懂不?讲一讲.我对内存这些东西是刚接触.很菜.  
  ===========================================  
  addr:=GetAddyfrmpointer($010EA0CC,$2A4,h);  
  ===========================================  
   
  function   GetAddyfrmpointer(baseaddress,   offset:   dword;  
      hID:   THandle):   Dword;  
  var   a:   dword;  
          x:   dword;  
          i:   integer;  
          offsetcount:   integer;  
          offsets:array   of   dword;  
          b:integer;  
          maxid:integer;  
  begin  
      offsetcount:=1;  
      b:=0;  
      setlength(offsets,1);  
      offsets[b]:=offset;  
      a:=baseaddress;  
      i:=0;  
      while   (i<offsetcount)   do  
      begin  
          if   not   readprocessmemory(hID,pointer(a),@a,4,x)   then   exit;  
          inc(a,offsets[i]);  
          inc(i);  
          result:=a  
      end;  
  end;  
 

看来基地址+偏移量直接取的办法是不对.

转载于:https://www.cnblogs.com/delphi2007/archive/2009/02/11/1388401.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值