 Introduction

Introduction

TFileCheckSumComp is freeware Delphi component which allow to check program exe file for changes and if found, use Windows installer service to reinstall program.
Copyright (c) 2002 Ainars Skangals
Http://balder.prohosting.com/ainars/
Email: ainarssk@email.com
Version 1.0
This component is provided "as is" without warranty of any kind,
either expressed or implied. Use at your own risk!

Warning! EXE file modification with provided sample program can destroy application. Use it only to modify your own compiled program files!


 Component workings

Component workings

Win32 program files can have file checksum in the EXE file header. Unfortunately Delphi compiler leave 0 insted of the real file checksum. This can be easy corrected simply writing value in the file with HEX editor or special program.

Windows function MapFileAndCheckSum residing in the ImageHlp.dll file allow to easy calculate any file checksum and also extract checksum value from Windows executable files.

TFileCheckSumComp component function CheckFile calls function MapFileAndCheckSum and if file checksum written in the file header is not zero and not equal to the calculated file checksum, calls Windows Installer service to reinstall the product. Msiexec command executed is "msiexec /fa [GUID]". Warning! With this command all the installation files will be replaced!


 Component usage

Component usage

Following steps are needed to successfully use TFileCheckSumComp:

1) Create installation project or Windows installer package containing product GUID.

2) Put the TFileCheckSumComp on the application main form and set its GUID property to the package Product code GUID - now component will be able to tell which package to reinstall.

3) Compile the application.

4) Set the CheckSum field of the IMAGE_OPTIONAL_HEADER in the EXE file to its real file checksum obtained with MapFileAndCheckSum function. Remember, that each file compilation can change file checksum and always set CheckSum field to zero.

5) Check if the file can be successfully run. Don't run it from Delphi IDE!

6) Build the installation package containing exe file with correct checksum in the header.

7) Install the program using Windows Installer service.


 Zip file content

Zip file content

csc.msi - Demo installation package for exe file modification tests, contains compiled test project exe file;

CSComp.chm - This file;

TCSComp.pas - TFileCheckSumComp component source file;

TCSComp.res - TFileCheckSumComp component resource file;

Unit1.dfm - Demo project form file;

Unit1.pas - Demo project unit source file;

Project1.dof - Demo project options file;

Project1.dpr - Demo project file;

Project1.res - Demo project resource file.