home *** CD-ROM | disk | FTP | other *** search
- UNIT WWPatch;
-
- (*
- This Unit does simple self-checking of a WWPacked program. In your
- applikation you just need to check whether WWPacked is true or not.
-
- Additionally the file date/time/size will be stored in the EXE-file
- and you will get WWPacked=false, if the file is packed and either
- date, time or size are not in its original state (may be useful for
- an easy manipulation detection).
-
- For that you may provide a version number in your program to the
- function "WWPatch" and and the file's time will be set accordingly.
- The compiled and packed file has to be started at least once to get
- proper results, for performing the self-modification of the EXE-file,
- but I guess you will do this anyway for a final check.
-
- (C) 1995 by Thomas Moenkemeier (thm@vgasoft.com). May be freely used
- and distributed freely. No warranty, either written or implied, is
- made as to the accuracy and usability of this code product. Use at
- your own risk ! Batteries not included. Pepperoni and extra cheese
- available for an additional charge.
- *)
-
-
- INTERFACE
-
-
- FUNCTION WWPacked(VerMajor,VerMinor:BYTE):BOOLEAN;
-
-
- IMPLEMENTATION
-
- USES DOS;
-
- VAR WWP_File:FILE;
- WWP_Time:DateTime;
- WWP_Size,WWP_Date,WWP_Merk:LONGINT;
-
- FUNCTION WWPacked(VerMajor,VerMinor:BYTE):BOOLEAN;
- BEGIN
- FileMode:=0;
- ASSIGN(WWP_File,ParamStr(0));
- RESET(WWP_File,1);
- WWP_Size:=FileSize(WWP_File);
- GetFTime(WWP_File,WWP_Date);
- Seek(WWP_File,$1C);
- BlockRead(WWP_File,WWP_Merk,4);
- IF (WWP_Merk=542136151) THEN BEGIN {patch fresh WWPacked-file !}
- CLOSE(WWP_File);
- UnPackTime(WWP_Date,WWP_Time);
- WWP_Time.Hour:=VerMajor;
- WWP_Time.Min:=VerMinor;
- WWP_Time.Sec:=0;
- PackTime(WWP_Time,WWP_Date);
- FileMode:=2;
- RESET(WWP_File,1);
- Seek(WWP_File,$1C);
- WWP_Merk:=WWP_Date*WWP_Size;
- BlockWrite(WWP_File,WWP_Merk,4);
- SetFTime(WWP_File,WWP_Date);
- END;
- WWPacked:=(WWP_Merk=WWP_Date*WWP_Size);
- CLOSE(WWP_File);
- END;
-
- BEGIN
- END.
-