well those are just the very basics.
the more interesting stuff would be how to use autoit to do higher level stuff =)
for example gettin the list of all mobs close to you and save them with some info in an array:
Code:
Func GetMobList($pid)
Local $array[769][3], $mid, $base, $pointer1, $pointer2, $pointer3, $pointer4, $mob_base, $mob_id, $mob_name, $mob_lvl
$mid = memopen($pid)
$base = memread($mid, 0x9F450C)
$pointer1 = memread($mid, $base + 0x8)
$pointer2 = memread($mid, $pointer1 + 0x24)
$pointer3 = memread($mid, $pointer2 + 0x18)
For $i=0 To 768
$pointer4 = memread($mid, $pointer3 + $i*0x4)
$mob_base = memread($mid, $pointer4 + 0x4)
$array[$i][0] = memread($mid, $mob_base + 0x11C) ;Mob ID
$array[$i][1] = memread($mid, memread($mid, $mob_base + 0x254), 'wchar[30]') ;Mob Name
$array[$i][2] = memread($mid, $mob_base + 0x124) ; Mob Level
Next
memclose($mid)
Return $array
EndFunc
Func memopen($pid)
Local $mid = DllCall('kernel32.dll', 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', 1, 'int', $pid)
Return $mid[0]
EndFunc ;==>memopen
Func memread($mid, $adress, $type = 'dword')
Local $struct = DllStructCreate($type)
DllCall('kernel32.dll', 'int', 'ReadProcessMemory', 'int', $mid, 'int', $adress, 'ptr', DllStructGetPtr($struct), 'int', DllStructGetSize($struct), 'int', '')
Return DllStructGetData($struct, 1)
EndFunc ;==>memread
Func memclose($mid)
DllCall('kernel32.dll', 'int', 'CloseHandle', 'int', $mid)
EndFunc ;==>memclose
and a function to select the mobs we've just collected, using the id:
Code:
Func Int2Hex($Value)
Local $tmp1, $tmp2, $i
$tmp1 = StringRight("0000000" & Hex($Value), 8)
For $i = 0 To StringLen($tmp1) / 2 - 1
$tmp2 = $tmp2 & StringMid($tmp1, StringLen($tmp1) - 1 - 2 * $i, 2)
Next
Return $tmp2
EndFunc
Func SelectMob($pid, $mob_id)
Local $kernel32, $pRemoteThread, $vBuffer, $loop, $result, $OPcode
$kernel32 = DllOpen("kernel32.dll")
; --- open the process ---
$mid = DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', 0x1F0FFF, 'int', 1, 'int', $pid)
; --- save the position of the allocated memory ---
$pRemoteMem = DllCall($kernel32, "ptr", "VirtualAllocEx", "int", $mid[0], "ptr", 0, "int", 0x46, "int", 0x1000, "int", 0x40)
$pRemoteMem = $pRemoteMem[0]
; --- build up the asm code ---
$OPcode = "608B156C3E9F0068"&Int2Hex($mob_id)&"8B4A2081C1EC000000BAC09C5E00FFD261C3"
; --- 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[0], "ptr", $pRemoteMem, "ptr", DllStructGetPtr($vBuffer), "int", DllStructGetSize($vBuffer), "int", 0)
; --- now we run the asm code we've just written ---
$hRemoteThread = DllCall($kernel32, "int", "CreateRemoteThread", "int", $mid[0], "ptr", 0, "int", 0, "int", $pRemoteMem, "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[0], "ptr", $pRemoteMem, "int", 0, "int", 0x8000)
DllCall("kernel32.dll", 'int', 'CloseHandle', 'int', $mid[0])
DllClose($kernel32)
Return True
EndFunc
Well those Functions are made to work for PWI they had to be edited to work for other clients too =) (could easily be automated, using the stringregexp functions)
same could be done with items on the ground, to pick them up.
guess explaining of the codecave i've used for selecting mobs is not needed. there's allready a stickied thread about it.