想用.NET编写一个游戏修改器,调用API的时候我的字节数组总是读取不到数据,不知道什么原因,简略源码如下:
[DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
 private static extern int ReadProcessMemory(int hProcess,int lpBaseAddress,byte [] lpBuffer,int nSize,ref int lpNumberOfBytesWritten);
int testread;
testread = 4;
byte [] mybtye = new byte[4];
ReadProcessMemory(1592,0x00373F9B4, mybtye,4,ref testread);
进程ID已经通过进程读取找到了,那个地址是通过金山游侠搜索到的,肯定里面有数据,为什么我读取出来的字节数组都是0呀,还望知道的大哥赐教一二,小弟谢过啦,不知道帮忙顶噢

解决方案 »

  1.   

    你读错了拉,你应该把mybtye[0]给读出来,还有就是你没指定一个进程前也为空,但是你能不能和我一起想一下为什么读到的值和原来的值都差了256,我实在有点搞不懂了!
      

  2.   

    Have a try![DllImport("kernel32.dll", CharSet=System.Runtime.InteropServices.CharSet.Auto)]
    private static extern int ReadProcessMemory(int hProcess,int lpBaseAddress,
          [MarshalAs( UnmanagedType.LPArray )] byte [] lpBuffer,int nSize,ref int lpNumberOfBytesWritten);
      

  3.   

    底楼的Knight94你怎么老是把托管的代码写出来啊!现在的这个问题我已经解决了哈哈!