that one was outdated.
i've rewritten the function, to use the original client function.
i've rewritten the function, to use the original client function.
Code:
Func SelectMob($id)
Local $pRemoteThread, $vBuffer, $loop, $result, $OPcode
; --- save the position of the allocated memory ---
$pRemoteMem = DllCall($kernel32, 'int', 'VirtualAllocEx', 'int', $mid, 'ptr', 0, 'int', 0x46, 'int', 0x1000, 'int', 0x40)
; --- build up the asm code ---
; 0046061D A1 6C3E9F00 MOV EAX,DWORD PTR DS:[9F3E6C]
; 00460622 57 PUSH EDI <---- EDI Contains Mob-ID
; 00460623 8B48 20 MOV ECX,DWORD PTR DS:[EAX+20]
; 00460626 81C1 EC000000 ADD ECX,0EC
; 0046062C E8 8F961800 CALL elementc.005E9CC0
$OPcode &= '60' ; pushad (Save registers)
$OPcode &= 'A1'&_hex($base) ; mov eax, [base]
$OPcode &= '68'&_hex($id) ; push mob-id
$OPcode &= '8B4820' ; mov ecx, [eax+0x20]
$OPcode &= '81C1'&_hex(0xEC) ; add ecx, 0xEC
$OPcode &= 'E8'&_hex($select_call-$pRemoteMem[0]-5-StringLen($OPcode)/2) ; call select_call
$OPcode &= '61' ; popad (Reload presaved registers)
$OPcode &= 'C3' ; retn (Back to the Maintool)
; --- enter the asm code to to a dllstruct, which can be used with WriteProcessMemory ---
$vBuffer = DllStructCreate('byte[' & StringLen($OPcode) / 2 & ']')
For $loop = 1 To DllStructGetSize($vBuffer)
DllStructSetData($vBuffer, 1, Dec(StringMid($OPcode, ($loop - 1) * 2 + 1, 2)), $loop)
Next
; --- now letz write the code from our dllstruct ---
DllCall($kernel32, 'int', 'WriteProcessMemory', 'int', $mid, 'int', $pRemoteMem[0], 'int', DllStructGetPtr($vBuffer), 'int', DllStructGetSize($vBuffer), 'int', 0)
; --- now we run the asm code we've just written ---
$hRemoteThread = DllCall($kernel32, 'int', 'CreateRemoteThread', 'int', $mid, 'int', 0, 'int', 0, 'int', $pRemoteMem[0], 'ptr', 0, 'int', 0, 'int', 0)
; --- wait till the thread did his job ---
Do
$result = DllCall('kernel32.dll', 'int', 'WaitForSingleObject', 'int', $hRemoteThread[0], 'int', 50)
Until $result[0] <> 258
; --- close everything we've opened ---
DllCall($kernel32, 'int', 'CloseHandle', 'int', $hRemoteThread[0])
DllCall($kernel32, 'ptr', 'VirtualFreeEx', 'hwnd', $mid, 'int', $pRemoteMem[0], 'int', 0, 'int', 0x8000)
Return True
EndFunc