unit Unit1;
interface
private
{ Private declarations }
public
{ Public declarations }
function KillTask(ExeFileName: string): Integer;
end;
const
bsize=1024;
var
Form1: TForm1;
h_cal:hwnd;//窗口
hProc,xiel,xiel_tow:dword;//进程id
s_proc:string;//进程id
hProcess: Cardinal;
query_thread_handle1: THandle;
ac:Cardinal;
ai_ga,ai_gb,id,y_id,baoh,baoha,baohb,timer_one:integer;
bb:boolean;
implementation
{$R *.dfm}
procedure Query(); stdcall;
begin
form1.timer1.Enabled:=true;
form1.timer3.Enabled:=true;
form1.timer7.Enabled:=true;
form1.timer8.Enabled:=true;
form1.timer6.Enabled:=true;
SendMessage(h_cal,WM_KEYDOWN,vk_tab,0);
SendMessage(h_cal,WM_KEYUP,vk_tab,0);
form1.sb1.Panels[0].Text:=''发现怪物开始攻击'';
if form1.ck3.Checked=true then
begin
form1.timer6.Enabled:=false;
end;
if form1.ck4.Checked=true then
begin
form1.timer4.Interval :=strtoint(form1.edit4.Text)*1000;
form1.timer5.Interval :=strtoint(form1.edit5.Text)*1000;
form1.timer4.Enabled :=true;
form1.timer5.Enabled :=true;
end;
if form1.ck1.Checked=true then
begin
form1.timer6.Interval :=strtoint(form1.edit10.Text)*1000;
form1.timer6.Enabled :=true;
end;
end;
procedure jiant;//检测主窗口
var
aproc:dword;
Num: cardinal;
PHND: THandle;
ft: Integer;
hp:array[0..30] of WideChar;
begin
aproc:=0;
h_cal:=FindWindow(0,pchar(''Element Client''));
if h_cal=0 then
begin
form1.Memo1.Lines.Add(''没发现游戏窗口!'');
end else
begin
GetWindowThreadProcessId(h_cal,aproc);
PHND := OpenProcess(PROCESS_VM_READ, False,aproc);
if PHND <> 0 then
begin
if ReadProcessMemory(PHND, Pointer(xiel_tow), @ft, 4, Num)then
if ReadProcessMemory(PHND, Pointer(ft), @hp,16, Num)then
form1.Label18.Caption :=format(''[ %s ]'',[hp]);
end;
s_proc:=''0x''+IntToHex(aproc,0);
if aproc<> 0 then
form1.Memo1.Lines.Add(''发现游戏.请稍后'');
end;
end;
function GetDataFromRam(DSAddres: Cardinal; var RamDataBack: Cardinal): Boolean;
var
DataBuffer: Cardinal;
bReadSucceed: LongBool;
lpNumberOfBytesRead: Cardinal;
begin
//if hProc = 0 then Exit;
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False,strtoint(s_proc));
bReadSucceed := ReadProcessMemory(hProcess, Pointer(DSAddres), @DataBuffer, SizeOf(DataBuffer), lpNumberOfBytesRead);
if bReadSucceed then
begin
RamDataBack := DataBuffer;
Result := True;
end else
begin
RamDataBack := $FFFFFFFF;
Result := False;
end;
CloseHandle(hProcess);
end;
function doaddtoint(adrac:Cardinal):integer;
var
ok:boolean;
LPDW:DWORD; //整数
Buffer:array[1..bSize] of byte;//用来装4KB的内存块
i,t:integer;
begin
hProcess := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False,strtoint(s_proc));
ok:=readProcessMemory(hProcess,pointer(adrac),pointer(@(buffer)),4,LPDW);
if ok then //读取成功 ^_^
begin
t:=(pint(@(buffer)))^;
result:=t;
end else
result:=0;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
jiant;
timer6.Interval :=180*1000;
if GetDataFromRam(xiel,ac)=true then
begin
if doaddtoint(ac+$254) <> 0 then
begin
form1.Label9.Font.Color:=clred;
form1.Label10.Font.Color:=clred;
f