Hi all. I am having a bit of a problem with my code ive been working on lately. What I am trying to do is (from the base address that doesnt change) grab all the data from memory and include it in a structure. Essentially what i want to do is recreate the structure like how it is in the game and simply point my structure to the address and use it.
What I am having troubles with is getting to the correct address in C. I have found my base address though CE and it looks like this. BaseAddress->AnotherAddress+0x34->My Data to fill my structure.
I have reversed enough of my structure to know what is in it and everything is aligned properly I just cant get the correct address. Here is my code.
Code:
typedef unsigned char BYTE;
typedef struct
{
BYTE Unknown01[0x468]; //Unknown stuff
DWORD Id;
DWORD Level;
DWORD Cultivation;
DWORD Current_HP;
DWORD Current_MP;
DWORD Exp;
DWORD Spirit;
DWORD Attribute_Points;
DWORD Current_Chi;
DWORD Attack_Level;
DWORD Defence_Level;
float Critical_Rate;
float Rage_Damage;
DWORD Stealth_Level;
DWORD Stealth_Detection_Level;
DWORD Slaying_Level;
DWORD Warding_level;
DWORD Vitality_Points;
DWORD Magic_Points;
DWORD Strength_Points;
DWORD Dextarity_Points;
DWORD Max_HP;
DWORD Max_MP;
DWORD HP_Regen;
DWORD MP_Regen;
float Walk_Speed;
float Run_Speed;
float Swim_Speed;
float Fly_Speed;
DWORD Accuracy;
DWORD Min_Attack_Damage;
DWORD Max_Attack_Damage;
float Attack_Rate;
float Range;
DWORD Min_Metal_Damage;
DWORD Max_Metal_Damage;
DWORD Min_Wood_Damage;
DWORD Max_Wood_Damage;
DWORD Min_Water_Damage;
DWORD Max_Water_Damage;
DWORD Min_Fire_Damage;
DWORD Max_Fire_Damage;
DWORD Min_Earth_Damage;
DWORD Max_Earth_Damage;
DWORD Min_Magic_Damage;
DWORD Max_Magic_Damage;
DWORD Metal_Defence;
DWORD Wood_Defence;
DWORD Water_Defence;
DWORD Fire_Defence;
DWORD Earth_Defence;
DWORD Physical_Defence;
DWORD Evasion;
DWORD Max_Chi;
DWORD Coins;
DWORD Max_Coins;
}PLAYER;
typedef struct
{
BYTE Unknown[0x34];
PLAYER *p_player;
}VARBASE;
DWORD WINAPI function()
{
VARBASE *Stats = (VARBASE*)0x00BBC9CC;
char lol[1000];
sprintf(lol, "stats pointer: %p | player pointer: %p | player pointer + 34: %ld", (void*)Stats, (void*)Stats->p_player, Stats->p_player->Level);
SomeFunction(lol);
return NULL;
}
What should be happening is when I create my VARBASE structure it will add 0x34 bytes to the address 0x00BBC9CC is pointing to and then set that new address as a pointer to my player struct where I can use all my variables.
It should look like 0x00BBC9CC->0x0A15CDC0+34->14DEE5F0(the beginning of the games structure i want to point to)
but instead it looks like 0x00BBC9CC->0x00000301->0x00001501 which causes a segment fault when i try to read it.
maybe someone here can help point me in the right direction for trying to find the correct memory address.
thanks for any help!