EXE file checking its own checksum
-
Errr......No. You know us young'uns. 3 weeks is , like, forever,dude!. :rolleyes:
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone
I do have to admit that 1979 doesn't seem that long ago :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
-
-
Is it possible to create an EXE file checking its own checksum? This is the structure of the program:
//computing the checksum
//...
//...
//checking the checksum
if (checksum == AD435G)
{
//OK message box
}
else
{
//not OK message box
}After compiling it, we compute the checksum of the EXE file (using some external application). We put it in
if
condition and compile the EXE one more time. However, since we changed the code, the EXE file is different, so it's checksum is different. Therefore, we can never see the OK message box. What do you think about it? I know that there are installers that check if they were downloaded correctly, but I do not know how they work. You're so cute when you're frustrated. --from 'PDA' by Interpolsuppose that you have three numbers like this: long[] check = {0x1234567812345678, 0x0, 0x1234567812345678}; //compute checksum //do not include a code block starting with 0x1234567812345678 //and ending with 0x1234567812345678. if (checksum == check[1]) { //Ok } else { //Not ok } Then you need a small program calculate the checksum in the above way and insert the reslult into the exe between the two 0x1234567812345678 numbers. What you need to be absolutely sure of is that the sequence 0x1234567812345678 is not in the exe at some other place, chosing a longer sequence makes that less likely but not certain. Also note that this scheme does not protect against external tampering, which might be the reason for having the checksum in the first place. But it should work for ensuring correct download and it also make it possible release patches.
-
This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol
-
This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol
Then it's customary to put the title as "This is not a programming question". That way, even if it is one, the natives can't do anything about it. :rolleyes:;)
"if you vote me down, I shall become more powerful than you can possibly imagine" - Michael P. Butler. Support Bone
-
Is it possible to create an EXE file checking its own checksum? This is the structure of the program:
//computing the checksum
//...
//...
//checking the checksum
if (checksum == AD435G)
{
//OK message box
}
else
{
//not OK message box
}After compiling it, we compute the checksum of the EXE file (using some external application). We put it in
if
condition and compile the EXE one more time. However, since we changed the code, the EXE file is different, so it's checksum is different. Therefore, we can never see the OK message box. What do you think about it? I know that there are installers that check if they were downloaded correctly, but I do not know how they work. You're so cute when you're frustrated. --from 'PDA' by InterpolOk, everyone else has yelled at you. Now, in the spirit of the holiday season (Peace on Earth, Good Will to People-Who-Post-Programming-Questions-In-The-Lounge), here's an answer to your question. Yes, you can have an .EXE verify it's own checksum. The key is not have the checksum in the .EXE's code itself. You do this by having the verification code look for a final checksum of zero. Your external application then places the negative of the actual checksum at a safe location in the file (typically, append it to the end of the file). I hope this helps, and Merry Christmas!
Software Zen:
delete this;
-
suppose that you have three numbers like this: long[] check = {0x1234567812345678, 0x0, 0x1234567812345678}; //compute checksum //do not include a code block starting with 0x1234567812345678 //and ending with 0x1234567812345678. if (checksum == check[1]) { //Ok } else { //Not ok } Then you need a small program calculate the checksum in the above way and insert the reslult into the exe between the two 0x1234567812345678 numbers. What you need to be absolutely sure of is that the sequence 0x1234567812345678 is not in the exe at some other place, chosing a longer sequence makes that less likely but not certain. Also note that this scheme does not protect against external tampering, which might be the reason for having the checksum in the first place. But it should work for ensuring correct download and it also make it possible release patches.
-
This is NOT a programming questions (I am not asking HOW to do it). This is more a philosophical problem - I am wondering if it is possible at all. You're so cute when you're frustrated. --from 'PDA' by Interpol
There are two posibilities. One is to keep re-calculating the new file, till it stop to a number. The second is to keep re-calculating the new file, forever. ...or till you see the same number twice and quit. or adjust a not used byte and try again. till you get bored. ;P Uh... ya, i forgot. You can also ignore the position where you store the checksum, when you calculate the checksum, but of course this is an obvious old-fasion way to go. :rolleyes: - - - - - - - - - - - - - - - - - - Memory leaks is the price we pay \0 01234567890123456789012345678901234
-
:-O
Software Zen:
delete this;
-
I do have to admit that 1979 doesn't seem that long ago :) Rob Manderson http://www.mindprobes.net **Paul Watson wrote:**What sense would you most dislike loosing? Ian Darling replied. Telepathy Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
Rob Manderson wrote: 1979 doesn't seem that long ago Wasn't it just last week?:confused: "Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
-
Nick Seng wrote: Woohoo!! I've been waiting a while to use this. :laugh: Excellent!
Look at the world about you and trust to your own convictions. - Ansel Adams
Meg's World - Blog Photography