 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
x86asm How do I cheat?
Reputation: 0
Joined: 11 May 2016 Posts: 8
|
Posted: Sat Jul 23, 2016 7:53 pm Post subject: Finding the members of some pointer? |
|
|
Say the address of our pointer is 0x1000. At 0x1004 we have player health. At 0x1100 we have player mana. At 0x1500 we have player ammo
------------------------------
Suppose we only know the player health at 0x1004 and we want to find the offset for mana (0x100 but we dont know that) and ammo (0x500 but we dont know that)
How can I find this out? Is there any way to find every instruction that accesses our pointer + some offset? Like say these instructions exist somewhere in memory:
1) 0x12345678: mov eax, [esi+0x100] ;esi=0x1000
2) 0x13231111: mov eax, [esi+0x4] ;esi = 0x1000
3) 0x13888888: mov eax, [esi+0x500] ;esi = 0x1000
How can we find them? In other words, if I know for a fact I have some pointer which will point to a bunch of different things like player health, blablabla, how can I find everything this pointer points to?
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4709
|
Posted: Sat Jul 23, 2016 8:40 pm Post subject: |
|
|
Look at how the game accesses those addresses.
For example, you find an address. Go to some address later on, find out what's accessing it, and if the difference between the offsets in instructions that accesses those addresses is the same as the distance away you moved in memory, they're very likely in the same structure. When you get to the point where nothing matches up like this anymore, you're probably at the end of the structure.
To figure out what kind of stuff is in a structure, you look at it. If you don't know what a particular value is, either change it or look at how the game uses it.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
x86asm How do I cheat?
Reputation: 0
Joined: 11 May 2016 Posts: 8
|
Posted: Sat Jul 23, 2016 8:59 pm Post subject: |
|
|
| According to somebody else who has already analyzed the game, the offsets are all over the place and aren't ordered like you would expect them to be. I.e. X,Y,Z aren't ordered sequentially in memory, but instead have random offsets with no relation to each other
|
|
| Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4709
|
Posted: Sat Jul 23, 2016 9:21 pm Post subject: |
|
|
And according to the information in your first post, what I said is valid.
Let's say you find the address of your health.
You see something that looks like mana 0xFC bytes after the address of your health.
You find out what instructions access those addresses and that the common offsets are 0x4 for your health and 0x100 for your mana.
You notice 0x100 - 0x4 = 0xFC, the exact amount of bytes away your mana is from your health.
This probably means your mana and your health are in the same structure since they're accessed from a common base address.
I never claimed everything would be ordered sequentially, nor did you ask about that. There is no rule or standard applicable to every type of program dictating the storage of analogous values.
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Jul 23, 2016 9:25 pm Post subject: |
|
|
Overall it depends on the game. Not every game is setup / designed the same way, and not every game is compiled in the same language. Different languages treat things in different manners. While one language may compile an object down into a block of memory easily mapped back to the original, not all languages are that elegant for a reverse engineer.
Things can be attached to others as well depending on the language. For example in C++, you could have a player object that inherits from other base objects, as well as includes pointers to other objects after that. Such as:
| Code: | // Ammo definition structure that holds information about an entities
// ammo for various guns.
struct Ammo
{
// Info specific to the current weapon being used..
int m_CurrentSelectedWeapon;
int m_CurrentClipAmmo;
int m_CurrentClipAmmoMax;
// Info specific to various other weapon types of ammo the
// player may contain..
int m_M4A1Ammo;
int m_M4A1AmmoMax;
int m_AK47Ammo;
int m_AK47AmmoMax;
int m_AUGAmmo;
int m_AUGAmmoMax;
};
// Base entity class used for all objects..
class Entity
{
public:
int m_Id;
int m_Type;
char* m_Name;
int m_Health;
int m_Mana;
float m_MovementSpeed;
};
// Player class, inherits from a base entity..
class Player : public Entity
{
public:
int m_Team;
int m_Rank;
int m_Level;
// pointer to another struct that contains data for this player..
Ammo* m_AmmoInfo;
};
// Npc class for a friendly NPC type..
class NpcFriendly : public Entity
{
public:
int m_VendorId;
int m_SomeOtherValue;
}; |
While each of the entities here all inherit from a base of Entity, they all define their own personal properties to determine what their other information is.
With this, it means that an offset of +0x100 for a player will not match the same thing as +0x100 for an Npc.
Figuring out these values is more or less up to you as a reverser. Most games do not have SDKs or public source code to look at to map the information to, so you have to do it manually.
Tools like Cheat Engines Data/Structure Dissector or another called ReClass do a great job at helping map blocks of memory back to a usable structure for understanding what is what. You could also use a tool like 010 Editor (hex editor) and map live memory to a binary template with their templating system, which I personally love and use the most for this type of thing.
_________________
- Retired. |
|
| Back to top |
|
 |
|
|
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
|
|