How to CRC32 check own executable?

Everything else that doesn't fall into one of the other PB categories.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

How to CRC32 check own executable?

Post 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?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
DarkDragon
Addict
Addict
Posts: 2348
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: How to CRC32 check own executable?

Post 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.
bye,
Daniel
freak
PureBasic Team
PureBasic Team
Posts: 5962
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Re: How to CRC32 check own executable?

Post by freak »

quidquid Latine dictum sit altum videtur
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: How to CRC32 check own executable?

Post 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!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Re: How to CRC32 check own executable?

Post 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
I like logic, hence I dislike humans but love computers.
Post Reply