Unit SFXgbls

*****************************************************************) (* Copyright 1997, Microchip Systems / Carl Bunton *) (* Email: Twojags@cris.com *) (* Web-page: http://www.concentric.net/~twojags *) (* *) (* This program was written in Delphi 2 because version 2 *) //## this release in delphi3 (* compiles a much smaller executable using the windows api. It *) (* should be fully compatible with Delphi 3, but will produce a *) (* noticable increase of size in the final compiled program. *) (* *) (*MODIFIED by M. Stephany mirbir.st@t-online.de 12/28/97-01/04/98*) (* for some special purposes; modified lines are marked (##) *) (******************************************************************) // bug with data_descriptor fixes in function readheader by mst 01/23/98. thanks to eric !

Classes

Functions

decrypt_byte - --------------------------------------------------------------------------*) (* Return the next byte in the pseudo-random sequence
decrypt_pw - ## added paramter lb to fill more than one listbox with the archive's contents

--------------------------------------------------------------------------
Make_CRC32Table - --------------------------------------------------------------------------
ProcessArchive - ## the getarchiveoffset has been removed since this value is calculated in dialogsel.
ReadHeader - --------------------------------------------------------------------------
seedk - --------------------------------------------------------------------------*) (* Initialize the encryption keys and the random header according to the given password.
UDK - --------------------------------------------------------------------------*) (* Update the encryption keys with the next byte of plain text
UpdC32 - --------------------------------------------------------------------------

Types

pCRC32Table
TCRC32
TLocal

Constants

CRC_MASK
RAND_HEAD_LEN
WSIZE

Variables

Bytes_To_Go
CRC32Table
Crc32Val
Header
HEADER_SIGNATURE
InFile
key
OutFile


Functions


FUNCTION decrypt_byte: INTEGER;

--------------------------------------------------------------------------*) (* Return the next byte in the pseudo-random sequence

FUNCTION decrypt_pw(Encrypt_Head: PCHAR; EncHead_len: BYTE; BitFlag: WORD; CRC, FileDate: LONGINT; password: STRING): BOOLEAN;

## added paramter lb to fill more than one listbox with the archive's contents

--------------------------------------------------------------------------


PROCEDURE Make_CRC32Table;

--------------------------------------------------------------------------

PROCEDURE ProcessArchive(DlgWin: hWnd; lb:integer; FillListBox: BOOLEAN);

## the getarchiveoffset has been removed since this value is calculated in dialogsel.pas

--------------------------------------------------------------------------


FUNCTION ReadHeader: BOOLEAN;

--------------------------------------------------------------------------

PROCEDURE seedk(passwd: STRING);

--------------------------------------------------------------------------*) (* Initialize the encryption keys and the random header according to the given password.

PROCEDURE UDK(c: byte);

--------------------------------------------------------------------------*) (* Update the encryption keys with the next byte of plain text

FUNCTION UpdC32(Octet: byte; Crc: LongInt) : LongInt;

--------------------------------------------------------------------------

Types


pCRC32Table        = ^TCRC32

TCRC32             = ARRAY[0..256] OF LONGINT;

TLocal = record
SignAtr : LONGINT;
VerNum : WORD;
BitFlag : WORD;
CompressType : WORD;
FileDate : LONGINT;
crc32 : LONGINT;
PackedSize : LONGINT;
UnpackedSize : LONGINT;
FilenameLen : WORD;
ExtraFieldLen : WORD;
end;

Constants

CRC_MASK = $FFFFFFFF

RAND_HEAD_LEN = 12

window size--must be a power OF two, and at least 32k

WSIZE = 32768


Variables

Bytes_To_Go : LONGINT

CRC32Table : pCRC32Table

Crc32Val : LONGINT

Header : TLocal

HEADER_SIGNATURE : LongInt

InFile : THandle

key : ARRAY[0..2] OF LONGINT

Running CRC (32 bit) value

OutFile : THandle