; AntiVirus  by  HEIKO RATH
;
;	-=>A very short hack to check and reset the 3 ResetPointers
;			(Cold-, Cool- and WarmCapture)
;
; Once upon a time I was sitting in front of my Amiga and inserted a new
; Public Domain Disk when suddenly a message in a red box apeared. The
; message was like this:
;
;	Something wonderful has happened. Your Amiga is alive !!!
;	A and even better ... Some of your Disks are infected by
;	a VIRUS !!! Another masterpiece of the Mega Mighty SCA !!
;
; At first I was shocked, but then I started to defeat the Virus from my
; Bootblocks. It is a rather harmless thing, the only damage it is able
; to do is to destroy/alter your bootblocks. But it is possible that another
; Virus might not be as harmless as the SCA-Virus. So I wrote a little toy to
; prevent my machine from being hurt by a resetresident Virus. The only
; thing it does is to check, report and reset your Resetpointers 'cause
; I think this is the usual way a Virus does it's dirty work. For the best
; results possible I use it in my startup-sequence & Shellstartup-sequence.
; This little program only works in the CLI environment. If all 3 vectors
; point to $00000000 then everything is OK (at least these are the default
; values). To force AntiVirus to clear the pointers enter "AntiVirus c".
;
; I used Asm68k and Blink6.7 to assemble and link it.
;
;		!!!!!!!!COPY ME I WANT TO TRAVEL!!!!!!!!
;
; This program is public domain. Feel free to copy and modify it. If you
; like it you can do one of the following things:
;
; 1.	absolutly nothing
; 2.	send me something I deserve:
;				money, yachts, beer, Marabu chocolate
; 3.	contact us
;
;				Heiko Rath
;				Raiffeisenstr.10a
;				D-6108 Weiterstadt
;				WEST GERMANY
;				Tel.06150-2658
;
;                                     or
;
;                          
;______  /          
;______\O                    - The Software Brewery - 
;      \\              		    
;       o            Sparkling, fresh software from W.-Germany
;                 
;     @@@@@	      Straight from the bar to your Amiga
;     |~~~|\        
;     | | |/        
;     |___|        With our regards to the Software Distillery
;
;Members are (listed alphabetically):
;Christian Balzer alias <CB>, Lattice C, user interfaces, beer addict. 
;Christof Bonnkirch, Aztec C, telecommunications, money adict.
;Heiko Rath alias <HR>, Assembler, ROM-Kernal stuff, Marabou addict. 
;Peter Stark alias PS, Lattice C, IO & utilities, WordStar addict.
;Ralf Woitinas alias RAF, Assembler, anything, Ray-Tracing addict.
;Torsten Wronski alias MM, Assembler, anything, girls addict.
;
;Beverages: Altenmuenster Brauer Bier, Urfraenkisches Landbier, Grohe Bock.
;
;Send exotic drinks, $$$$, comments, critizism, flames to:
;
;The Software Brewery
;Christian Balzer
;Im Wingertsberg 45
;D-6108 Weiterstadt
;West-Germany
;
;Our BBS "AmigaNode" isn't online yet. As soon as it becomes available, 
;you'll be the first to know :-).
;
;
;
; Thanks to Larry Phillips, (CIS - 76703,4322) for his binhexroutine!!! 
; Note to Leo Schwab: keep on developing display hacks!!!
;
; Remember:
;+--------------------------------------------------------------------+
; A clean, neat, and orderly work place is a sure sign for a sick mind  :-)
;+--------------------------------------------------------------------+
;

ExecBase	Equ	4

;
; Exec Offsets:
;
OpenLibrary	Equ	-552		;OpenLibrary (LibName,version)(a1,d0)
CloseLibrary	Equ	-414		;CloseLibrary (Library)(a1)
ColdCapture	Equ	$2a
CoolCapture	Equ	$2e
WarmCapture	Equ	$32

;
; DOS Offsets:
;
OutPut		Equ	-60		;OutPut ()
Write		Equ	-48		;Write (file,buffer,length)(d1,d2,d3)

run:
	SUBQ.W	#$1,D0				;Byte-count -1
	BEQ.S	OpenDos				;no Parameters? -=> OpenDos

search:
	CMPI.B	#$20,(A0)+			;search for argument
	BNE.S	found				;-=>found
	DBF	D0,search			;
	BRA.S	OpenDos				;not found

found:
	MOVE.B	-(A0),D0			;move argument to d0
	ANDI.B	#$DF,D0				;convert 'c'-=> 'C'
	CMPI.B	#$43,D0				;is it 'C'?
	BNE.S	OpenDos				;no -=> OpenDos
	MOVE.L	D0,Flag				;set Flag

OpenDos:
	MOVEA.L	ExecBase,A6			;Execaddress to a6
	MOVEA.L	#DOSNAME,A1			;Librarynamepointer to a1
	MOVEQ.L	#$0,D0				;any version
	JSR	OpenLibrary(A6)			;try to open DOS-Library
	TST.L	D0				;is d0 = NULL?
	BEQ	ErrorExit			;exit if call wasn't successfull

	MOVE.L	D0,DOSBase			;save DOSBasepointer
	MOVEA.L	D0,A6				;move DOSBasepointer to a6
	JSR	OutPut(A6)			;identify the initial output handle
	MOVE.L	D0,stdout			;save stdout

	MOVEA.L	ExecBase,A6			;Execaddress to a6
	MOVE.L	ColdCapture(A6),D0		;ColdCapture to d0
	MOVEA.L	#COLD,A0			;#COLD to a0
	BSR	binhex				;convert Hex to ASCII -=> COLD
	MOVE.L	CoolCapture(A6),D0		;CoolCapture to d0
	MOVEA.L	#COOL,A0			;#COOL to a0
	BSR.B	binhex				;convert Hex to ASCII -=> COOL
	MOVE.L	WarmCapture(A6),D0		;WarmCapture to d0
	MOVEA.L	#WARM,A0			;#WARM to a0
	BSR.B	binhex				;convert Hex to ASCII -=> WARM
	TST.L	Flag				;is PointerClearFlag set?
	BEQ.B	LeavePointers			;no: leave Pointers untouched

	CLR.L	ColdCapture(A6)			;clear ColdCapture
	CLR.L	CoolCapture(A6)			;clear CoolCapture
	CLR.L	WarmCapture(A6)			;clear WarmCapture
	MOVE.L	#Text,D2			;Textpointer to d2
	MOVE.L	#Length1,D3			;Textlength to d3
	BSR.B	TextOutPut			;output Text
	BRA.B	CloseDos			;close Doslibrary

