Hmm, let me try to be a little clearer. In my theoretical example; I have a game which contains two players.
1 2
Memory Location: 1 2 3 4 5 6 7 8 9 10 11 12 13-32 33 34
Member: health mana experience playername ID
1 2
Memory Location: 35 36 37 38 39 40 41 42 43 44 45 46 47-66 67 68
Member: health mana experience playername ID
Now, pretend I inject (gain access to game's address space) this code to execute:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
struct Player
{
int health, mana, experience;
char playername[20];
short ID;
};
void EditHealth(int PlayerNumber) // can be 1 or 2 since there are only 2 players
{
if ( PlayerNumber != 1 || 2 )
return;
Player* pPlayer = (Player*)(1 * (sizeof(Player)*PlayerNumber));
pPlayer->health = 9001;
pPlayer->experience = 1000;
// ...
}
afaik there's no way to do this safely with a simple struct. Especially since the struct is aligned oddly (typically they're padded to multiples of 4 bytes, but apparently this struct isn't).