home *** CD-ROM | disk | FTP | other *** search
- { CRC.PAS 1.01 Copyright (c) 1995-96 by Piotr Warezak and Rafal Wierzbicki
-
- This program demonstrates how to use WWP_CRC unit (WWP_CRC.TPU file)
- and CHECK_IF_PACKED function (CHK_WWP.PAS file).
-
- Compiled version of this program is a part of the WWPACK distribution
- package (CRC.EXE file).
-
- This program is public domain and may be freely distributed.
-
- ==========================================================================
-
- Incompatibility problems please report to: awarezak@krysia.uni.lodz.pl
- or to any official WWPACK distribution site.
-
- ========================================================================== }
-
- {$A+,B-,D-,E-,F-,G-,I-,L-,N-,O-,P-,Q-,R-,S-,T-,V-,X-} {create the smallest code}
- {$M 16384,0,655360}
-
- program crccheck;
- uses crt,dos,wwp_crc; {use WWP_CRC module}
- var header:array [1..16] of word;
- directory:array[1..201] of string[12];
- f:file;
- count:word;
- dir:searchrec;
- path:dirstr;
- ext:extstr;
- nazwa:namestr;
- k,ver:word;
-
- procedure read_directory; {read directory}
- var help_string:string[12]; {and store filenames}
- i,j:word; {to the array}
- begin
- findfirst(paramstr(1),$27,dir);count:=0;
- while (doserror=0) and (count<201) do {search for files}
- begin
- inc(count);
- directory[count]:=dir.name;
- findnext(dir);
- end;
- if count>200 then {more than 200 files?}
- begin
- writeln('Error: too many files matching to the filespec.');
- halt;
- end;
- if count=0 then {no files found?}
- begin
- writeln('File not found.');halt;
- end;
- if count>1 then {sort files}
- for i:=1 to count-1 do
- for j:=i+1 to count do
- if directory[i]<directory[j] then
- begin
- help_string:=directory[j];
- directory[j]:=directory[i];
- directory[i]:=help_string;
- end;
- end;
-
- {$I chk_wwp.pas} {use CHECK_IF_PACKED function}
-
- begin
- writeln('■ CRC_Check 1.01 for EXE files packed with WWPACK 3.03/3.04 ■');
- writeln('■ Written by Piotr Warezak and Rafal Wierzbicki ■');
- writeln('■ This program is public domain and may be freely distributed ■');
- writeln;
- if paramstr(1)='' then
- begin
- writeln('Usage: CRC filename.exe (paths and wildcards are allowed)');
- halt;
- end;
-
- filemode:=0;read_directory; {init: read directory}
- fsplit(paramstr(1),path,nazwa,ext); {init: check path}
- repeat
- assign(f,path+directory[count]);reset(f,1);k:=ioresult; {open file}
- if k=0 then
- begin
- ver:=255;
- if filesize(f)>32 then {check if WWPACKed}
- begin
- blockread(f,header[1],32);
- if (header[1]=23117) or (header[1]=19802) then ver:=check_if_packed(f);
- end;
- write(' ',directory[count]);
- gotoxy(20,wherey);
- if ((ver>17) and (ver<21)) or ((ver>21) and (ver<25)) then{check is packed with 'P','PP' or 'PU'}
- begin
- if check_crc(f)=0 then {check CRC (execute check_crc function from WWP_CRC unit}
- begin
- write('CRC: correct'); {CRC is OK!}
- gotoxy(1,wherey);writeln('√');
- end
- else
- begin
- write('Bad CRC!'); {Bad CRC!}
- gotoxy(1,wherey);writeln('!!!');
- end;
- end
- else
- begin {when not EXE or not WWPACKed}
- if ver=255 then writeln('This is not an EXE file')
- else
- begin
- write('The file isn''t packed with WWPACK ''P/PP/PU''');
- gotoxy(2,wherey);writeln('?');
- end;
- end;
- end
- else
- begin {when error while opening the file}
- write('- ',directory[count]);
- gotoxy(20,wherey);writeln('Error while reading.');
- end;
- close(f); {close file}
- dec(count); {and check the next one}
- until count=0;
- writeln('Finished.'); {finish!}
- end.