LeavePointers:
	MOVE.L	#Text,D2			;Textpointer to d2
	MOVE.L	#Length,D3			;Textlength to d3
	BSR.B	TextOutPut			;output Text
	MOVEA.L	ExecBase,A6			;ExecBase to a6
	MOVE.L	ColdCapture(A6),D0		;ColdCapture to d0
	OR.L	CoolCapture(A6),D0		;+ CoolCapture
	OR.L	WarmCapture(A6),D0		;+ WarmCapture
	TST.L	D0				;Pointers clean?
	BEQ.B	CloseDos			;yes -=> CloseDos

	MOVE.L	#Text2,D2			;Textpointer2 to d2
	MOVE.L	#Length2,D3			;Textlength2 to d3
	BSR.B	TextOutPut			;output Text2

CloseDos:
	MOVEA.L	DOSBase,A1			;DOSBase to a1
	MOVEA.L	ExecBase,A6			;ExecBase to a6
	JSR	CloseLibrary(A6)		;close DOSlibrary

ErrorExit:
	RTS					;get back to CLI

TextOutPut:
	MOVE.L	stdout,D1			;stdout to d1
	MOVEA.L	DOSBase,A6			;DOSBase to a6
	JSR	Write(A6)			;output Text
	RTS

;***********************************************************************
;*
;*	 binhex
;*		(c) by Larry Phillips (CIS -76703,4322)
;*	 	modified by Heiko Rath to suit better my needs (4.1.88)
;*
;* PURPOSE: Convert a binary value in a register to 
;*	   a hex ASCII string at the destination address
;*          
;* ROUTINE TYPE: SUBROUTINE
;*
;* SYNTAX: bsr	binhex	(source(long),destination) (d0.l,a0)
;*	   bsr	binhexw	(source(word),destination) (d0.w,a0)
;*	   bsr	binhexb	(source(byte),destination) (d0.b,a0)
;*
;* ENTRY CONDITIONS: None
;*
;* RETURNS: ASCII string in destination address
;*
;* NOTE: destination is 8 bytes long to hold string
;*       for any length (long, word, byte).
;*       Destination contains result padded with leading zeros.
;*
;* CHANGED: Nothing
;*
;* USAGE:
;*
;*	 move	#label,d0
;*	 move.l	address,a0	;converts the address at label to
;*	 bsr	binhex		;string at address
;*				
;*	 move	label,d0
;*	 move.l	address,a0
;*	 bsr	binhex		;conv contents at label
;*
;*	 move	#value,d0
;*	 move.l	address,a0
;*	 bsr	binhex		;convert immediate value
;*
;****************************************************************

binhex:
	MOVE.L	A0,-(A7)
	MOVE.L	D2,-(A7)			;preserve d2
	MOVE.L	#$7,D2				;count to d2
	CLR.L	D1				;conversion work register

bhloop:
	ROL.L	#$4,D0				;get high order nybble to low order
	MOVE.B	D0,D1				;low order byte to d1
	ANDI.B	#$F,D1				;isolate low order byte
	CMPI.B	#$A,D1				;digit or letter?
	BLT.B	bhaddz				;branch if digit
	ADDQ.B	#$7,D1				;offset for letters

bhaddz:
	ADDI.B	#'0',D1				;convert to ASCII
	MOVE.B	D1,(A0)+			;store it and increment address
	DBF	D2,bhloop			;do 8 times

	MOVE.L	(A7)+,D2			;restore d2
	MOVEA.L	(A7)+,A0			;restore a0
	RTS

;
; Variables:
;
DOSBase:
	dc.l	0
stdout:
	dc.l	0
Flag:
	dc.l	0
;
; Constants:
;
DOSNAME:
	dc.b	'dos.library',0
Text:
	dc.b	$9b,'0;33;40m','AntiVirus',$9b,'0;31;40m'
	dc.b	'  by  ',$9b,'0;32;40m','Heiko Rath',$9b,'0;31;40m',10
	dc.b	$9b,'4;31;40m',169,' by '
	dc.b	$9b,'1;31;40m','The Software Brewery',$9b,'0;31;40m',10
	dc.b	'ColdCapture:    $'
	cnop	0,2
COLD	dc.b	'00000000',10
	dc.b	'CoolCapture:    $'
	cnop	0,2
COOL	dc.b	'00000000',10
	dc.b	'WarmCapture:    $'
	cnop	0,2
WARM	dc.b	'00000000',10
Length	equ	*-Text

	dc.b	'All done - vectors cleared',10
Length1	equ	*-Text

Text2:
	dc.b	'To clear the pointers use '
	dc.b	$9b,'1;33;40m','AntiVirus c',$9b,'0;31;40m',10
Length2	equ	*-Text2

	end
