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 


How Do We Find Game Offsets In LUA Script?

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

Joined: 22 Jan 2018
Posts: 36
Location: USA

PostPosted: Wed Dec 04, 2024 4:05 am    Post subject: How Do We Find Game Offsets In LUA Script? Reply with quote

I've been researching how to find offsets from game runtime to affect values ingame. I'm using OpenKH for Kingdom Hearts and something called Lua Backend engine. In the attachment I set up I have questions in Yellow text, but I mainly need to have the 3rd question sovled.

1. Steam version is 0x3B2271. How do we determine this?
2. ReadLong == 0x7265737563697065. IDK where to begin with this number.
3. ReadLong(0x2537E48)+0x40, true. I get this one aside from the offset in parenthasis. It's different from how the game looks at runtime where the offset from the module is "KINGDOM HEARTS FINAL MIX.exe"+2D372A0 + 40 so the final address is = "KINGDOM HEARTS FINAL MIX.exe"+2D372E0 for size x.

I just don't know where 0x2537E48 was determind. I've tried scouring the .exe in HxD, using ReClass.NET, and Cheat Engine. Mind you I've been trying to learn via Guided Hacking and Udemy and am currently learning C++ and LUA. I just don't get offsets sometimes or I'm just not understanding how it works at game initialization in LUA.

Please help and view attachment.



Update: I spoke to the man KSX himself just now and got my answer. I just had to pointer scan 1 level since sora as an entity sits above loading room entities ingame I think. *facepalms*

Please check other attachment for highlighted answer.



offsets_size_x.JPG
 Description:
Answer by KSX
 Filesize:  128.31 KB
 Viewed:  5536 Time(s)

offsets_size_x.JPG



KSX_Lua_Script.PNG
 Description:
Script made by KSX
 Filesize:  167.38 KB
 Viewed:  5543 Time(s)

KSX_Lua_Script.PNG


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Wed Dec 04, 2024 1:24 pm    Post subject: Reply with quote

1, 3: That offset is just a number. There is no semantic value that can be gotten just from that. Given it's passed to the function `ReadLong`, you should look up documentation for that function to learn the meaning of those arguments.
The only documentation I can find is here:
https://github.com/Sirius902/LuaBackend/blob/hook/DOCUMENT.md
It's a little lacking, but it's not unreasonable to assume "base address" refers to the address that the exe was loaded at. This is also shown in your other image "offsets_size_x.JPG".

2: That number is the ASCII string "epicuser" reinterpreted as an 8-byte integer.

_________________
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
Gear2ndGandalf
Cheater
Reputation: 0

Joined: 22 Jan 2018
Posts: 36
Location: USA

PostPosted: Wed Dec 04, 2024 2:31 pm    Post subject: Reply with quote

Thanks, it's more clear to me now due to your explanation! I'm reading and book marking that page now. Looks like 'ReadLong' is typically reading 8 bytes (64-bit) as opposed to 'ReadShort' which is 2 bytes (32-bit) which makes sense due to the game being 64-bit.

Also, I learned since the game is hard coded (green static addresses) I could've done on line 59 for ex: ReadLong(0X2D372E0), true instead of using offsets.

Edit: As to not flood the forum with more topics I have a question regarding this script. What am I doing wrong it shows I have no snytax errors but I'm not affecting the address to enable fly anywhere. Do I need a loop timer? Is the code only running once?

Code:
function flyAnywhere()
local inputAddress = "KINGDOM HEARTS FINAL MIX.exe+23407B5" -- input address
local flyAddress = "KINGDOM HEARTS FINAL MIX.exe+2D37310"   -- animation address

local input = readByte(inputAddress)
local fly = readByte(flyAddress)

if fly ~= nil then
      if input == 0x21 then                                      -- pressing L2 + O
         writeByte(fly, 8)                                       -- mov 8 to fly
      end
      if input == 0x41 then                                      -- pressing L2 + X
         writeByte(fly, 0)                                       -- mov 0 to fly
      end
end
end


Update: Fixed issue in below code.

Code:
{$lua}
if syntaxcheck then return end
[ENABLE]

-- Setup Flying Functions
local flyAddress = "[KINGDOM HEARTS FINAL MIX.exe+02811A08]+70"   -- Animation address

-- Function to enable fly mode
function enableFlyMode(fly)
  writeByte(flyAddress, 0x8)
end

-- Function to disable fly mode
function disableFlyMode(noFly)
  writeByte(flyAddress, 0x0)
end

-- Assign hotkeys
L2O = createHotkey(enableFlyMode, 0x5806, 0x5801)  -- L2 + O or LT + B to enable fly mode
L2X = createHotkey(disableFlyMode, 0x5806, 0x5800) -- L2 + X or LT + A to disable fly mode

[DISABLE]

if L2O then
L2O.destroy()
L2O = nil
end

if L2X then
L2X.destroy()
L2X = nil
end
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