home *** CD-ROM | disk | FTP | other *** search
/ Computer Installation Guide - Dragon Clan Series / CD2.iso / ZIP / WWPACK / WWP304 / PASCAL / WWPATCH.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1996-01-05  |  2.0 KB  |  69 lines

  1. UNIT WWPatch;
  2.  
  3. (*
  4. This Unit does simple self-checking of a WWPacked program. In your
  5. applikation you just need to check whether WWPacked is true or not.
  6.  
  7. Additionally the file date/time/size will be stored in the EXE-file
  8. and you will get WWPacked=false, if the file is packed and either
  9. date, time or size are not in its original state (may be useful for
  10. an easy manipulation detection).
  11.  
  12. For that you may provide a version number in your program to the
  13. function "WWPatch" and and the file's time will be set accordingly.
  14. The compiled and packed file has to be started at least once to get
  15. proper results, for performing the self-modification of the EXE-file,
  16. but I guess you will do this anyway for a final check.
  17.  
  18. (C) 1995 by Thomas Moenkemeier (thm@vgasoft.com). May be freely used
  19. and distributed freely. No warranty, either written or implied, is
  20. made as to the accuracy and usability of this code product. Use at
  21. your own risk !  Batteries not included. Pepperoni and extra cheese
  22. available for an additional charge.
  23. *)
  24.  
  25.  
  26. INTERFACE
  27.  
  28.  
  29. FUNCTION WWPacked(VerMajor,VerMinor:BYTE):BOOLEAN;
  30.  
  31.  
  32. IMPLEMENTATION
  33.  
  34. USES DOS;
  35.  
  36. VAR WWP_File:FILE;
  37.     WWP_Time:DateTime;
  38.     WWP_Size,WWP_Date,WWP_Merk:LONGINT;
  39.  
  40. FUNCTION WWPacked(VerMajor,VerMinor:BYTE):BOOLEAN;
  41. BEGIN
  42.   FileMode:=0;
  43.   ASSIGN(WWP_File,ParamStr(0));
  44.   RESET(WWP_File,1);
  45.   WWP_Size:=FileSize(WWP_File);
  46.   GetFTime(WWP_File,WWP_Date);
  47.   Seek(WWP_File,$1C);
  48.   BlockRead(WWP_File,WWP_Merk,4);
  49.   IF (WWP_Merk=542136151) THEN BEGIN     {patch fresh WWPacked-file !}
  50.     CLOSE(WWP_File);
  51.     UnPackTime(WWP_Date,WWP_Time);
  52.     WWP_Time.Hour:=VerMajor;
  53.     WWP_Time.Min:=VerMinor;
  54.     WWP_Time.Sec:=0;
  55.     PackTime(WWP_Time,WWP_Date);
  56.     FileMode:=2;
  57.     RESET(WWP_File,1);
  58.     Seek(WWP_File,$1C);
  59.     WWP_Merk:=WWP_Date*WWP_Size;
  60.     BlockWrite(WWP_File,WWP_Merk,4);
  61.     SetFTime(WWP_File,WWP_Date);
  62.   END;
  63.   WWPacked:=(WWP_Merk=WWP_Date*WWP_Size);
  64.   CLOSE(WWP_File);
  65. END;
  66.  
  67. BEGIN
  68. END.
  69.