Page 1 of 1

How to CRC32 check own executable?

Posted: Sat Aug 21, 2010 11:52 am
by c4s
I'm a little bit confused right now how to manage this. I mean when I use something like this:

Code: Select all

If CRC32FileFingerprint(ProgramFilename()) = $00000000  ; $F6C91970
	MessageRequester("CRC32 Check", "Correct!")
Else
	MessageRequester("CRC32 Check", "Incorrect!")
EndIf
...The check is obviously incorrect but when I try to add the correct checksum of this code the real checksum is different again (also obvious because the code has changed).

Does anyone have an idea how this is usually done?

Re: How to CRC32 check own executable?

Posted: Sat Aug 21, 2010 12:28 pm
by DarkDragon
You need to safe the correct checksum somewhere different. E.g. append it to the end of your file or make a placeholder and ignore it while calculating the checksum.

Re: How to CRC32 check own executable?

Posted: Sat Aug 21, 2010 1:32 pm
by freak

Re: How to CRC32 check own executable?

Posted: Sat Aug 21, 2010 8:39 pm
by c4s
@DarkDragon
At first I didn't fully understand what you mean with placeholder but freak's code clears it up now.

@freak
Thanks, looks perfect!

Re: How to CRC32 check own executable?

Posted: Mon Aug 23, 2010 4:13 pm
by Joakim Christiansen
c4s wrote:Does anyone have an idea how this is usually done?
The simplest way I know of:
http://www.purebasic.fr/english/viewtop ... 12&t=26369