I have a string literal in my program, I am trying to create an amateur checksum to ensure that the string literal has not been replaced in a portable executable.
To do this, I create a string literal hash and save it as an integer literal in the program. Now I have two literals: one for the string and one for the hash.
In my code, I implement a checksum using a function that hashes a string literal in the same way, I create a new runtime hash and check that hash for a hash literal.
The problem is that with compiler optimization, it can pre-compute the run-time hash, and then im check the hash literal against the hash literal, and the checksum will always return true.
So, I'm looking for a trick to make the compiler think that a string literal is a dynamic string that can be anything, so it won’t do constant bending optimization during the execution of the hash, and my code will work correctly.
source
share