T
talent002
Unregistered / Unconfirmed
GUEST, unregistred user!
我想做一个仙剑2的游戏修改器,该游戏的进程名是pal2.tmp0,进程ID都已经找到了,可为什么就是不能显示出体力的值呢?<br>源程序如下,无法正确地显示出内存的数值呢?<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs,tlhelp32, StdCtrls;<br><br>type<br> TForm1 = class(TForm)<br> Button1: TButton;<br> Edit1: TEdit;<br> procedure Button1Click(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br><br><br>var<br> Form1: TForm1;<br> theprohandle:Thandle;<br> c1:integer;<br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> cLoop:boolean;<br> FSnapshotHandle:THandle;<br> FProcessEntry32:TProcessEntry32;<br> addre:integer;<br> re:cardinal;<br>begin<br>addre:=$72c2e4;//游戏里存放体力值的内存地址,用金山游侠查出来的.<br> FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);<br> FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);<br> cLoop:=Process32First(FSnapshotHandle,FProcessEntry32);<br> while integer(cLoop)<>0 do<br> begin<br> if FProcessEntry32.szExeFile='PAL2.TMP0' then<br> begin<br> theprohandle:=OpenProcess(PROCESS_ALL_ACCESS or PROCESS_TERMINATE or PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE,false,FProcessEntry32.th32processid); //打开进程并得到读与权限<br> end;<br> cLoop:=Process32Next(FSnapshotHandle,FProcessEntry32);<br> end;<br>if theprohandle=0 then<br>showmessage('游戏没运行')<br>else<br> begin<br> readprocessmemory(theprohandle,@addre,@c1,4,re);<br> showmessage('体力:'+inttostr(c1));//这里总是显示1<br> end;<br><br>end;<br><br><br>end.