		IFND	SPIRIT_I
SPIRIT_I	SET	1
**
** $VER: spirit.i 1.5 (23.7.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 ********************************************************************

	STRUCTURE	KeyBase,0
	  APTR		kb_Name		;Name: (STRPTR)
	  APTR		kb_Serial	;Serial: (STRPTR)
	  APTR		kb_Street	;Street: (STRPTR)
	  APTR		kb_City		;ZIP/City: (STRPTR)
	  APTR		kb_Country	;Country: (STRPTR)
	  APTR		kb_Computer	;Computer: (STRPTR)
	  APTR		kb_eMail	;eMail: (STRPTR)
	  APTR		kb_Phone	;Phone: (STRPTR)
	  ULONG		kb_SerialHEX	;see below
	  ULONG		kb_SerialDEC	;see below
	  APTR		kb_KeyBuffer	;pointer to the keyfile buffer
	  APTR		kb_TempBuffer	;pointer to temp buffer
          FPTR		kb_SaveFile	;file save function
	  APTR		kb_Date		;current date in format dd.mm.yy (STRPTR)
	  APTR		kb_Time		;current system time in format hh:mm:ss (STRPTR)
	LABEL		kb_SIZEOF

** SerialHEX/DEC:
** Here you can find the converted serial number.
** For example the user have keyboarded "12345":
** kb_Serial is the STRPTR, kb_SerialDEC includes $12345
** kb_SerialHEX includes $3039
** Since V1.4 I abort the serial converter on an overflow.

** Patch File Structure *****************************************************************

	STRUCTURE	pchhd,0
	  ULONG		ph_ID		;patch header ID (PH_ID,PH_IDATT)
	  ULONG		ph_FileLen	;filelength of the compared file
	  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 (PD_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 pchhd
**  struct pchdat*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

** SPT_Flags 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	;no empty string gadgets, or spaces
	BITDEF	FLG,DYNAMIC,4		;keyfile have a dynamic length
	BITDEF	FLG,CRYPTED,5		;do not set this!

** KeyModule Tags ***********************************************************************

	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		;keymodule creation date (dd.mm.yy)
	EITEM	SPT_KeyLength		;length of the keyfile buffer (kb_KeyBuffer)
	EITEM	SPT_KeyName		;keyfile name only. without the path
	EITEM	SPT_KeyPath		;the complete path to the keyfile dir
	EITEM	SPT_Encrypt		;pointer to your encrypt routine
	EITEM	SPT_TempBuff		;length of the temp buffer (kb_TempBuffer)
	EITEM	SPT_Flags		;see above
	EITEM	SPT_Anno		;announcement before key saving or for ABORT
	EITEM	SPT_NameLen		;length of the Name: string gadget
	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 code (for the keymod crypter)
	EITEM	SPT_SpiritVer		;set SPIRITVERSION
	EITEM	SPT_CPU			;set the needed CPU type


SPIRITVERSION	EQU	$00010005	;actual spirit version (SPT_SpiritVer)

** SPT_CPU Types ************************************************************************

CPU_68000       EQU     0               ;not really required
CPU_68010	EQU	1
CPU_68020	EQU	2
CPU_68030	EQU	3
CPU_68040	EQU	4
CPU_68060	EQU	8

** 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	#.dn-.st,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
.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
RETURN_ABORT	EQU	-2	;aborted (no fail requester but a SPT_Anno)
RETURN_SERIAL   EQU	-3	;special for serial#gen

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

	ENDC	;SPIRIT_I