secret
Created

Modified PoE Exp Calculator with added toggle

  • Download Gist
poeexpcalc.au3
AutoIt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403
;Developed by www.toolsofexile.com
;Modified version
TraySetState(2)
HotKeySet("{F9}", "Toggle")
HotKeySet("{F10}", "Reset")
HotKeySet("{F11}", "Close")
#RequireAdmin
If IsAdmin() = 0 Then
MsgBox(0, "", "You are not running as an administrator! Please right-click this program, then click Run As Administrator.")
Exit
EndIf
$VISIBLE = True
SETPRIVILEGE("SeDebugPrivilege", 1)
$PID = ProcessExists("Client.exe")
If $PID = 0 Then
MsgBox(0, "", "Please run Path of Exile before starting this program.")
Exit
EndIf
$HANDLE = _MEMORYOPEN($PID)
If $HANDLE = 0 Then
MsgBox(0, "", "Unable to open the Path of Exile process to read memory. Please ensure you do not have any software blocking this program from running properly, such as anti-virus software.")
Exit
EndIf
$BASEADDRESS = GETBASEADDRESS($PID)
$PLAYERBASE = $BASEADDRESS + 7141876
 
$PLAYERBASE = _MEMORYREAD($PLAYERBASE, $HANDLE, "dword")
Local $EXPMINOFFSETS[8] = [1112, 88, 1924, 776, 508, 124, 124, 824]
Local $EXPMAXOFFSETS[8] = [1112, 88, 1924, 776, 508, 124, 124, 828]
Local $LEVELOFFSETS[8] = [1112, 88, 1924, 776, 508, 124, 124, 832]
$TIME = TimerInit()
$STARTEXP = READPOINTER($PLAYERBASE, $HANDLE, $EXPMINOFFSETS)
$CURLEVEL = READPOINTER($PLAYERBASE, $HANDLE, $LEVELOFFSETS)
While 1
If ProcessExists("Client.exe") = False Then
Exit
EndIf
$EXPMIN = READPOINTER($PLAYERBASE, $HANDLE, $EXPMINOFFSETS)
$EXPMAX = READPOINTER($PLAYERBASE, $HANDLE, $EXPMAXOFFSETS)
$LEVEL = READPOINTER($PLAYERBASE, $HANDLE, $LEVELOFFSETS)
$EXPGAINED = $EXPMIN - $STARTEXP
If $EXPGAINED < 0 Then
$EXPGAINED = 0
EndIf
$EXPREMAINING = $EXPMAX - $EXPMIN
$TTL = 0
$SECONDS = TimerDiff($TIME) / 1000
$MINUTES = Round(Floor(Mod($SECONDS / 60, 60)))
$HOURS = Round(Floor($SECONDS / 3600))
$SECONDS = Round(Mod($SECONDS, 60))
$RUNTIME = $HOURS & ":" & $MINUTES & ":" & $SECONDS
$EXPHOUR = 0
If $EXPGAINED > 0 Then
$RUNNINGHOURS = TimerDiff($TIME) / (1000 * 60 * 60)
$EXPHOUR = Round($EXPGAINED / $RUNNINGHOURS)
$TTLHOURS = $EXPREMAINING / $EXPHOUR
$TTLMINUTES = $TTLHOURS * 60
$TTLSECONDS = $TTLMINUTES * 60
$INIT = $TTLSECONDS
$HRS = Round(Floor($INIT / 3600))
$MINS = Round(Floor(Mod(($INIT / 60), 60)))
$SECS = Round(Mod($INIT, 60))
$TTL = $HRS & ":" & $MINS & ":" & $SECS
If $EXPHOUR > 10000 Then
$EXPHOUR = Round($EXPHOUR / 1000)
$EXPHOUR = ADDCOMMAS($EXPHOUR)
$EXPHOUR = $EXPHOUR & "k"
EndIf
EndIf
If $EXPMIN > 10000 Then
$EXPMIN = Round($EXPMIN / 1000)
$EXPMIN = ADDCOMMAS($EXPMIN)
$EXPMIN = $EXPMIN & "k"
EndIf
If $EXPMAX > 10000 Then
$EXPMAX = Round($EXPMAX / 1000)
$EXPMAX = ADDCOMMAS($EXPMAX)
$EXPMAX = $EXPMAX & "k"
EndIf
If $VISIBLE Then
ToolTip("Experience: " & $EXPMIN & " / " & $EXPMAX & @CRLF & "Exp/hr: " & $EXPHOUR & @CRLF & "TTL: " & $TTL & @CRLF & "Running Time: " & $RUNTIME, @DesktopWidth / 1.5, 0, "Level: " & $LEVEL)
Else
Tooltip("")
EndIf
Sleep(1000)
WEnd
Func Close()
_MEMORYCLOSE($HANDLE)
Exit
EndFunc
Func Toggle()
$VISIBLE = NOT $VISIBLE
EndFunc
Func ADDCOMMAS($STRING)
$T = 0
$FINAL = ""
$VAR = $STRING
$RESULT = StringSplit($VAR, "")
For $X = $RESULT[0] To 1 Step -1
$T = $T + 1
If $T = 4 Then
$FINAL = "," & $FINAL
$T = 1
EndIf
$FINAL = $RESULT[$X] & $FINAL
Next
Return $FINAL
EndFunc
Func READPOINTER($BASE, $HAND, $OFFSETS)
$CURADDRESS = $BASE
For $X = 0 To UBound($OFFSETS) - 1
$CURADDRESS = _MEMORYREAD($CURADDRESS + $OFFSETS[$X], $HAND, "dword")
Next
Return $CURADDRESS
EndFunc
Func Reset()
$TIME = TimerInit()
$STARTEXP = READPOINTER($PLAYERBASE, $HANDLE, $EXPMINOFFSETS)
$CURLEVEL = READPOINTER($PLAYERBASE, $HANDLE, $LEVELOFFSETS)
EndFunc
Func GETBASEADDRESS($PROCESSID)
$HSNAP = DllCall("Kernel32.dll", "HANDLE", "CreateToolhelp32Snapshot", "DWORD", 8, "DWORD", $PROCESSID)
$STMODULE = DllStructCreate("DWORD dwSize;DWORD th32ModuleID;DWORD th32ProcessID;" & "DWORD GlblcntUsage;DWORD ProccntUsage;ptr modBaseAddr;" & "DWORD modBaseSize;HANDLE hModule;WCHAR szModule[256];" & "WCHAR szExePath[260]")
DllStructSetData($STMODULE, "dwSize", DllStructGetSize($STMODULE))
$RET = DllCall("Kernel32.dll", "BOOLEAN", "Module32FirstW", "HANDLE", $HSNAP[0], "ptr", DllStructGetPtr($STMODULE))
If ($RET[0] = False) Then
DllCall("Kernel32.dll", "BOOLEAN", "CloseHandle", "HANDLE", $HSNAP[0])
Return 0
Else
$RET[0] = True
Do
If DllStructGetData($STMODULE, "szModule") = "Client.exe" Then
DllCall("Kernel32.dll", "BOOLEAN", "CloseHandle", "HANDLE", $HSNAP[0])
Return DllStructGetData($STMODULE, "modBaseAddr")
EndIf
$RET = DllCall("Kernel32.dll", "BOOLEAN", "Module32NextW", "HANDLE", $HSNAP[0], "ptr", DllStructGetPtr($STMODULE))
Until $RET[0] = False
EndIf
EndFunc
#region _Memory
Func _MEMORYOPEN($IV_PID, $IV_DESIREDACCESS = 2035711, $IF_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", $IF_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 _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
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 _MEMORYPOINTERREAD($IV_ADDRESS, $AH_HANDLE, $AV_OFFSET, $SV_TYPE = "dword")
If IsArray($AV_OFFSET) Then
If IsArray($AH_HANDLE) Then
Local $IV_POINTERCOUNT = UBound($AV_OFFSET) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf
Local $IV_DATA[2], $I
Local $V_BUFFER = DllStructCreate("dword")
For $I = 0 To $IV_POINTERCOUNT
If $I = $IV_POINTERCOUNT Then
$V_BUFFER = DllStructCreate($SV_TYPE)
If @error Then
SetError(@error + 2)
Return 0
EndIf
$IV_ADDRESS = "0x" & Hex($IV_DATA[1] + $AV_OFFSET[$I])
DllCall($AH_HANDLE[0], "int", "ReadProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$IV_DATA[1] = DllStructGetData($V_BUFFER, 1)
ElseIf $I = 0 Then
DllCall($AH_HANDLE[0], "int", "ReadProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$IV_DATA[1] = DllStructGetData($V_BUFFER, 1)
Else
$IV_ADDRESS = "0x" & Hex($IV_DATA[1] + $AV_OFFSET[$I])
DllCall($AH_HANDLE[0], "int", "ReadProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(7)
Return 0
EndIf
$IV_DATA[1] = DllStructGetData($V_BUFFER, 1)
EndIf
Next
$IV_DATA[0] = $IV_ADDRESS
Return $IV_DATA
EndFunc
Func _MEMORYPOINTERWRITE($IV_ADDRESS, $AH_HANDLE, $AV_OFFSET, $V_DATA, $SV_TYPE = "dword")
If IsArray($AV_OFFSET) Then
If IsArray($AH_HANDLE) Then
Local $IV_POINTERCOUNT = UBound($AV_OFFSET) - 1
Else
SetError(2)
Return 0
EndIf
Else
SetError(1)
Return 0
EndIf
Local $IV_STRUCTDATA, $I
Local $V_BUFFER = DllStructCreate("dword")
For $I = 0 To $IV_POINTERCOUNT
If $I = $IV_POINTERCOUNT Then
$V_BUFFER = DllStructCreate($SV_TYPE)
If @error Then
SetError(@error + 3)
Return 0
EndIf
DllStructSetData($V_BUFFER, 1, $V_DATA)
If @error Then
SetError(8)
Return 0
EndIf
$IV_ADDRESS = "0x" & Hex($IV_STRUCTDATA + $AV_OFFSET[$I])
DllCall($AH_HANDLE[0], "int", "WriteProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(9)
Return 0
Else
Return $IV_ADDRESS
EndIf
ElseIf $I = 0 Then
DllCall($AH_HANDLE[0], "int", "ReadProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(3)
Return 0
EndIf
$IV_STRUCTDATA = DllStructGetData($V_BUFFER, 1)
Else
$IV_ADDRESS = "0x" & Hex($IV_STRUCTDATA + $AV_OFFSET[$I])
DllCall($AH_HANDLE[0], "int", "ReadProcessMemory", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER), "int", "")
If @error Then
SetError(3)
Return 0
EndIf
$IV_STRUCTDATA = DllStructGetData($V_BUFFER, 1)
EndIf
Next
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
$NTOKENVAR = $NTOKENINDEX - 1
$PRIV = $PRIVILEGE[$NTOKENVAR]
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
Func _MEMORYGETBASEADDRESS($AH_HANDLE, $IHEXDEC = 0)
Local $IV_ADDRESS = 1048576
Local $V_BUFFER = DllStructCreate("dword;dword;dword;dword;dword;dword;dword")
Local $VDATA
Local $VTYPE
If Not IsArray($AH_HANDLE) Then
SetError(1)
Return 0
EndIf
DllCall($AH_HANDLE[0], "int", "VirtualQueryEx", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER))
If Not @error Then
$VDATA = Hex(DllStructGetData($V_BUFFER, 2))
$VTYPE = Hex(DllStructGetData($V_BUFFER, 3))
While $VTYPE <> "00000080"
DllCall($AH_HANDLE[0], "int", "VirtualQueryEx", "int", $AH_HANDLE[1], "int", $IV_ADDRESS, "ptr", DllStructGetPtr($V_BUFFER), "int", DllStructGetSize($V_BUFFER))
$VDATA = Hex(DllStructGetData($V_BUFFER, 2))
$VTYPE = Hex(DllStructGetData($V_BUFFER, 3))
If Hex($IV_ADDRESS) = "01000000" Then ExitLoop
$IV_ADDRESS += 65536
WEnd
If $VTYPE = "00000080" Then
SetError(0)
If $IHEXDEC = 1 Then
Return Dec($VDATA)
Else
Return $VDATA
EndIf
Else
SetError(2)
Return 0
EndIf
Else
SetError(3)
Return 0
EndIf
EndFunc
#endregion _Memory
; DeTokenise by myAut2Exe >The Open Source AutoIT/AutoHotKey script decompiler< 2.12 build(185)

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.