Board index » cppbuilder » Recognize size changes of exe (Application) - Repost !

Recognize size changes of exe (Application) - Repost !


2004-01-13 07:00:47 AM
cppbuilder77
hi dear builders,
last time I didn't get any replys..so I try again :-)
can someone tell me how its posible to check if Application->FileSize
has changed ? I need just something simple not CRC checking stuff..
Just want to know if there some bytes more in the Application..
can someone help me with that..?
Oren
 
 

Re:Recognize size changes of exe (Application) - Repost !

Oren,
It might help if you explained what you are trying to do. You want to find out in the
IDE that a newly generated exe is bigger or smaller than it was the last time you did
a build?
Or do you want your app itself to know how big it is?
What are you trying to do with the information?
Oren (Halvani.de) wrote:
Quote
hi dear builders,

last time I didn't get any replys..so I try again :-)

can someone tell me how its posible to check if Application->FileSize
has changed ? I need just something simple not CRC checking stuff..

Just want to know if there some bytes more in the Application..

can someone help me with that..?


Oren


 

Re:Recognize size changes of exe (Application) - Repost !

Quote
Or do you want your app itself to know how big it is?
thats what I need to do...
Quote
What are you trying to do with the information?
If FileSize was changing, than terminate the program via:
Application->Terminate( )
But how do I check the size of the running exe...?
I'll store the values in the Registry and than I compare them at the Form
OnShow Event...
Oren
 

{smallsort}

Re:Recognize size changes of exe (Application) - Repost !

"Oren (Halvani.de)" < XXXX@XXXXX.COM >wrote in message
Quote
If FileSize was changing, than terminate the program via:
Application->Terminate( )
But how do I check the size of the running exe...?
You would have to store the value somewhere on application shutdown, and
then read the value again on startup and compare it to the current size.
The tricky part is storing the value in a secure way that can't easily be
modified, though.
Alternatively, there are a number of third-party exe-related CRC
implementations that you can try using instead.
Quote
I'll store the values in the Registry and than I compare them
at the Form OnShow Event...
You could do that, but that would be very easy to circumvent if someone
wanted to do so. All they would have to do is alter your exe as desired and
then write the new file size to your Registry value, and your program would
never know what happened. Also, the OnShow event is too late, the
application is already initialized and running by that time. You would be
better off moving the code into the program's WinMain() function directly,
so that you can abort the application immediately if needed before anything
else is done.
CRC is a much better way to go. Actually, even better, you could encrypt
the exe itself using any number of third-party tools that prevent exactly
this scenerio, by compressing and encrypting the exe itself, and then
decompressing/decrypting the file at runtime when it is executed. If any
changes are made to the exe, it will fail to load at all.
Gambit
 

Re:Recognize size changes of exe (Application) - Repost !

Thanks Remy for your infos..
by the way to do got a snip to check the filesite o the
running exe..?
Oren
Quote
You could do that, but that would be very easy to circumvent if someone
wanted to do so. All they would have to do is alter your exe as desired
and
then write the new file size to your Registry value, and your program
would
never know what happened. Also, the OnShow event is too late, the
application is already initialized and running by that time. You would be
better off moving the code into the program's WinMain() function directly,
so that you can abort the application immediately if needed before
anything
else is done.

CRC is a much better way to go. Actually, even better, you could encrypt
the exe itself using any number of third-party tools that prevent exactly
this scenerio, by compressing and encrypting the exe itself, and then
decompressing/decrypting the file at runtime when it is executed. If any
changes are made to the exe, it will fail to load at all.
I hope UPX is a good choice for this..?
 

Re:Recognize size changes of exe (Application) - Repost !

"Oren (Halvani.de)" < XXXX@XXXXX.COM >wrote in message
Quote
by the way to do got a snip to check the filesite o
the running exe..?
The simpliest way is to use the FnidFirst() function, ie:
int iSize = 0;
TSearchRec sr;
if( FindFirst(Application->ExeName, faAnyFile, sr) == 0 )
{
iSize = sr.Size;
FindClose(sr);
}
// use iSize as needed...
Gambit
 

Re:Recognize size changes of exe (Application) - Repost !

thank you very much Remy :-)
Quote
int iSize = 0;

TSearchRec sr;
if( FindFirst(Application->ExeName, faAnyFile, sr) == 0 )
{
iSize = sr.Size;
FindClose(sr);
}