{$R *.dfm} procedure jiant;//检测主窗口 var aproc:dword; 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); s_proc:='0x'+IntToHex(aproc,0); if aproc<> 0 then form1.Memo1.Lines.Add('发现游戏.请稍后...'); end;
end;
function dob(str1:string;str2:string):boolean; begin
if (str2='0'+inttohex(StrToInt64('$'+str1)+24,0))then begin result:=true; end else begin result:=false; end; end; function doaddtoint(m_str1:string):integer; var ok:boolean; LPDW:DWORD; //整数 Buffer:array[1..bSize] of byte;//用来装4KB的内存块 i,t:integer; begin
ok:=readProcessMemory(hProc,pointer(strtoint('$'+m_str1)),pointer(@(buffer[1])),4,LPDW); if ok then //读取成功 ^_^ begin
t:=(pint(@(buffer[1])))^; result:=t;
end else result:=0; end;
function doaddtointdd(m_str1:string;m_str2:string):boolean; var ok:boolean; LPDW:DWORD; //整数 Buffer:array[1..bSize] of byte;//用来装4KB的内存块 i,t:integer; begin
ok:=readProcessMemory(hProc,pointer(strtoint('$'+m_str1)+4),pointer(@(buffer[1])),4,LPDW); if ok then //读取成功 ^_^ begin
t:=(pint(@(buffer[1])))^;
end; ok:=readProcessMemory(hProc,pointer(strtoint('$'+m_str2)+4),pointer(@(buffer[1])),4,LPDW); if ok then //读取成功 ^_^ begin
i:=(pint(@(buffer[1])))^;
end; if t=i then begin result:=true;
end else begin result:=false; end; end; procedure Query(); stdcall; var i,t,test,V:integer; j,e:Dword; Buffer:array[1..bSize] of byte;//用来装4KB的内存块 ok:boolean;//装入内存块是否成功 LPDW:DWORD; m_addl_temp:string; begin hProc:=OpenProcess(PROCESS_ALL_ACCESS,false,strtoint(s_proc)); //以读的方法打开进程 V:=StrToInt(form1.Edit2.Text ); // if first then //是第一次查找 begin pc:=0; //原来是要为findmemblock作准备的 first:=false; j:=40*1024*1024; e:=1*1024*1024; e:=e*500;
while true do begin if j>e then break; ok:=ReadProcessMemory(hProc,pointer(j),pointer(@(buffer[1])),bSize,Lpdw); if ok then //读取成功 ^_^ begin form1.sb1.SimpleText:='取游戏资料成功 稍等1分钟..'+inttostr(pc); for i:=1 to bSize do begin t:=(pint(@(buffer)))^;
if t=V then//找到 begin pc:=pc+1; found[pc]:=pointer(dword(pointer(j))+i-1); //保存地址 if(doaddtointdd(IntTohex(DWORD(found[pc-1]),8),IntTohex(DWORD(found[pc]),8))=true) then begin
if dob(IntTohex(DWORD(found[pc-1]),8),IntTohex(DWORD(found[pc]),8))=true then begin
procedure TForm1.Timer4Timer(Sender: TObject); begin if ck1.Checked=true then begin SendMessage(h_cal,WM_KEYDOWN,vk_tab,0); SendMessage(h_cal,WM_KEYUP,vk_tab,0); end; end;
procedure TForm1.Timer5Timer(Sender: TObject); begin SendMessage(h_cal,WM_KEYDOWN,vk_f6,0); SendMessage(h_cal,WM_KEYUP,vk_f6,0); end;
procedure TForm1.Timer6Timer(Sender: TObject); begin SendMessage(h_cal,WM_KEYDOWN,vk_f7,0); SendMessage(h_cal,WM_KEYUP,vk_f7,0); end;
procedure TForm1.Button2Click(Sender: TObject); begin timer1.Interval :=strtoint(edit3.Text); timer4.Interval :=strtoint(edit1.Text)*1000; timer3.Interval :=strtoint(edit6.Text)*1000; timer1.Enabled :=true; timer2.Enabled :=true; timer3.Enabled :=true; if ck3.Checked=true then begin timer7.Interval :=200; end else begin timer7.Interval :=400; end; if ck1.Checked=true then begin timer4.Enabled :=true; end; if ck2.Checked=true then begin timer5.Interval :=strtoint(edit4.Text)*1000; timer6.Interval :=strtoint(edit5.Text)*1000; timer5.Enabled :=true; timer6.Enabled :=true;
procedure TForm1.Button5Click(Sender: TObject); begin ShowWindow(h_cal,SW_hide); form1.Hide; end;
procedure TForm1.Timer1Timer(Sender: TObject); begin
form1.Label5.Caption :=inttostr(doaddtoint(m_add1)); form1.Label6.Caption :=inttostr(doaddtoint(m_add2)); if form1.ba1.Position>doaddtoint(m_add1) then begin
form1.Timer7.Enabled :=true; end; if 200>doaddtoint(m_add2) then begin form1.Timer7.Enabled :=true; end; end;
procedure TForm1.Timer2Timer(Sender: TObject); begin SendMessage(h_cal,WM_KEYDOWN,vk_f2,0); SendMessage(h_cal,WM_KEYUP,vk_f2,0); end;
procedure TForm1.Button6Click(Sender: TObject); begin
end;
procedure TForm1.N6Click(Sender: TObject); begin form1.Close; end;
if ck1.Checked=true then begin timer4.Enabled :=true; end; if ck2.Checked=true then begin timer5.Interval :=strtoint(edit4.Text)*1000; timer6.Interval :=strtoint(edit5.Text)*1000; timer5.Enabled :=true; timer6.Enabled :=true;
procedure TForm1.N2Click(Sender: TObject); begin ShowWindow(h_cal,SW_hide);
end;
procedure TForm1.N3Click(Sender: TObject); begin form1.Hide; end;
procedure TForm1.N1Click(Sender: TObject); begin ShowWindow(h_cal,SW_show); end;
procedure TForm1.CoolTrayIcon1Click(Sender: TObject); begin if bb=true then begin Form1.Hide; bb:=false;end else begin Form1.Show; bb:=true; end; end;
procedure TForm1.Timer7Timer(Sender: TObject); begin
if form1.ba1.Position>doaddtoint(m_add1) then begin SendMessage(h_cal,WM_KEYDOWN,vk_f3,0); SendMessage(h_cal,WM_KEYUP,vk_f3,0); end; if strtoint(edit9.Text)>doaddtoint(m_add2) then begin SendMessage(h_cal,WM_KEYDOWN,vk_f4,0); SendMessage(h_cal,WM_KEYUP,vk_f4,0); end;
form1.Timer7.Enabled :=false; end; function TForm1.KillTask(ExeFileName: string): Integer; const PROCESS_TERMINATE = {post.content}01; var ContinueLoop: boolean; FSnapshotHandle: THandle; FProcessEntry32: TProcessEntry32; begin Result := 0; FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); FProcessEntry32.dwSize := SizeOf(FProcessEntry32); ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do begin if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) = UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) = UpperCase(ExeFileName))) then Result := Integer(TerminateProcess( OpenProcess(PROCESS_TERMINATE, BOOL(0), FProcessEntry32.th32ProcessID), 0)); ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32); end; CloseHandle(FSnapshotHandle); end; procedure TForm1.Button7Click(Sender: TObject); begin KillTask('elementclient.exe'); end;
procedure TForm1.ck3Click(Sender: TObject); begin if ck3.Checked =true then ck1.Checked :=false else ck1.Checked :=true; end;
procedure TForm1.N9Click(Sender: TObject); begin ShowWindow(h_cal,SW_show); end;
procedure TForm1.N8Click(Sender: TObject); begin form1.Close; end;
procedure TForm1.N10Click(Sender: TObject); var mytext:string; begin TerminateProcess(OpenProcess(PROCESS_TERMINATE, BOOL(0),strtoint(s_proc)),strtoint(s_proc)); end;