Page 1 of 1
Program to check itself.
Posted: Sun Mar 09, 2025 9:51 pm
by matalog
Is there a way to get a program to check itself, before successfully working to see if it has been changed fromi its original form in any way? The plan would be for it not to work in the case that it has been altered.
For example, if I wanted to do this to an image, I might just carry out a simple addition of all bytes mod 65536, and then there would be a checksum with assumably a 65536 to 1 chance of working correctly if the program had been altered.
I would have read the bytes of the image one by one, but i'm not sure about how I could get a program to do this to itself. Any ideas?
Re: Program to check itself.
Posted: Sun Mar 09, 2025 10:03 pm
by miso
I never did such thing, so just guessing:
You can add an empty datasection (filled with $00-s) in the range of your checksum, and later fill it with a real one and recompile. That way the size of the executable won't change. I'm not sure though, where will that data will be placed, but I guess it will be at the end of the exe.
Must be important, or else it does not worth the hassle. (it still will take only one conditional jump to change in the machine code to jump to start when your condition NOT true, so not a real defense, but might be good checking against viruses.)
Another solution can be to add a launcher, that tests your exe, and if ok launches it with a proper program parameter or make a handshake or something.
Re: Program to check itself.
Posted: Sun Mar 09, 2025 10:51 pm
by Caronte3D
I ever use a launcher and the procedure: FileFingerprint()
It works very well and detects even a simple bit modification.
Re: Program to check itself.
Posted: Sun Mar 09, 2025 11:41 pm
by BarryG
matalog wrote: Sun Mar 09, 2025 9:51 pmIs there a way to get a program to check itself, before successfully working to see if it has been changed fromi its original form in any way?
For Windows exes, this works fantastic ->
https://www.purebasic.fr/english/viewto ... 98#p559198
The best thing is you don't need to calculate anything, because Windows does it all.