Guide:Finding pointers and offsets: Difference between revisions
Guide:Finding pointers and offsets (view source)
Revision as of 19:26, 13 September 2023
, 8 months agoAdded navbox
TheOnlyZac (talk | contribs) (Added images) |
TheOnlyZac (talk | contribs) (Added navbox) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1:
{{Infobox guide
| sly1 = y
| sly2 = y
| sly3 = y
| difficulty = Intermediate
| time = 10-20 mins
}}
This tutorial will teach you how to find pointers to structs and use offsets to access values stored within those structs. Basically every value the game uses is stored in a struct somewhere in memory, so if you can find a global pointer to a struct, and then figure out the offset to access a value in that struct, you can access that value in any map without having to scan for it. The steps below should work for all three games, though keep in mind that [[Sly 1]] structs are organized slightly differently than [[Sly 2]] and [[Sly 3]] structs.
==How to find the pointer/offset to a value
#'''Find the address of the value within the struct you want to find the pointer for.'''
#*In this tutorial we will use [[Sly 2:Jt|Sly's]] X-position while in the [[Sly 2:F nightclub exterior|Paris map]] in Sly 2. By doing changed value scans in Cheat Engine, we know the address of Sly's X position is is <tt>0xFB3710</tt>.
Line 8 ⟶ 16:
#*In PCSX2, click '''Debug > Open Debug Window'''.
#*Once it opens, click '''Set Breakpoint'''.
#*In the '''Address''' box,
#*Check the box for '''Read''', but not Write or Execute.
#*Click '''OK'''.
#:[[File:Pointer tutorial breakpoint.png]]
#'''Do something to make the game read the value.'''
#*
#*When your breakpoint hits
#'''In the Debugger, look at the assembly code instruction that reads the value, and see what address is in the register it used.'''
#*For example, the instruction will probably be something like <code>sw s0, 0x30(s1)</code>. The register in parenthesis (in this case, <tt>s1</tt>) will contain the base address of the struct, and the number before the parenthesis
#*So, if the s0 register contains the value <tt>FB36E0</tt>, then the base address of the struct is <tt>0xFB36E0</tt>, and Sly's X
#:[[File:Pointert tutorial debugger.png]]
#'''Do a 4-byte scan in Cheat Engine to find an address which stores a pointer to that base address.'''
Line 26 ⟶ 34:
===A struct can store pointers to other structs===
If you followed the above steps to find the pointer to the struct that stores Sly's X position, you might think you've found the pointer to the '''Sly Entity struct'''. However, since this is Sly 2, what you have actually found is the pointer to Sly's '''Transform Component struct'''.
Each entity in the game has a Transform Component, which is referenced by a pointer inside it's Entity struct. This means the pointer you found will not work to find Sly's X position on every map. '''But,
===To find the actual Sly Entity Struct pointer===
Line 40 ⟶ 48:
Once you know the offset of the Transform Component from the entity struct, and the offset of the X coordinate from the transform component, you can find the coordinates for every entity in the game without having to repeat the steps above every single time.
==How to find the
This will work for Sly 2 and Sly 3 entities like Sly, Bentley, Neyla, guards, antennas, cars, trees, bombs, bullets, music box, etc. since Sly 2 and 3 have a method for easily finding pointers to these structs.
#'''Find the FK$X struct for the entity you want'''
Line 69 ⟶ 77:
* [https://docs.google.com/document/d/12XPT3YeYfiwtyEcJOJfOAMNKklIuc4MyXkLM6YAUXU0 Zac's PCSX2 Pointer Tutorials - Google Docs, Aug 8 2021]
{{Navbox guides}}
|