Hey,
I have a client sided app (no server involved) and during testing came across a couple issues regarding hacking.
There is a conceptual membership model and you’re a member if you have got days added to your account.
Doing some really trivial coding and using cheat engine you can modify the number of days you have on your account so in sense call it a membership hack.
To prevent this pragmatically is the following code acceptable?:
Current:
int days;
boolean isMember() {
return days > 0;
}
The new, updated method:
int days;
boolean member;
boolean isMember() { return member; }
void increment(int days) {
if (days <= 0) return;
this.days += days;
member = true;
}
void decrement(int days) {
if (days <= 0) return;
if ((this.days - days) > 0) {
this.days -= days;
} else {
this.days = 0;
member = false;
}
}
I don’t think people will be able to modify that boolean using any sort of memory hacking (near impossible, I think).
Is that type of coding style okay? Is there another way I should handle it?
Also in the case, you could change the member, what then? Create a thread that automatically rolls back changes that have been unintentionally performed? (seems bad, but a solution). If it was Java, what’s stopping reflection clients calling the increment method themselves (unless I do some clever redesign)?
All of these mentioned have failed me from going into production.
And any other general tips would be nice.
Thanks!