I make my own bot and I have translate some stuff from AutoIT that I found on another forum. In the end of this post I gave the credits for the original coder in AutoIT.
Here is the essence of the code, the definitions and the functions that we need to inject some stuff into elementclient.exe
Code:
//global definitions
type
PPacket = ^TPacket;
TPacket = packed record
Len: cardinal;
Buf: array [0 .. 63] of byte;
end;
var
WH: DWORD;
const
PW_TITLE = 'Element Client';
PW_BASE_ADDRESS = $00B4EF34;
PW_SENDPACKET = $0068D640;
procedure InjectFunc(ProcessID: cardinal; Func: pointer; aParams: pointer;
aParamsSize: DWORD);
var
hThread: THandle;
lpNumberOfBytes: DWORD;
ThreadAddr, ParamAddr: pointer;
begin
if ProcessID <> 0 then
begin
ThreadAddr := VirtualAllocEx(ProcessID, nil, 256, MEM_COMMIT,
PAGE_READWRITE);
WriteProcessMemory(ProcessID, ThreadAddr, Func, 256, lpNumberOfBytes);
ParamAddr := VirtualAllocEx(ProcessID, nil, aParamsSize, MEM_COMMIT,
PAGE_READWRITE);
WriteProcessMemory(ProcessID, ParamAddr, aParams, aParamsSize,
lpNumberOfBytes);
hThread := CreateRemoteThread(ProcessID, nil, 0, ThreadAddr, ParamAddr, 0,
lpNumberOfBytes);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(hThread);
VirtualFreeEx(ProcessID, ParamAddr, 0, MEM_RELEASE);
VirtualFreeEx(ProcessID, ThreadAddr, 0, MEM_RELEASE);
end;
end;
//Procedure what is inject in the elementclient
procedure SendCall(aPacket: PPacket); stdcall;
var
addr: pointer;
size, Buf: DWORD;
begin
addr := pointer(PW_SENDPACKET);
size := PDword(aPacket)^;
Buf := DWORD(aPacket) + 4;
asm
pushad
mov eax, dword ptr [PW_BASE_ADDRESS]
mov ecx, dword ptr [eax + $20]
push size
push buf
call addr
popad
end;
end;
And here are some os packets that you can send to the server to do some stuff like deselect target
Code:
procedure Deselect;
var
lPacket: TPacket;
pckHead: word;
begin
// Packet: 0800
// Length: 2
lPacket.Len := 2;
pckHead := $08;
copymemory(@lPacket.Buf[0], @pckHead, sizeof(pckHead));
lPacket.Buf[1] := $00;
InjectFunc(WH, @SendCall, @lPacket, sizeof(lPacket));
end;
//Select the target from ID
procedure Target(IDTarget: DWORD);
var
lPacket: TPacket;
pckHead: word;
TarHex: LongInt;
begin
{ $packet = '0200'
$packet &= _hex($targetId)
$packetSize = 6 }
lPacket.Len := 6;
pckHead := $02;
copymemory(@lPacket.Buf[0], @pckHead, sizeof(pckHead));
lPacket.Buf[1] := $00;
TarHex := IDTarget;
copymemory(@lPacket.Buf[2], @TarHex, sizeof(cardinal));
InjectFunc(WH, @SendCall, @lPacket, sizeof(lPacket));
end;
Credits
Original coder from AutoIT: Interest07.
Me for translated :P
Sorry about my english =/