主单元:

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.

  

相关文章:

  • 2022-12-23
  • 2021-09-18
  • 2022-01-30
  • 2021-04-09
  • 2021-12-21
  • 2022-01-21
  • 2021-05-08
猜你喜欢
  • 2021-07-13
  • 2021-12-13
  • 2021-05-17
  • 2021-08-04
  • 2021-06-14
  • 2021-05-16
  • 2021-08-24
相关资源
相似解决方案