主单元:
unit mainform;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,GameFunction;
type
TForm1 = class(TForm)
edtCurBlood: TEdit;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
self.edtCurBlood.Text:=intTostr(GetCurBlood);
end;
end.
函数单元:
unit GameFunction;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
function GetRoleBase:integer; //其它要调用的函数 要前置
Function GetCurBlood:integer;
var
Gameh:hwnd; //游戏窗口句柄
GamePid:Thandle; //进程ID
GamehProcess:Thandle; //进程句柄
const
GameCaption='Element Client';
GameWndClassName='QElementClient Window';
GameBase =$95E800;
implementation
function GetRoleBase:integer;
var
ptmp:integer;
readByte:Dword;
begin
result:=0;
Gameh:=FindWindow(nil,GameCaption);
if Gameh=0 then exit;
GetWindowThreadProcessID(Gameh,GamePid);
GamehProcess:=OpenProcess(windows.PROCESS_ALL_ACCESS,false,GamePid);
// [[[[[95E800+1c]+24]+918]+14]+1c ] //角色对象基址
ReadProcessMemory(GamehProcess,Pointer(GameBase+$1C),@ptmp,4,readByte);
ReadProcessMemory(GamehProcess,Pointer(Ptmp+$24),@ptmp,4,readByte);
ReadProcessMemory(GamehProcess,Pointer(Ptmp+$918),@ptmp,4,readByte);
ReadProcessMemory(GamehProcess,Pointer(Ptmp+$14),@ptmp,4,readByte);
ReadProcessMemory(GamehProcess,Pointer(Ptmp+$1C),@ptmp,4,readByte);
result:=ptmp;
end;
Function GetCurBlood:integer;
var
base,ptmp:integer;
readByte:Dword;
begin
Result:=0;
base:=GetRoleBase;
Gameh:=FindWindow(nil,GameCaption);
if Gameh=0 then exit;
GetWindowThreadProcessID(Gameh,GamePid);
GamehProcess:=OpenProcess(windows.PROCESS_ALL_ACCESS,false,GamePid);
ReadProcessMemory(GamehProcess,Pointer(base+$25c),@ptmp,4,readByte);
Result:=ptmp;
end;
end.
浙公网安备 33010602011771号