The Code-Bin
Links
Home
Add your code!
All Listings
About
Latest Entry
Featured Scripts
Author's Website
Latest Entries
FFMPEG Thumbnail Scr...
PHP, 0.8KB
Jul. 29, 10:24pm
John
Z80 Assembler, 190 bytes
Feb. 17, 3:36am
John
Z80 Assembler, 176 bytes
Sep. 13, 2:19am
John
Z80 Assembler, 77 bytes
Sep. 13, 2:18am
John
Z80 Assembler, 209 bytes
Sep. 13, 2:17am
Anarchy Online Teleporter
Posted by: Tagyourit50 | August 30, 2010 @ 2:21am
AutoIT Code
[
Download
]
;;Simplest way to make hotkeys can be done other ways, Basically hit the button and it calls the function HotKeySet("{Numpad6}", "Right") HotKeySet("{Numpad4}", "Left") HotKeySet("{Numpad8}", "Forward") HotKeySet("{Numpad2}", "Backward") HotKeySet("{Numpad3}", "Down") HotKeySet("{Numpad9}", "Up") ;;I think we all know what this is $PI = 3.14159265358979 ;;Name of character logged into the client you wish to attach to $Character_Name = "Tagy" ;;Value for how much to modify each axis $Magnitude = 1 ;;Offsets for coord pointers Global $N3_Coord_Offsets[3], $Client_Handles, $Z_PTR, $Y_PTR, $X_PTR, $VectorX_PTR ,$VectorY_PTR $N3_DLL_Base_Offset = 0x63620 $N3_Coord_Offsets[0] = 0x84 $N3_Coord_Offsets[1] = 0x50 $N3_Coord_Offsets[2] = 0x60 ;;call load pointers once at the start which will then update every 2 seconds Load_Pointers() ;;Start a timer till refresh $Refresh_Pointers = TimerInit() While 1 If Timerdiff($Refresh_Pointers) > 2000 Then ;;Recalculate offsets every 2 seconds Load_Pointers() $Refresh_Pointers = TimerInit() Endif ;;Delay to not waste cpu Sleep(250) WEnd ;;Calculate my angle from both Vectors Func Get_Angle() Return Atan2(_MemoryRead($VectorY_PTR, $Client_Handles[0], "Float"),_MemoryRead($VectorX_PTR, $Client_Handles[0], "Float"))* 180 / $pi Endfunc ;;Calculate the Vector for the angle specified Func Angle_To_Vector($Angle) Local $New_Vector[2] $Heading = $Pi * $Angle / 180 $New_Vector[0] = $Magnitude * sin($Heading) $New_Vector[1] = $Magnitude * cos($Heading) Return $New_Vector Endfunc ;;Atan2 a math function required for calcs Func ATan2($x, $y) If $y < 0 Then Return -ATan2($x, -$y) ElseIf $x < 0 Then Return $Pi - ATan(-$y / $x) ElseIf $x > 0 Then Return ATan($y / $x) ElseIf $y <> 0 Then Return $Pi / 2 Else SetError( 1 ) EndIf EndFunc ;;Load/update pointer data Func Load_Pointers() ;;Gets all 3 handles to the client based off of toon name $Client_Handles = Get_AO_Client($Character_Name) If $Client_Handles = 0 then Return ;;Calls Create_Pointer_Path and returns the Z axis address $Coord_PTR = Create_Pointer_Path("n3.dll", $N3_DLL_Base_Offset, $N3_Coord_Offsets) ;;Declaring the addresses needed based off the Z axis $Z_PTR = $Coord_PTR $Y_PTR = $Coord_PTR + 0x4 $X_PTR = $Coord_PTR - 0x4 $VectorX_PTR = $Coord_PTR + 0x68 $VectorY_PTR = $Coord_PTR + 0x70 Endfunc ;;gets the final address in a pointer from a array of offsets Func Create_Pointer_Path($DLL_Name, $Dll_Offset,$Offset_Array) ;;Get the base address of n3.dll $Address = _MemoryModuleGetBaseAddress($Client_Handles[2], $DLL_Name)+$DLL_Offset ;;Levels up the pointer For $I = 0 to UBound($Offset_Array)-1 $Address = _MemoryRead($Address, $Client_Handles[0])+$Offset_Array[$I] Next ;;Returns the Z axis address Return "0x" & Hex($Address) Endfunc ;It's not required to attach to a client by name it's just a function i like basically give it a toon name and it will attach to it Func Get_AO_Client($Name) Local $Client_Handles[3] ;;makes an array of all processes named Client.exe $LIST = ProcessList("Client.exe") ;;makes an array of all Windows named Anarchy Online $WLIST = WinList("Anarchy Online") ;;it's messy looking but in this for loop it matches a bunch of data For $C = 1 to $LIST[0][0] ;;Opens a temporary memory handle to the client to read it's name $Temp_Handle = _Memoryopen($LIST[$C][1]) ;;Gets the static address of the name Global $Name_Addr = _MemoryModuleGetBaseAddress($LIST[$C][1], "Interfaces.dll")+0x2F844 ;;Reads the name $Name_Check = _MemoryRead($Name_Addr, $Temp_Handle, "Char[14]") ;;Checks the character name of the current client against the one in the parameters If $Name_Check = $Name then ;;Was true so opens the memory handle $Client_Handles[0] = _Memoryopen($LIST[$C][1]) ;;Process Handle $Client_Handles[2] = $LIST[$C][1] For $i = 1 To $WList[0][0] ;;Makes a for loop then compares the process handle to the window handle until true If WinGetProcess($WList[$i][1]) = $LIST[$C][1] Then ;;Got the correct handle end the loop $Client_Handles[1] = $WList[$i][1] ExitLoop EndIf Next Endif ;;close the temporary handle _MemoryClose($Temp_Handle) Next ;;Returns OpenMemory handle/Window handle/Process handle Return $Client_Handles Endfunc ;;Calculates the 2 vectors for the direction desired then updates the axis in the memory Func Forward() $Vector = Angle_To_Vector(Get_Angle()) _MEMORYWRITE($X_PTR, $Client_Handles[0],_MEMORYREAD($X_PTR, $Client_Handles[0], "Float")+$Vector[0], "Float") _MEMORYWRITE($Y_PTR, $Client_Handles[0],_MEMORYREAD($Y_PTR, $Client_Handles[0], "Float")+$Vector[1], "Float") EndFunc ;;Calculates the 2 vectors for the direction desired then updates the axis in the memory Func Backward() $Vector = Angle_To_Vector(Get_Angle()+180) _MEMORYWRITE($X_PTR, $Client_Handles[0],_MEMORYREAD($X_PTR, $Client_Handles[0], "Float")+$Vector[0], "Float") _MEMORYWRITE($Y_PTR, $Client_Handles[0],_MEMORYREAD($Y_PTR, $Client_Handles[0], "Float")+$Vector[1], "Float") EndFunc ;;Calculates the 2 vectors for the direction desired then updates the axis in the memory Func Right() $Vector = Angle_To_Vector(Get_Angle()+90) _MEMORYWRITE($X_PTR, $Client_Handles[0],_MEMORYREAD($X_PTR, $Client_Handles[0], "Float")+$Vector[0], "Float") _MEMORYWRITE($Y_PTR, $Client_Handles[0],_MEMORYREAD($Y_PTR, $Client_Handles[0], "Float")+$Vector[1], "Float") EndFunc ;;Calculates the 2 vectors for the direction desired then updates the axis in the memory Func Left() $Vector = Angle_To_Vector(Get_Angle()-90) _MEMORYWRITE($X_PTR, $Client_Handles[0],_MEMORYREAD($X_PTR, $Client_Handles[0], "Float")+$Vector[0], "Float") _MEMORYWRITE($Y_PTR, $Client_Handles[0],_MEMORYREAD($Y_PTR, $Client_Handles[0], "Float")+$Vector[1], "Float") EndFunc ;;Reads the Z axis and adds the Magnitude variable onto it then rewrites it Func Up() _MEMORYWRITE($Z_PTR, $Client_Handles[0],_MEMORYREAD($Z_PTR, $Client_Handles[0], "Float")+$Magnitude, "Float") EndFunc ;;Reads the Z axis and subtracts the Magnitude variable onto it then rewrites it Func Down() _MEMORYWRITE($Z_PTR, $Client_Handles[0],_MEMORYREAD($Z_PTR, $Client_Handles[0], "Float")-$Magnitude, "Float") EndFunc ;;Opens the processes memory Func _MemoryOpen($iv_Pid, $iv_DesiredAccess = 0x1F0FFF, $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 ;;Reads the processes memory. 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 ;;Writes to the processes memory Func _MemoryWrite($iv_Address, $ah_Handle, $v_Data, $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 Else DllStructSetData($v_Buffer, 1, $v_Data) If @Error Then SetError(6) Return 0 EndIf EndIf DllCall($ah_Handle[0], 'int', 'WriteProcessMemory', 'int', $ah_Handle[1], 'int', $iv_Address, 'ptr', DllStructGetPtr($v_Buffer), 'int', DllStructGetSize($v_Buffer), 'int', '') If Not @Error Then Return 1 Else SetError(7) Return 0 EndIf EndFunc ;;Closes a handle to the memory 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 ;;I don't know it wasn't made by me Func SetPrivilege( $privilege, $bEnable ) Const $TOKEN_ADJUST_PRIVILEGES = 0x0020 Const $TOKEN_QUERY = 0x0008 Const $SE_PRIVILEGE_ENABLED = 0x0002 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_ptr",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_ptr",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 ;;Calculates the base load address of a dll in a process Func _MemoryModuleGetBaseAddress($iPID, $sModule) If Not ProcessExists($iPID) Then Return SetError(1, 0, 0) If Not IsString($sModule) Then Return SetError(2, 0, 0) Local $PSAPI = DllOpen("psapi.dll") Local $hProcess Local $PERMISSION = BitOR(0x0002, 0x0400, 0x0008, 0x0010, 0x0020) If $iPID > 0 Then Local $hProcess = DllCall("kernel32.dll", "ptr", "OpenProcess", "dword", $PERMISSION, "int", 0, "dword", $iPID) If $hProcess[0] Then $hProcess = $hProcess[0] EndIf EndIf Local $Modules = DllStructCreate("ptr[1024]") Local $aCall = DllCall($PSAPI, "int", "EnumProcessModules", "ptr", $hProcess, "ptr", DllStructGetPtr($Modules), "dword", DllStructGetSize($Modules), "dword*", 0) If $aCall[4] > 0 Then Local $iModnum = $aCall[4] / 4 Local $aTemp For $i = 1 To $iModnum $aTemp = DllCall($PSAPI, "dword", "GetModuleBaseNameW", "ptr", $hProcess, "ptr", Ptr(DllStructGetData($Modules, 1, $i)), "wstr", "", "dword", 260) If $aTemp[3] = $sModule Then DllClose($PSAPI) Return Ptr(DllStructGetData($Modules, 1, $i)) EndIf Next EndIf DllClose($PSAPI) Return SetError(-1, 0, 0) EndFunc
Syntax Highlighting
[
Open in new window
]
Author Comments
Basic Teleporter code for the game Anarchy Online - Tagyourit50
Rating
4.44 / 8
62 Votes