		IFND	SPIRIT_I
SPIRIT_I	SET	1
**
** $VER: spirit.i 1.4 (9.5.98)
**
** include file for spirit
**
** Copyright (C) 1998 by Sunbeam\dc
**

	IFND	EXEC_TYPES_I
	INCLUDE	"exec/types.i"
	ENDC
	IFND	UTILITY_TAGITEM_I
	INCLUDE	"utility/tagitem.i"
	ENDC

** KeyBase Structure ********************************************************************
**
** This structure are pointed in A5.

	STRUCTURE	KeyBase,0
	  APTR		kb_Name		;Name: contents
	  APTR		kb_Serial	;Serial: contents
	  APTR		kb_Street	;Street: contents
	  APTR		kb_City		;ZIP/City: contents
	  APTR		kb_Country	;Country: contents
	  APTR		kb_Computer	;Computer: contents
	  APTR		kb_eMail	;eMail: contents
	  APTR		kb_Phone	;Phone: contents
	  ULONG		kb_SerialHEX	;see below
	  ULONG		kb_SerialDEC	;see below
	  APTR		kb_KeyBuffer	;allocated keyfile buffer
	  APTR		kb_TempBuffer	;allocated temp buffer
          FPTR		kb_SaveFile	;file save function
	LABEL		kb_SIZEOF

** SerialHEX/DEC:
** Here you can find the converted serial number.
** For example the user have entered "12345":
** kb_Serial includes the STRPTR, kb_SerialDEC includes $12345
** kb_SerialHEX includes $3039

** Patch Structure **********************************************************************
**
** for external patches

	STRUCTURE	pchhd,0
	  ULONG		ph_ID		;patch header ID
	  ULONG		ph_FileLen	;filelength of the compared program
	  ULONG		ph_NumPatches	;number of stored patches
	  ULONG		ph_ChkSum1	;original file checksum
	  ULONG		ph_ChkSum2	;patched file checksum
	  ;pchdat starts here
	LABEL		ph_SIZEOF

	STRUCTURE	pchdat,0
	  UBYTE		pd_ID		;security ID
	  ULONG		pd_Offset	;offset in file
	  UBYTE		pd_OrigByte	;original byte
	  UBYTE		pd_PatchByte	;patched byte
	LABEL		pd_SIZEOF

PH_ID		EQU	"SPCH"		;normal patch file
PH_IDATT	EQU	"SPC2"		;+attach file
PD_ID		EQU	$44		;pd_ID
PD_ENDID	EQU	$55		;pd_ID (no more entries)

** file structure:
**  struct header
**  struct data*ph_NumPatches
**  pd_ID=PH_ENDID
**  str 'cracker' until 0
**  str 'group' until 0
**  str 'prg' until 0
**  str 'prg_ver' until 0
**  str 'date' until 0
**-end or if PH_IDATT
**  ulong attach len
**  ulong attach sum
**  str 'path+name' until 0
**  attached file

** Flags for SPT_Flags ******************************************************************

	BITDEF	FLG,HEXSER,0		;allow in serial hex chars. (0-F)
	BITDEF	FLG,RNDFILL,1		;fill keyfile with random bytes
	BITDEF	FLG,RNDFILLTMP,2	;fill tempbuffer with random bytes
	BITDEF	FLG,CHECKEMPTY,3	;check for empty strings.
					;an empty string or only spaces
					;are not allowed!
	BITDEF	FLG,DYNAMIC,4		;set this flag for dynamic key lengths
	BITDEF	FLG,CRYPTED,5		;will set auto. from the crypter!

** Global Flags *************************************************************************

	ENUM	TAG_USER
	EITEM	SPT_Name		;name of the program
	EITEM	SPT_Version		;program version
	EITEM	SPT_Cracker		;name of the cracker
	EITEM	SPT_Group		;group of the cracker
	EITEM	SPT_Date		;creation date (dd.mm.yy)
	EITEM	SPT_KeyLength		;length of the keyfile buffer
	EITEM	SPT_KeyName		;keyfile name w/o path
	EITEM	SPT_KeyPath		;the path to the dest
	EITEM	SPT_Encrypt		;pointer to your encrypt routine
	EITEM	SPT_TempBuff		;length of the temp buffer or NULL for none
	EITEM	SPT_Flags		;see above
	EITEM	SPT_KeyAnno		;announcement after key saving (requester)
	EITEM	SPT_NameLen		;length of the max. Name: or NULL -> Disabled
	EITEM	SPT_SerialLen		;^^^
	EITEM	SPT_StreetLen		;^^^
	EITEM	SPT_CityLen		;^^^
	EITEM	SPT_CountryLen		;^^^
	EITEM	SPT_ComputerLen		;^^^
	EITEM	SPT_eMailLen		;^^^
	EITEM	SPT_PhoneLen		;^^^
	EITEM	SPT_EncryptLen		;length of your encrypt code
					;for the external keymodule crypter.
					;see in example.asm!

** Misc Stuff ***************************************************************************
**
** This Macro-Header must be in every keymodule!
** example:
**       KEYHEAD Tags
**Tags:  dc.l    SPT_Name,Name
**       dc.l    TAG_DONE
**

KEYHEAD	MACRO	;tags
	bra.s	.sc
	dc.b	"SPIRITKM"
	dc.l	\1

.sc	move.l	4.w,a6
	lea	.dn(pc),a1
	moveq	#0,d0
	jsr	-552(a6)
	tst.l	d0
	beq.s	.nd
	move.l	d0,a6
	jsr	-60(a6)
	move.l	d0,d1
	beq.s	.cd
	lea	.st(pc),a0
	move.l	a0,d2
	moveq	#.stl,d3
	jsr	-48(a6)
.cd	move.l	a6,a1
	move.l	4.w,a6
	jsr	-414(a6)
.nd	moveq	#20,d0
	rts

.st	dc.b	"This is not an executable file.",10
	dc.b	"It's a keymodule for Spirit.",10,0
.stl	EQU	*-.st
.dn	dc.b	"dos.library",0
	cnop	0,2
	ENDM

** Return Codes ***********************************************************

RETURN_NOERR	EQU	0	;keyfile generated
RETURN_ERR	EQU	-1	;keyfile not generated

***************************************************************************

	ENDC	;SPIRIT_I