Advertisement
Guest User

magenpriest2

a guest
Apr 30th, 2012
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 6.47 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
  3. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  4. ;--------------------------------------------------------------------------------
  5. ;Getting My Player GUID
  6. ;--------------------------------------------------------------------------------
  7. #include <NomadMemory.au3>
  8. #include <ButtonConstants.au3>
  9. #include <EditConstants.au3>
  10. #include <GUIConstantsEx.au3>
  11. #include <WindowsConstants.au3>
  12.  
  13. ;--------------------------------------------------------------------------------
  14. ;public enum Player
  15. ;--------------------------------------------------------------------------------
  16. $playerName = 0x9BE820
  17. ;PlayerName = 0x9BE820,
  18.  
  19. ;--------------------------------------------------------------------------------
  20. ;public enum UnitFields
  21. ;--------------------------------------------------------------------------------
  22. $UNIT_FIELD_HEALTH = 0x8 + 0x12
  23. ;OBJECT_END = 0x8
  24. ;UNIT_FIELD_HEALTH = OBJECT_END + 0x12,
  25.  
  26. ;--------------------------------------------------------------------------------
  27. ; Offsets Object Manager
  28. ; Offset and Pointer for Wow 4.3.4.15595
  29. ;--------------------------------------------------------------------------------
  30. ;CurMgrPointer = 0x9BE7E0,
  31. ;CurMgrOffset = 0x463C,
  32. ;NextObject = 0x3C,
  33. ;FirstObject = 0xC0,
  34. ;LocalGUID = 0xC8,
  35. Global Const $ClientConnection = 0x9BE7E0                       ;The first 2 are you create you manager from the baseaddress wow
  36. Global Const $CurrMgrOffset = 0x463C
  37. Global Const $FirstObjectOffset = 0xC0                          ;The next one is to get the address of your first object ONLY
  38. Global Const $NextObjectOffset = 0x3C                           ;To cycle through the object you need this offset
  39. Global Const $localPlayerGUIDOffset = 0xC8
  40. Global Const $GameObjGUIDOffset = 0x30                          ;This next one is to find the objects type : 1 to 7
  41. Global Const $GameObjTypeOffset = 0x14                          ;And this one is to find the objects GUID
  42. Global Const $DescriptorOffset = 0x8
  43.  
  44. ;Open WoW Process to enable Memory Reading and Get the WoW Base Address
  45. $ProcessID = ProcessExists("wow.exe")
  46. $WowProcess = _MemoryOpen($ProcessID)
  47.  
  48. ;Getting WoWBase Address
  49. $WowBase = GetWoWBaseAddress($ProcessID)
  50.  
  51. ;1) Getting CurrentManager_Pre
  52. $currMgr_pre = _MemoryRead("0x" & Hex($WowBase + $ClientConnection), $WowProcess , "dword")
  53. ;2) Getting CurrentManager
  54. $currMgr = _MemoryRead("0x" & Hex($currMgr_pre + $CurrMgrOffset), $WowProcess , "dword")
  55.  
  56. ;Getting My Player GUID (Player Global Unique ID)
  57. $pGUID = _MemoryRead("0x" & Hex($currMgr + $localPlayerGUIDOffset), $WowProcess , "UINT64") ;Player Guid
  58. $pGUID2 = _MemoryRead("0x" & Hex($currMgr + $localPlayerGUIDOffset), $WowProcess , "dword") ;Player Guid 2
  59.  
  60. ;Gettin My Player Address
  61. $ObjectMemLoc = GetMemLocByGUID($pGUID)
  62.  
  63. $msgbox_text  = "";
  64. $msgbox_text &= "$ProcessID: " & $ProcessID & @CRLF;
  65. $msgbox_text &= "$WowBase: " & $WowBase & @CRLF;
  66. $msgbox_text &= "$currMgr_pre: " & $currMgr_pre & @CRLF;
  67. $msgbox_text &= "$currMgr: " & $currMgr & @CRLF;
  68. $msgbox_text &= "$pGUID: " & $pGUID & @CRLF;
  69. $msgbox_text &= "$pGUID2: " & $pGUID2 & @CRLF;
  70. $msgbox_text &= "Player Name: " & GetPlayerName() & @CRLF;
  71. $msgbox_text &= "Player health: " & GetPlayerHealth() & @CRLF;
  72.  
  73. MsgBox(1,"Test",$msgbox_text)
  74.  
  75. Func GetPlayerName()
  76.     return _memoryread($WowBase + $playerName, $WowProcess, "char[20]")
  77. EndFunc
  78.  
  79. Func GetPlayerHealth()
  80.     $pDescriptor = _MemoryRead("0x" & Hex($ObjectMemLoc + $DescriptorOffset), $WowProcess , "dword");<---essentially says that you want to use a descriptor (aka health)
  81.     $pHealth = _MemoryRead("0x" & Hex($pDescriptor + $UNIT_FIELD_HEALTH), $WowProcess ,"dword");<---looks up your health
  82.     return $pHealth
  83. EndFunc
  84.  
  85.  
  86. Func GetMemLocByGUID($guid)
  87.     ;Read the first wow object by adding our current manager address and our first object offset together
  88.     $NextObject = _MemoryRead("0x" & Hex($currMgr + $FirstObjectOffset), $WowProcess , "dword")
  89.  
  90.     ;next get the object type buy adding our first object and our Objtype offset together  and reading that
  91.     $ObjType = _MemoryRead("0x" & Hex($NextObject + $GameObjTypeOffset), $WowProcess , "dword")
  92.  
  93.     ;If the return of object type is less than or equal to 7 (which it should always be) and more than 0 in the case that we do have an object in the list than do a while loop.
  94.  
  95.     while (($ObjType <= 7) And ($ObjType > 0))
  96.  
  97.         ;NOTE: if there is an object in the list, objType will have to be = 1 to 7
  98.         ; If our object plus the GUIDoffset = the GUID we are looking for (example our localplayer GUID) …
  99.             IF (_MemoryRead("0x" & Hex($NextObject + $GameObjGUIDOffset), $WowProcess , "UINT64") = $guid) Then ; …then return our object
  100.             Return $NextObject ;found what we wanted.
  101.         EndIf
  102.  
  103.  
  104.         ;if no return happens (stays in the function) then cycle through the objects using our next object offset on our next object (might also be called current object)
  105.         $NextObject = _MemoryRead("0x" & Hex($NextObject + $NextObjectOffset), $WowProcess , "dword")
  106.  
  107.         ;We will also need to see the type
  108.         $ObjType = _MemoryRead("0x" & Hex($NextObject + $GameObjTypeOffset), $WowProcess , "dword")
  109.  
  110.     Wend
  111.  
  112.     ;if we find nothing Return 0 (address are probably wrong or you messed up code)
  113.     Return 0;
  114. EndFunc
  115.  
  116. Func GetWoWBaseAddress($ProcessID)
  117.         $HSNAP = DllCall("Kernel32.dll", "HANDLE", "CreateToolhelp32Snapshot", "DWORD", 8, "DWORD", $ProcessID)
  118.         $STMODULE = DllStructCreate("DWORD dwSize;DWORD th32ModuleID;DWORD th32ProcessID;" & "DWORD GlblcntUsage;DWORD ProccntUsage;ptr modBaseAddr;" & "DWORD modBaseSize;HANDLE hModule;WCHAR szModule[256];" & "WCHAR szExePath[260]")
  119.         DllStructSetData($STMODULE, "dwSize", DllStructGetSize($STMODULE))
  120.         $RET = DllCall("Kernel32.dll", "BOOLEAN", "Module32FirstW", "HANDLE", $HSNAP[0], "ptr", DllStructGetPtr($STMODULE))
  121.  
  122.         IF ($RET[0] = False) Then
  123.                 DllCall("Kernel32.dll", "BOOLEAN", "CloseHandle", "HANDLE", $HSNAP[0])
  124.                 Return 0
  125.         Else
  126.                 $RET[0] = True
  127.                 Do
  128.                         If DllStructGetData($STMODULE, "szModule") = "Wow.exe" Then
  129.  
  130.                                 DllCall("Kernel32.dll", "BOOLEAN", "CloseHandle", "HANDLE", $HSNAP[0])
  131.  
  132.                                 Return DllStructGetData($STMODULE, "modBaseAddr")
  133.                         EndIf
  134.                         $RET = DllCall("Kernel32.dll", "BOOLEAN", "Module32NextW", "HANDLE", $HSNAP[0], "ptr", DllStructGetPtr($STMODULE))
  135.                 Until $RET[0] = False
  136.         EndIf
  137. EndFunc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement