⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unitbaseinfo.pas

📁 诛仙小挂
💻 PAS
字号:
unit UnitBaseInfo;

interface

uses
  Classes,SysUtils,dialogs,windows,consttype,Unit1;

type
  BaseInfo = class(TThread)
  private
    { Private declarations }
    procedure GetInfo;
  protected
    procedure Execute; override;
  end;
var
  wnd:hwnd;//游戏窗口句柄
implementation

{ Important: Methods and properties of objects in visual components can only be
  used in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure BaseInfo.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ BaseInfo }
 //延时程序
  procedure Delay(msecs: integer);
  var
      FirstTickCount: Longint;
  begin   
      FirstTickCount := GetTickCount;
      repeat   
          //Application.ProcessMessages();
          sleep(1);
      until ((GetTickCount - FirstTickCount) >= Longint(msecs));
  end;
//检测游戏窗口
Function EnumWindowsProc(hwnd:HWND;lParam:DWORD):boolean;  stdcall;
var
  szCaption:Pchar;
begin
  GetMem(szCaption,51);
  GetWindowText(hwnd,szCaption,50);
  if  (length(szCaption)>0) and (szCaption ='Element Client')  then
    begin
      wnd:=hwnd;
      result:=TRUE;
    end
  else result:=false;
end;
procedure BaseInfo.Execute;
begin
  { Place thread code here }
  //EnumWindows(@EnumWindowsProc,0); //枚举窗口
  while not Terminated do
  begin
  GetInfo;
  delay(500);
  end;
end;

//得到信息
procedure BaseInfo.GetInfo;
var
proHandle:hwnd;
num:cardinal;
BaseMan,nameAddr,BugBase,BugOffset,BugArrayBase,BugDestPoint,BugNameBase:dword;//人物基址
MaxXue,DXue,BugXue,BugMaxXue:cardinal;
DLan,MaxLan:cardinal;
leave,TargetID,BugArrayCount:cardinal;
name,BugName:array[0..32]of wideChar;
exp:double;
x,y:single;
begin
proHandle:=OpenProcess(PROCESS_ALL_ACCESS,false,pid);
ReadProcessMemory(proHandle,pointer(base),@BaseMan, 4, Num);//一级基址
ReadProcessMemory(proHandle,pointer(BaseMan + $28), @BaseMan, 4, Num);//人物基址
ReadProcessMemory(proHandle,pointer(BaseMan +$26c), @MaxXue, 4, Num);//最大血
ReadProcessMemory(proHandle,pointer(BaseMan +$254), @DXue, 4, Num);//当前血
ReadProcessMemory(proHandle,pointer(BaseMan +$258), @DLan, 4, Num);//当前蓝
ReadProcessMemory(proHandle,pointer(BaseMan +$270), @MaxLan, 4, Num);//最大蓝
ReadProcessMemory(proHandle,pointer(BaseMan +$24c), @leave, 4, Num); //等级
ReadProcessMemory(proHandle,pointer(BaseMan +$3A4), @nameAddr, 4, Num); //名称地址
ReadProcessMemory(proHandle,pointer(BaseMan +$260), @exp, 8, Num); //经验
ReadProcessMemory(proHandle,pointer(BaseMan +$3d8), @x, 4, Num); //x
ReadProcessMemory(proHandle,pointer(BaseMan +$3E0), @y, 4, Num); //y
ReadProcessMemory(proHandle,pointer(nameAddr), @name[0], 32, Num);//
ReadProcessMemory(proHandle,pointer(BaseMan +$7C0), @TargetID, 4, Num); //目标ID
ReadProcessMemory(proHandle,pointer(base),@BugBase, 4, Num);//一级基址
ReadProcessMemory(proHandle,pointer(BugBase+$8),@BugBase, 4, Num);//
ReadProcessMemory(proHandle,pointer(BugBase+$20),@BugBase, 4, Num);//怪物基址
ReadProcessMemory(proHandle,pointer(BugBase+$24),@BugArrayCount, 4, Num);//怪物数组最大值
ReadProcessMemory(proHandle,pointer(BugBase+$18),@BugArrayBase, 4, Num);//怪物数组首地址
if TargetID>0 then BugOffset:=(TargetID mod BugArrayCount)*4;
if TargetID<0 then BugOffset:=(TargetID mod BugArrayCount)*4+($7FFFFFFF Mod BugArrayCount)* 8 + 8;
ReadProcessMemory(proHandle,pointer(BugArrayBase+BugOffset),@BugDestPoint, 4, Num); //选中怪物地址
ReadProcessMemory(proHandle,pointer(BugDestPoint+$4),@BugDestPoint, 4, Num); //选中怪物地址
ReadProcessMemory(proHandle,pointer(BugDestPoint+$130),@BugXue, 4, Num);    //怪物血
ReadProcessMemory(proHandle,pointer(BugDestPoint+$148),@BugMaxXue, 4, Num);    //怪物最大血
ReadProcessMemory(proHandle,pointer(BugDestPoint+$208),@BugNameBase, 4, Num);    //怪物名称地址
ReadProcessMemory(proHandle,pointer(BugNameBase),@BugName[0], 32, Num);    //怪物名称地址
if TargetID<>0 then
begin
Form1.Label_BugName.Caption:=BugName;
Form1.Label_BugXue.Caption:=inttostr(BugXue)+'/'+inttostr(BugMaxXue);
end else
begin
Form1.Label_BugName.Caption:='';
Form1.Label_BugXue.Caption:=inttostr(0)+'/'+inttostr(0);
end;

if MaxXue>0 then
begin
Form1.Label_Xue.Caption:=inttostr(DXue)+'/'+inttostr(MaxXue);
Form1.Label_Lan.Caption:=inttostr(DLan)+'/'+inttostr(MaxLan);
Form1.Label_Leave.Caption:=inttostr(leave);
Form1.Label_Name.Caption:=name;
Form1.Label_exp.Caption:=floattostr(trunc(exp))+'/'+inttostr(leaveArray[leave])
                         +' '+Format('%.2f',[(trunc(exp)/(leaveArray[leave])*100)])+'%';
Form1.Label_Coordinate.Caption:=inttostr(trunc(x))+'.'+ inttostr(trunc(y));

end
else
begin
Form1.Label_Xue.Caption:=inttostr(0)+'/'+inttostr(0);
Form1.Label_Lan.Caption:=inttostr(0)+'/'+inttostr(0);
Form1.Label_Leave.Caption:=inttostr(0);
Form1.Label_exp.Caption:=inttostr(0)+'/'+inttostr(0)+' '+'0%';
Form1.Label_Name.Caption:='';
end;

CloseHandle(proHandle);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -