listerily / ModdedBE

Open source Minecraft: Bedrock Edition launcher for Android. Using EnderCore as Mod Engine, patching NMods to Minecraft.
GNU Lesser General Public License v2.1
51 stars 11 forks source link

Dump headers #6

Closed timscriptov closed 3 years ago

timscriptov commented 3 years ago

How can i get attribute for class Actor from shared library?

Example:

class Actor {
int x,y,z;
}

Example 2:

class Color {
float red,green,blue <- how to debug from shared library libminecraftpe
}
listerily commented 3 years ago

Dumping attributes by disassemblers is impossible. When compiling, C/C++ compilers will ignore the attributes' name and replace them with the address offsets. For example:

struct Actor{ int x,y,z; };

Actor myActor;
myActor.y = 0;

Will be translated into:

struct Actor{ int x,y,z; };

Actor myActor;
*((void*)(&myActor) + sizeof(int)) /* size of the attributes before attribute "x" */ = 0;

As a result, compiling loses the name of attributes and leaves address offsets only. We can only get to know where the attribute locates, but it's impossible for us to know the original name of the attributes.