问题描述
[DllImport("kernel32.dll")]publicstaticexternvoidCloseHandle(IntPtrhObject);[DllImport("kernel32.dll")]publicstaticexternIntPtrOpenProcess(intdwDesiredAccess,boolbInheritHandle,intdwProcessId);[DllImport("kernel32.dll")]publicstaticexternboolReadProcessMemory(IntPtrhProcess,IntPtrlpBaseAddress,IntPtrlpBuffer,intnSize,IntPtrlpNumberOfBytesRead);privateintbaseaddress=0;privatevoidForm1_Load(objectsender,EventArgse){}///<summary>///获取进程id///</summary>///<paramname="proName"></param>///<returns></returns>privateintGetProcessID(stringproName){Process[]processArray2=Process.GetProcessesByName(proName);intindex=0;while(index<processArray2.Length){Processprocess=processArray2[index];returnprocess.Id;}return0;}privatevoidbutton1_Click(objectsender,EventArgse){inthp=ReadMemoryValue("DNF",0);textBox1.Text=hp.ToString();}publicintReadMemoryValue(stringprocessName,intbaseAdd){byte[]arr=newbyte[40];IntPtrlpBuffer=Marshal.UnsafeAddrOfPinnedArrayElement(arr,0);IntPtrhProcess=Function.OpenProcess(0x1f0fff,false,this.GetProcessID(processName));Function.ReadProcessMemory(hProcess,(IntPtr)baseAdd,lpBuffer,4,IntPtr.Zero);CloseHandle(hProcess);returnMarshal.ReadInt32(lpBuffer);}我得到的值都是0
解决方案
解决方案二:
用GetLastError去查问题
解决方案三:
先研究一下如何过tp腾讯的游戏不是这么容易读得到内存的。
解决方案四:
可能有保护,或者.OpenProcess(0x1f0fff,这个权限达不到,有现成的cheat工具,干嘛要自己写