Pointers in the script are pointing to real memory.
Internally the script works exactly like C.
This is what makes it so compatible with real C/C++ functions and makes it exceptionally fast to call real C/C++ functions.
However what you are doing is taking an
extern pointer and assigning it to a local pointer.
You can’t do this because they are using two completely different addressing methods.
extern pointers point to addresses in the target process while local pointers point to addresses in the script, or within Memory Hacking Software itself otherwise.
So if you did this:
- Code: Select all
extern byte e_bHeader[32] = { "", 0x00400000 };
byte * l_pbHeader = (byte *)0x00400000;
e_bHeader[X] gives you the PE header (data from the loaded .EXE file at address 0x00400000) from the target process while
l_pbHeader[X] gives you the PE header of Memory Hacking Software.
When you assign
memptr to the local
ptr, you are removing its
extern properties, and the result is not necessarily what you desire.
If you want to map the player structure using
extern, define a structure that matches that of your player structure and create an extern variable of a pointer of that type with the address being the address of the real pointer in the game.
So, for example, my player class looks like this:
- Code: Select all
struct PLAYER {
int iHealth;
int iAmmo;
float fPos[3]; // XYZ position.
char szName[32]; // Player name.
};
And if we have a pointer to our player (which translates to a pointer to the PLAYER structure above) at address 0x0056F3EC, then we do this:
- Code: Select all
extern PLAYER * e_pPlayer = { "", 0x0056F3EC };
And now to access anything in our player, use the normal -> operator.
- Code: Select all
PrintF( "Health: %d, Ammo: %d, Pos: %f %f %f", e_pPlayer->iHealth, e_pPlayer->iAmmo, e_pPlayer->fPos[0], e_pPlayer->fPos[1], e_pPlayer->fPos[2] );
If you try to pass
extern pointer types to functions you will be an error because they use different addressing modes, and the function does not know that the addressing mode for the parameter you supplied is supposed to be
extern.
So if you want to print strings, you have to copy the string locally.
- Code: Select all
char szLocal[32];
for ( INT I = 0; I < 32; I++ ) {
szLocal[I] = e_pPlayer->szName[I];
}
Now to print your name you can use
szLocal rather than
e_pPlayer->szName.
Soon I will add a function that does this for you.
It will accept an
extern pointer and return a local string that can be used to print text from your games.
L. Spiro