[Path of Exile] Auto Potion

Ask gaming related questions (AHK v1.1 and older)
0sync0
Posts: 46
Joined: 05 Aug 2016, 13:57

Re: [Path of Exile] Auto Potion

28 Feb 2017, 23:31

Thanks RHCP.
LemonHaze_ wrote:But now how do I use this getProcessBaseAddress functions you posted for the sake of learning?
RHCP shows how to use it in his example.

I don't understand why your code works without it unless perhaps PoE's base address is always 0.
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

28 Feb 2017, 23:55

I find a static address using CE then add the offsets. I used the base address function and it yields a completely different address with a value of 0. I don't really know what to do with that base address but my code works without it.
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: [Path of Exile] Auto Potion

01 Mar 2017, 00:13

LemonHaze_ wrote:I figured out a new working set of static address and offsets (well only the static address changed the offsets are still the same). My program works fine with the new values. But now how do I use this getProcessBaseAddress functions you posted for the sake of learning?

I use it to get a base address value. Now assuming this is a static address how do i find the offsets from this base that lead to current hp and max hp? And so if the function always finds the base address and if the offsets from that base address to my desired variable never change then this is a more update/patch proof solution is that right?
You don't need to use it in your situation.

Programs will have either a static or an ASLR (Address Space Layout Randamisation) dynamic base address. If a process has a static base address every time it loads the base address will remain the same, usually 0x40000000. Most games however will have a dynamic address which changes each time it loads. If a game has a dynamic base address, CE will usually label addresses as "game.exe + 0xB00B5" (hence every time the game reloads 'game.exe + 0xB00B5' evaluates to a different address), and you need to use one of those functions to determine the address that 'game.exe' resolves to. Note, you can add 'game.exe' e.g. 'calc.exe' as a CE address to easily see the address. Just for clarity, when people refer to the base address of a POINTER they are talking about the first address which is read in a pointer - not the base address of the game/process. If the game uses ASLR and has a dynamic base address, then the base address of the pointer will look like game.exe + 0x019D45B0, and hence you will need to work out the base address of the PROCESS too i.e. what game.exe resolves to. I don't think i explained that very well...


If the game is fairly well established (it's data structures aren't being radically changed), then the offsets associated with pointers will often remain the same and it's only the base address of the pointer which changes. In this case you can usually find the same pointer again in a single scan - tell CE to only scan for addresses with the same number of offsets, and limit the maximum offset value to something slightly larger than the largest offset value of your old offset. This is the easiest method to quickly update your pointer.

If you really want to make it more robust to updates, then you need to use AOB scanning in your script to find the base address of the pointer. In short, you:
  1. Add the base address of the pointer to CE
    Right click the address and select 'find out what accesses this address'
    Look at the (asm) codes which accesses the address.
    One of them will have something like (might be a different instruction): push game.exe+DEADBEEF (ASLR Dynamic) or push DEADBEEF (static), or lea edx,[ecx+game.exe+DEADBEEF], or mov [game.exe+DEADBEEF],eax -- the address will evaluate to your pointer's base address.
    Use the ASM code which surrounds that line to create an AOB pattern which will uniquely identify that line of code.
    Use the AOB pattern in your AHK script to find the code and read the base address of the pointer.


Cheers.
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

01 Mar 2017, 00:42

Great info thank you! I will need to reread it a couple times to really digest it. I may attempt it at some point but I've got a working method and finding the new static address isn't that hard so I'll stick to what I have for now.
0sync0
Posts: 46
Joined: 05 Aug 2016, 13:57

Re: [Path of Exile] Auto Potion

01 Mar 2017, 17:19

Send, {e 1}
What is the idea behind the way you are formating your sends? When I test this in Notepad it sends "e". So it seems to be identical to "Send, e".
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

02 Mar 2017, 08:49

I'm just trying to make sure it only sends the key once. It is not as important on the e key but the 1 2 3 keys where my potions are should only be pressed once when needed. If the program were spamming the potions every time I'd run out of potions really quickly. I'm just trying to slow down the program. I don't know maybe it is unnecessary and is not doing anything different. I'm a noob.
0sync0
Posts: 46
Joined: 05 Aug 2016, 13:57

Re: [Path of Exile] Auto Potion

02 Mar 2017, 10:49

LemonHaze_ wrote:I'm just trying to slow down the program.
Use sleep between sends for control.
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

03 Mar 2017, 00:33

I do already. I reduced the sleep even because 90% it would work perfectly but if I took a spike of damage sometimes it would not spam hp pots as fast as it should so I lowered the delay a bit and now it feels really good. I mean if you take back to back spike damage at that point potions really aren't going to save you anyway no matter how perfect it's usage.
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

07 Sep 2017, 03:30

Hi,

I am resurrecting this post because I have returned to this same bit of code just now after the big Path of Exile update. It is now 64 bit and I am having a lot of trouble reading the memory. I also had some trouble finding the offsets and static address in Cheat Engine but I figured that part out (had to use 8 byte instead of the default 4). I am having trouble reading the memory in the addresses I have figured out with both the ReadMemory() function below and I have installed classMemory.ahk and tried using that as well but I couldn't get results. Thank you in advance!

base = 7FF6 EB18 0000
static = base + 0x1311268 = 7FF6 EC49 1268
current hp = static + +0xa10 + 0x998 + 0x9d8
max hp = static + +0xa10 + 0x998 + 0x9d0

you can check my work here
https://imgur.com/a/jbxLp
classMemory.ahk
https://github.com/Kalamity/classMemory

For simplicity sake all I want is a program that will give me the max hp and current hp values in a msgbox. If i can extract that info the auto potion code is easy and I've already done it in the past as you can see.

Simple Msgbox:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#Include <classMemory>
; You can use this code to check if you have installed the class correctly.
if (_ClassMemory.__Class != "_ClassMemory")
{
	msgbox class memory not correctly installed. Or the (global class) variable "_ClassMemory" has been overwritten
	ExitApp
}

poe := new _ClassMemory("ahk_exe PathOfExile_x64Steam.exe", "", hProcessCopy) 
; Check if the above method was successful.
if !isObject(poe) 
{
	msgbox failed to open a handle
	if (hProcessCopy = 0)
	msgbox The program isn't running (not found) or you passed an incorrect program identifier parameter. 
	else if (hProcessCopy = "")
	msgbox OpenProcess failed. If the target process has admin rights, then the script also needs to be ran as admin. Consult A_LastError for more information.
	ExitApp
}

base:=getProcessBaseAddress("ahk_exe PathOfExile_x64Steam.exe")

s1:=base+0x1311268
p1:=poe.Read(s1)
p2:=poe.Read(p1+0xa10)
p3:=poe.Read(p2, "UInt", 0x998)
chp:=poe.Read(p3, "UInt", 0x9d8)

mhp:=poe.Read(p3, "UInt", 0x9d0)

WinGet, pid, PID, ahk_exe PathOfExile_x64Steam.exe
MsgBox, The POE's PID is %pid%`nbase = %base%`ns1 = %s1%`np1 = %p1%`np2 = %p2%`np3 = %p3%`nchp = %chp%`nmhp = %mhp%
ReadMemory: (even though my code is currently trying to use the classMemory.ahk lib file. classMemory.ahk is standard and unaltered from github so there is no point posting that here but the ReadMemory function could be different so I am posting it here)

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

ReadMemory(address)
{
    ; It would be safer to use a more exact title for winget e.g.
    ; winget, pid, PID, ahk_exe PathOfExile.exe ; or what ever the exe is called
    ; otherwise you risk reading from another process when PoE isn't the active window.
    WinGet, pid, PID, ahk_exe PathOfExile_x64Steam.exe
    if !pid 
        return 
    if !hProcess := DllCall("OpenProcess", "UInt", 24, "Int", False, "UInt", pid, "Ptr") 
        return 
    success := DllCall("ReadProcessMemory", "Ptr", hProcess, "Ptr", address, "UInt*", result, "Ptr", 4, "Ptr",0)
    DllCall("CloseHandle", "Ptr", hProcess)
    return success ? result : ""
}
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: [Path of Exile] Auto Potion

08 Sep 2017, 01:05

The getProcessBaseAddress() standalone function is probably returning an incorrect baseaddress. Classmemory also includes getModuleBaseAddress() which is more reliable and should be used where possible. With the current version of classmemory poe.baseaddress is automatically set to the value of getModuleBaseAddress() when possible.

Make sure classMemory.ahk is up-to-date (version 2.8). You need to launch the script via the 64 bit AHK exe i.e. run the script as 64 bits to allow 8 byte pointers to work.

This works on my computer.

Code: Select all

f1::
if (A_ptrSize != 8)
{
	msgbox "AHK needs to run as 64 bit!"
	ExitApp
}
if (_classmemory.version() < 2.8)
{
	msgbox update class memory ; https://github.com/Kalamity/classMemory
	exitapp 
}


poe := new _classmemory("ahk_exe PathOfExile_x64Steam.exe")
hp := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d8)
maxHP := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d0) 
msgbox % hp "`n" maxHP
return 
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

08 Sep 2017, 02:33

Thank you for your reply. I downloaded classMemory.ahk again from this link https://github.com/Kalamity/classMemory but when I run your code it still says update class memory. I don't get it. I assume the github version is the latest no? Should i delete every other file in the lib folder to avoid conflict?

Also I am using 64 bit AHK
https://imgur.com/a/5uae2
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: [Path of Exile] Auto Potion

08 Sep 2017, 03:23

%A_ScriptDir%\Lib\ ; Local library - requires AHK_L 42+.
%A_MyDocuments%\AutoHotkey\Lib\ ; User library.
path-to-the-currently-running-AutoHotkey.exe\Lib\ ; Standard library.

if a script calls a nonexistent function MyFunc(), the program searches for a file named "MyFunc.ahk" in the user library. If not found there, it searches for it in the standard library.
[AHK_L 42+]: The local library is supported and is searched before the user library and standard library.
If you have multiple classMemory.ahk files spread among those folders and use "#Include <classMemory>" syntax (which searches the library folders for the file) then that could cause an issue.

Just delete the version 'if' statement and see if it works.
You can check the running version by doing:

Code: Select all

msgbox % _classmemory.version()
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

08 Sep 2017, 03:31

I do not have multiple classMemory.ahk files. I downloaded the zip from github and put the one and only classMemory.ahk into the lib folder. I also tried by commenting out the version check if statement. I got a blank msg box. I'm passing the 64 bit check, failing the version check, and if version check is bypassed getting blank results. Something is funny here.

my poe ahk codes folder cleaned up to avoid possible conflict
and the lib folder images below
https://imgur.com/a/8kueS
RHCP
Posts: 202
Joined: 30 Sep 2013, 10:59

Re: [Path of Exile] Auto Potion

08 Sep 2017, 03:48

Are you including the class via #include?

Code: Select all

#Include <classMemory>

Code: Select all

        ; You can use this code to check if you have installed the class correctly.
            if (_ClassMemory.__Class != "_ClassMemory")
            {
                msgbox class memory not correctly installed. Or the (global class) variable "_ClassMemory" has been overwritten
                ExitApp
            }
LemonHaze_
Posts: 21
Joined: 23 Feb 2017, 22:02

Re: [Path of Exile] Auto Potion

08 Sep 2017, 03:56

DEAR SWEET BABY JESUS. in my other code i had the include but when i copy pasted your code i forgot it. thats it. thank you so very much!
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: [Path of Exile] Auto Potion

13 Sep 2017, 15:49

RHCP wrote:Make sure classMemory.ahk is up-to-date (version 2.8). You need to launch the script via the 64 bit AHK exe i.e. run the script as 64 bits to allow 8 byte pointers to work.

This works on my computer.

Code: Select all

f1::
if (A_ptrSize != 8)
{
	msgbox "AHK needs to run as 64 bit!"
	ExitApp
}
if (_classmemory.version() < 2.8)
{
	msgbox update class memory ; https://github.com/Kalamity/classMemory
	exitapp 
}


poe := new _classmemory("ahk_exe PathOfExile_x64Steam.exe")
hp := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d8)
maxHP := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d0) 
msgbox % hp "`n" maxHP
return 
Works on my computer also.

First time I have used your classMemory. Nicely done!

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
User avatar
FanaticGuru
Posts: 1906
Joined: 30 Sep 2013, 22:25

Re: [Path of Exile] Auto Potion

20 Sep 2017, 13:04

FanaticGuru wrote:Works on my computer also.
Well it was working up till the latest update.

Since then I cannot figure out the chain to get back to a static address.

Previous working addresses:

Code: Select all

hp := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d8)
maxHP := poe.read(poe.baseaddress + 0x1311268, "UInt", 0xa10, 0x998, 0x9d0) 
I found the HP, the 0x9d8, the 0x998. I can't find the 0xa10 so that may no longer be valid and I seem to be going in circles from there trying to find new offsets to get back to a valid initial offset from the baseaddress.

If anyone has the updated code it would be greatly appreciated. I am something of a newb at unraveling pointer chains and still learning.

FG
Hotkey Help - Help Dialog for Currently Running AHK Scripts
AHK Startup - Consolidate Multiply AHK Scripts with one Tray Icon
Hotstring Manager - Create and Manage Hotstrings
[Class] WinHook - Create Window Shell Hooks and Window Event Hooks
yessorryno
Posts: 22
Joined: 12 Sep 2017, 03:13

Re: [Path of Exile] Auto Potion

20 Sep 2017, 21:14

Hi All,

I will be stopped by nProtect GameGuard when I use CE.

How to use CE is not detected by nProtect GameGuard?

Can someone help me find the way?

Thanks

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: Shoobis and 39 guests