top kek. i am playing this old japanese game from 2001 https://en.wikipedia.org/wiki/Zwei:_The_Arges_Adventure
the devs ciphered the stats to prevent the use of CheatEngine or an action replay.
every time a stats is modified, the integer bytes are shuffled randomly. the shuffling key is then stored in memory right after the integer.
something like this
typedef struct
{
u8 bytes[4];
u8 key;
} shuffled;
void set_shuffled(shuffled *s, int val)
{
s->key = rand() & 0xFF;
val <<= 2;
s->bytes[ emoney.key - 1 % 4 ] = val & 0xFF;
s->bytes[ emoney.key - 2 % 4 ] = (val >> 8) & 0xFF;
s->bytes[ emoney.key % 4 ] = (val >> 16) & 0xFF;
s->bytes[ emoney.key + 1 % 4 ] = (val >> 24) & 0xFF;
}
int get_shuffled(shuffled *s)
{
int val = 0;
val = s->bytes[ emoney.key - 1 % 4 ];
val |= s->bytes[ emoney.key - 2 % 4 ] << 8;
val |= s->bytes[ emoney.key % 4 ] << 16;
val |= s->bytes[ emoney.key + 1 % 4 ] << 24;
val >>= 2;
return val;
}
To increase money, for example, you would do
set_shuffled(money, get_shuffled(money) + 100);
please don't do this.