Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Same Address different value? Why?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Mon Aug 21, 2023 9:42 am    Post subject: Same Address different value? Why? Reply with quote

Code:
local TeamIdAddress1 = getAddress('[[[[game.exe+01CBBBF0]+60]+338]+38]+A0')

local baseAddress = getAddress('game.exe+01CBBBF0')
local TeamIdAddress2 = getAddress(baseAddress + 0x60 + 0x338 + 0x38 + 0xA0)

print("TeamIdAddress1:", TeamIdAddress1)
print("TeamIdAddress2:", TeamIdAddress2)


I am getting different values at print for TeamIdAddress1 & TeamIdAddress2.
Why is that? Aren't both the same exact address?

Can someone explain and help me understand.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Mon Aug 21, 2023 10:13 am    Post subject: Reply with quote

Pointers don't work that way. A pointer is a value type that stores another address.

Square brackets mean "the pointer value stored at this address"

Code:
local TeamIdAddress1 = getAddress'[[[[game.exe+01CBBBF0]+60]+338]+38]+A0'
local TeamIdAddress2 = readPointer(readPointer(readPointer(readPointer'game.exe+1CBBBF0'+0x60)+0x338)+0x38)+0xA0

assert(TeamIdAddress1 == TeamIdAddress2)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Tue Aug 22, 2023 3:01 am    Post subject: Reply with quote

Something new learnt. Thank you.

So In this example:
Code:
'[[[[game.exe+01CBBBF0]+60]+338]+38]+A0'


Does it mean there are 5 pointers one pointing to the next until it comes to the final address?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Tue Aug 22, 2023 9:29 am    Post subject: Reply with quote

There are 4 pointers. Example:
Code:
        pointer        ->   value
1: [game.exe+01CBBBF0] -> 415C69AE0
2: [415C69AE0 + 60]    -> 298145E00
3: [298145E00 + 338]   -> 417BB14C0
4: [417BB14C0 + 38]    -> 1C849EA08

final address (can be any type): 1C849EA08 + A0 = 1C849EAA8

The first pointer is the base address. The next 3 pointers are nodes. The final result is the address the pointer path points to.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Tue Aug 22, 2023 11:15 am    Post subject: Reply with quote

Code:
local xStepSequence = {0x0, 0x8, 0x10, 0x18, 0x20, 0x28, 0x30, 0x38, 0x40, 0x48, 0x50, 0x58, 0x60}

for PIndex, PxOffset in ipairs(xStepSequence) do
    local TeamIdAddress2 = readPointer(readPointer(readPointer(readPointer'game.exe+1CBBBF0'+0x60)+0x338)+PxOffset)+0xA0
end


As you can see above when i used PxOffset to replace a certain offset (3rd one here) it works but when I use it similarly like this:

local TeamIdAddress1 = getAddress'[[[[game.exe+01CBBBF0]+60]+338]+PxOffset]+A0'

why doesn't it work?


Another question I have is that I learnt from you using getAddressSafe to counter errors for nil values. How would I do that in this case:
Code:
readPointer(readPointer(readPointer(readPointer'game.exe+1CBBBF0'+0x60)+0x338)+PxOffset)+0xA0


There is no readPointerSafe is there?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Aug 22, 2023 11:52 am    Post subject: Reply with quote

Because getAddress requires a string literal.
Code:

local TeamIdAddress1 = getAddress('[[[[game.exe+01CBBBF0]+60]+338]+' .. string.format('%X', PxOffset) .. ']+A0')
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4700

PostPosted: Tue Aug 22, 2023 1:16 pm    Post subject: Reply with quote

Code:
local my_var = 5
print(my_var)    -- prints "5"
print('my_var')  -- prints "my_var", not 5

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Bit Byte
Advanced Cheater
Reputation: 0

Joined: 28 Nov 2022
Posts: 62

PostPosted: Wed Aug 23, 2023 10:59 am    Post subject: Reply with quote

Ok, thank you, I got it to work.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites