Advertisement
Guest User

ahk read adress

a guest
Oct 6th, 2017
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. IF NOT A_IsAdmin
  3. {
  4.    Run *RunAs "%A_ScriptFullPath%"
  5.    ExitApp
  6. }
  7. setSeDebugPrivilege(enable := True)
  8.  
  9. #SingleInstance Force
  10.  
  11. ProcessName := "game.exe"
  12. hwnd := MemoryOpenFromName(ProcessName)
  13.  
  14.  
  15. CoordMode, Mouse, Client
  16. CoordMode, Pixel, Client
  17. CoordMode, ToolTip, Client
  18.  
  19. SetWorkingDir, %A_ScriptDir%
  20.  
  21.  
  22. adress := 0x0DBA865C
  23.  
  24.  
  25. ยง::
  26. adress_read = % MemoryRead(hwnd, adress, "int",4)
  27. MsgBox, %adress_read%
  28.  
  29.  
  30. ; ==================================================
  31. ; FUCNTIONS!
  32. ; ==================================================
  33.  
  34.  
  35. MemoryOpenFromName(Name)
  36. {
  37.     Process, Exist, %Name%
  38.     Return DllCall("OpenProcess", "Uint", 0x1F0FFF, "int", 0, "int", PID := ErrorLevel)
  39. }
  40.  
  41. MemoryWrite(hwnd, address, writevalue, datatype="int", length=4, offset=0)
  42. {
  43.     VarSetCapacity(finalvalue, length, 0)
  44.     NumPut(writevalue, finalvalue, 0, datatype)
  45.     return DllCall("WriteProcessMemory", "Uint", hwnd, "Uint", address+offset, "Uint", &finalvalue, "Uint", length, "Uint", 0)
  46. }
  47.  
  48.  ; UInt, Int, Int64, Short, UShort, Char, UChar, Double, Float, Ptr or UPtr
  49. MemoryRead(hwnd, address, datatype="int", length=4, offset=0)
  50. {
  51.     VarSetCapacity(readvalue,length, 0)
  52.     DllCall("ReadProcessMemory","Uint",hwnd,"Uint",address+offset,"str",readvalue,"Uint",length,"Uint *",0)
  53.  
  54. if (datatype = "Float")
  55. finalvalue := NumGet(readvalue, 0, "Float")
  56. if (datatype = "Str")
  57. finalvalue := StrGet(&readvalue, length, "UTF-8")
  58. if (datatype = "StrUni")
  59. finalvalue := StrGet(&readvalue, length, "UTF-16")
  60. if NOT (datatype = "Float" or datatype = "Str" or datatype = "StrUni")
  61. {
  62. finalvalue := NumGet(readvalue, 0, datatype)
  63. }
  64. return finalvalue
  65. }
  66.  
  67. setSeDebugPrivilege(enable := True)
  68. {
  69.     h := DllCall("OpenProcess", "UInt", 0x0400, "Int", false, "UInt", DllCall("GetCurrentProcessId"), "Ptr")
  70.     ; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
  71.     DllCall("Advapi32.dll\OpenProcessToken", "Ptr", h, "UInt", 32, "PtrP", t)
  72.     VarSetCapacity(ti, 16, 0)  ; structure of privileges
  73.     NumPut(1, ti, 0, "UInt")  ; one entry in the privileges array...
  74.     ; Retrieves the locally unique identifier of the debug privilege:
  75.     DllCall("Advapi32.dll\LookupPrivilegeValue", "Ptr", 0, "Str", "SeDebugPrivilege", "Int64P", luid)
  76.     NumPut(luid, ti, 4, "Int64")
  77.     if enable
  78.         NumPut(2, ti, 12, "UInt")  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
  79.     ; Update the privileges of this process with the new access token:
  80.     r := DllCall("Advapi32.dll\AdjustTokenPrivileges", "Ptr", t, "Int", false, "Ptr", &ti, "UInt", 0, "Ptr", 0, "Ptr", 0)
  81.     DllCall("CloseHandle", "Ptr", t)  ; close this access token handle to save memory
  82.     DllCall("CloseHandle", "Ptr", h)  ; close this process handle to save memory
  83.     return r
  84. }
  85.  
  86. ^Esc::
  87. ExitApp
  88. return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement