Code:
#RequireAdmin
#Region
#AutoIt3Wrapper_Icon=1.ico
#AutoIt3Wrapper_OutFile=autolooter.exe
#AutoIt3Wrapper_UseUpx=n
#EndRegion
Global Const $gui_event_close = -3
Global Const $ws_minimizebox = 131072
Global Const $ws_sysmenu = 524288
Global Const $ws_caption = 12582912
Global Const $ws_popup = -2147483648
Global Const $gui_ss_default_gui = BitOR($ws_minimizebox, $ws_caption, $ws_popup, $ws_sysmenu)
Func _memoryopen($iv_pid, $iv_desiredaccess = 2035711, $iv_inherithandle = 1)
If NOT ProcessExists($iv_pid) Then
SetError(1)
Return 0
EndIf
Local $ah_handle[2] = [DllOpen("kernel32.dll")]
If @error Then
SetError(2)
Return 0
EndIf
Local $av_openprocess = DllCall($ah_handle[0], "int", "OpenProcess", "int", $iv_desiredaccess, "int", $iv_inherithandle, "int", $iv_pid)
If @error Then
DllClose($ah_handle[0])
SetError(3)
Return 0
EndIf
$ah_handle[1] = $av_openprocess[0]
Return $ah_handle
EndFunc
Func _memoryread($iv_address, $ah_handle, $sv_type = "dword")
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
Local $v_buffer = DllStructCreate($sv_type)
If @error Then
SetError(@error + 1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "ReadProcessMemory", "int", $ah_handle[1], "int", $iv_address, "ptr", DllStructGetPtr($v_buffer), "int", DllStructGetSize($v_buffer), "int", "")
If NOT @error Then
Local $v_value = DllStructGetData($v_buffer, 1)
Return $v_value
Else
SetError(6)
Return 0
EndIf
EndFunc
Func _memoryclose($ah_handle)
If NOT IsArray($ah_handle) Then
SetError(1)
Return 0
EndIf
DllCall($ah_handle[0], "int", "CloseHandle", "int", $ah_handle[1])
If NOT @error Then
DllClose($ah_handle[0])
Return 1
Else
DllClose($ah_handle[0])
SetError(2)
Return 0
EndIf
EndFunc
Func setprivilege($privilege, $benable)
Const $token_adjust_privileges = 32
Const $token_query = 8
Const $se_privilege_enabled = 2
Local $htoken, $sp_auxret, $sp_ret, $hcurrprocess, $ntokens, $ntokenindex, $priv
$ntokens = 1
$luid = DllStructCreate("dword;int")
If IsArray($privilege) Then $ntokens = UBound($privilege)
$token_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
$newtoken_privileges = DllStructCreate("dword;dword[" & (3 * $ntokens) & "]")
$hcurrprocess = DllCall("kernel32.dll", "hwnd", "GetCurrentProcess")
$sp_auxret = DllCall("advapi32.dll", "int", "OpenProcessToken", "hwnd", $hcurrprocess[0], "int", BitOR($token_adjust_privileges, $token_query), "int*", 0)
If $sp_auxret[0] Then
$htoken = $sp_auxret[3]
DllStructSetData($token_privileges, 1, 1)
$ntokenindex = 1
While $ntokenindex <= $ntokens
If IsArray($privilege) Then
$priv = $privilege[$ntokenindex - 1]
Else
$priv = $privilege
EndIf
$ret = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", "", "str", $priv, "ptr", DllStructGetPtr($luid))
If $ret[0] Then
If $benable Then
DllStructSetData($token_privileges, 2, $se_privilege_enabled, (3 * $ntokenindex))
Else
DllStructSetData($token_privileges, 2, 0, (3 * $ntokenindex))
EndIf
DllStructSetData($token_privileges, 2, DllStructGetData($luid, 1), (3 * ($ntokenindex - 1)) + 1)
DllStructSetData($token_privileges, 2, DllStructGetData($luid, 2), (3 * ($ntokenindex - 1)) + 2)
DllStructSetData($luid, 1, 0)
DllStructSetData($luid, 2, 0)
EndIf
$ntokenindex += 1
WEnd
$ret = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "hwnd", $htoken, "int", 0, "ptr", DllStructGetPtr($token_privileges), "int", DllStructGetSize($newtoken_privileges), "ptr", DllStructGetPtr($newtoken_privileges), "int*", 0)
$f = DllCall("kernel32.dll", "int", "GetLastError")
EndIf
$newtoken_privileges = 0
$token_privileges = 0
$luid = 0
If $sp_auxret[0] = 0 Then Return 0
$sp_auxret = DllCall("kernel32.dll", "int", "CloseHandle", "hwnd", $htoken)
If NOT $ret[0] AND NOT $sp_auxret[0] Then Return 0
Return $ret[0]
EndFunc
$autolooter = GUICreate("Autolooter", 200, 80, 254, 266, $gui_ss_default_gui)
$btn = GUICtrlCreateButton("Turn Off", 40, 8, 113, 33)
$l1 = GUICtrlCreateLabel("0", 20, 45)
$l2 = GUICtrlCreateLabel("0", 50, 45)
$state = GUICtrlCreateLabel("Waiting Process", 100, 45)
$clicker_enabled_l = GUICtrlCreateLabel("Clicker Enabled", 20, 65)
$clicker_key_l = GUICtrlCreateLabel("Key: ", 100, 65)
GUISetState(@SW_SHOW)
setprivilege("SeDebugPrivilege", 1)
$k = IniRead("autolooter.ini", "main", "key", "f")
$clicker_enabled = IniRead("autolooter.ini", "main", "clicker_enabled", "1")
If $clicker_enabled <> 1 Then GUICtrlSetData($clicker_enabled_l, "Clicker Disabled")
$clicker_key = IniRead("autolooter.ini", "main", "clicker_key", "{NUMPAD0}")
GUICtrlSetData($clicker_key_l, "Key: " & $clicker_key)
$pid = 0
While $pid = 0
$nmsg = GUIGetMsg()
Switch $nmsg
Case $gui_event_close
Exit
EndSwitch
$pid = ProcessExists("Gw2.exe")
WEnd
Func _memoryscan($ah_handle, $pattern, $after = False, $iv_addrstart = 4194304, $iv_addrend = 16777215, $step = 51200)
If NOT IsArray($ah_handle) Then
SetError(1)
Return -1
EndIf
$pattern = StringRegExpReplace($pattern, "[^0123456789ABCDEFabcdef.]", "")
If StringLen($pattern) = 0 Then
SetError(2)
Return -2
EndIf
For $addr = $iv_addrstart To $iv_addrend Step $step-(StringLen($pattern) / 2)
StringRegExp(_memoryread($addr, $ah_handle, "byte[" & $step & "]"), $pattern, 1, 2)
If NOT @error Then
If $after Then
Return StringFormat("0x%.8X", $addr + ((@extended - 2) / 2))
Else
Return StringFormat("0x%.8X", $addr + ((@extended - StringLen($pattern) - 2) / 2))
EndIf
EndIf
Next
Return -3
EndFunc
GUICtrlSetData($state, "Process Found")
$open = _memoryopen($pid)
$enabled = True
$ffa = _memoryread(2 + _memoryscan($open, "C7 05 .. .. .. .. 01 00 00 00 C3 A1"), $open, "dword")
$t1 = 11 + _memoryscan($open, "85 C0 74 05 E8 .. .. .. .. 57 E8 .. .. .. .. 8B 10")
$t2 = _memoryread($t1, $open, "dword")
$t1 = $t1 + 4
$t1 = $t1 + $t2
$ttt = _memoryread(1 + $t1, $open, "dword")
$ttt = $ttt + 103
$finaladdr = $ttt
HotKeySet("{f9}", "flip")
Func flip()
$enabled = NOT $enabled
If $enabled Then
GUICtrlSetData($btn, "Turn Off")
Else
GUICtrlSetData($btn, "Turn On")
EndIf
EndFunc
HotKeySet($clicker_key, "mc")
Func mc()
If $clicker_enabled = 1 Then MouseClick("left")
EndFunc
While 1
If $enabled Then
$r=WinActive("[CLASS:ArenaNet_Dx_Window_Class]")
if not $r then GUICtrlSetBkColor($state, 0xFF0000)
If $r Then
GUICtrlSetBkColor($state, 0x00FF00)
$r = _memoryread($finaladdr, $open)
GUICtrlSetData($l1, $r)
If $r = 64 Then
$r = _memoryread($ffa, $open)
GUICtrlSetData($l2, $r)
If $r = 0 Then
Send($k)
Sleep(50)
EndIf
EndIf
EndIf
EndIf
$nmsg = GUIGetMsg()
Switch $nmsg
Case $gui_event_close
ExitLoop
Case $btn
flip()
EndSwitch
$pid = ProcessExists("Gw2.exe")
If $pid = 0 Then ExitLoop
WEnd
_memoryclose($open)