Source file: /~heha/hs/dos/dirhide.zip/RBOOT.ASM

;hoffentlich QEMM-kompatibel
;RBOOTD(aemon) zum Fernbooten eines Netzrechners
	include	prolog.asm
	include	"strings.asm"
REQfunc		equ	4b48h		;in AX
REQcode		equ	9877h		;in DX
ANScode		equ	8764h		;in AX; DX=Segmentadresse
ResPara		equ	(ISRBase-PSPOrg+ISRE-ISRA+0fh)/16

		org	5ch
ctrl0		db	?		;Ein/Aus-Schalter
fName		db	81 dup (?)
		;Bit7: global ein/aus
ISRBase:	;FCB's überschreiben
		org	100h
		print	Text0		;Meldung
		mov	[ctrl0],80h	;erst mal Standard laden
		call	InstChk		;ggf. ES auf Fremdroutine
		;nun ch=Statusregister:
		;Bit0: Deinstallation nicht möglich
		;Bit7: Noch nicht installiert
		mov	si,81h
		cld
scancl:		lodsb
		cmp	al,'/'
		jz	opt
		cmp	al,'-'
		jz	opt
		cmp	al,' '
		jz	scancl
		cmp	al,0dh
		jz	install0
		push	si
sc1:		 lodsb
		 cmp	al,21h
		 jnc	sc1
		 mov	[by si-1],0	;Abschluß-Null
		pop	si
		dec	si
		mov	di,ofs fname
		DOS	60h		;Truename
		jc	errm
		jmp	install
opt:
		lodsb
		call	Upcase
		cmp	al,'U'
		je	UnInst
		cmp	al,'D'
		je	DisActiv
		cmp	al,'S'
		JN	z,Status	;'n tolles Makro erspart JUMPS

help:	;Hilfe Option "H" oder "?"
		mov	dx,offset TextH
		jr	TXTO1

UnInst:	;Deinstallation(sversuch) Option "U"
		mov	dx,offset Text5
		test	ch,80h
		jnz	TXTO1		;Wenn nicht nötig!
		or	ch,ch
		jz	Raus
		PRINT	Text4
		mov	dx,offset Text4a
disab:		and	[es:Ctrl0],not 80h	;löschen
		jmp	TXTOut

DisActiv:;Deaktivieren Option "D"
		test	ch,80h		;Schon installiert?
		mov	dx,ofs Text5
		jnz	TXTO1
		mov	dx,ofs Text4b
		jr	disab
	;Deinstallation
Raus:		lds	dx,[es:ofs OldInt21-ISRA+ISRBASE]
		DOS	2521h
		DOS	49h		;den Speicher ab es freigeben
		push	cs
		pop	ds
		mov	dx,ofs Text3	;removed...
TXTO1:		jmp	TXTOut

errm:		mov	dx,ofs err$	;"Falscher Dateiname!"
		jr	TXTOut
errm2:		mov	dx,ofs err2$	;"Dateiname erforderlich!"
		jr	TXTOut

Install0:	test	ch,80h
		jnz	errm2
Install:	test	ch,80h
		mov	dx,ofs Text2	;"reaktiviert"
		jz	stat2
	;ISR nach vorn schaufeln
		cld
		push	cs
		pop	es
		mov	si,ofs ISRA
		mov	di,ofs ISRBase
		mov	cx,(ISRE-ISRA)/2
		rep	movsw
	;Zeiger verbiegen
		mov	dx,ofs NewInt21-ISRA+ISRBASE
		DOS	2521h			;Set Int21
	;Environment freigeben
		mov	es,[2ch]	;Segment Environment
		DOS	49h		;ENV-Speicher ab es freigeben
	;Test des Hochladens
		mov	ax,cs
		mov	es,ax		;Eigenes Programm=Resident!
		cmp	ax,0a000h
		jc	NoHi		;unten
		PRINT	Text1a
NoHi:		mov	dx,offset Text1
	;RBoot enabeln
setab:		or	[es:Ctrl0],80h	;setzen
	;dx-adressierten Text ausgeben
TXTOut:		DOS	9		;Textausgabe
	;Programm beenden
LFOut:		push	dx
		PRINT	_NL
		pop	dx
		cmp	dx,ofs Text1	;Installierung? (etwas seltsam!)
		mov	ax,4C00h
		jnz	exi
		mov	ah,31h		;Resident
		mov	dx,ResPara
exi:		int	21h

stat2:		or	[es:Ctrl0],80h	;setzen
		jr	stat1

Status:		test	ch,80h
		mov	dx,ofs Text5	;"Noch nicht installiert"
		jnz	TXTOut
		PRINT	TextS1		;"Status "
		mov	cl,[es:ctrl0]
		test	cl,80h
		jnz	stat1
		PRINT	Text4		;"in"
stat1:		PRINT	Text2		;"aktiv, Name "
		mov	dx,ofs fName
		push	ds
		 LD	ds,es
		 call	zkout2
		pop	ds
		jr	LFOut


InstChk:;Installationscheck, ES=Zeiger auf installierte Routine oder n.a.!,
	;Bit7(CH)=0: Installationscheck erfolgreich, dann:
	;ES: Segmentadresse der residenten Routine
	;Bit0(CH)=0: Zeiger nicht von anderen verbogen
		mov	ax,REQfunc	;eigentlich Cursorform ermitteln
		mov	dx,REQcode
		int	21h
		xor	ch,ch
		cmp	ax,ANScode	;gleich?
		jz	T21I
		or	ch,80h		;Z-Flag "retten"
		mov	dx,ds
T21I:		push	dx		;Segment der TSR
	;Segment retten
		DOS	3521h		;Get Int21
		SES	<OldInt21>,bx
		cmp	bx,ofs NewInt21-ISRA+ISRBASE
		jnz	T21FLT
		mov	bx,es
		cmp	bx,dx
		je	T21OK
T21FLT:		inc	ch		;ch <>0 wenn andere TSR stört
T21OK:		pop	es
		ret

		_ZKOUT2
;═══════════════════════════════════════
ISRA:
		_UPCASE
		_STRICOMP
NewInt21:	;Neue INT21-Routine
		pushf
		cmp	ax,REQfunc      ;Installationscheck?
		jne	I21cont
		cmp	dx,REQcode
		jne	I21cont
		mov	ax,ANScode
		mov	dx,cs
		popf
		iret
I21cont:
		test	[cs:ctrl0],80h
		jz	isrend
		cmp	ah,3ch		;Create?
		jnz	isrend
		push	ax si di es
		 mov	si,dx
		 mov	di,ofs fname
		 LD	es,cs
		 call	stricomp
		 jz	boot
		pop	es di si ax
isrend:		popf
		JMPF			;jmp far
OldInt21	dd	?

boot:
	;Hyperdisk flushen
	call	SearchHyperAPI
	jc	NoHyp
	mov	al,2
	mov	bx,'DH'		;Kenncode
	mov	dl,0		;alles totlegen
	int	2fh
NoHyp:	;Smartdrv und PC-Cache flushen
	mov	ax,4a10h
	mov	bx,1		;"Flush Buffer"
	int	2fh
	mov	ax,40h
	mov	ds,ax
	mov	[wo 72h],1234h	;"weich" booten ohne Speicherzählen
	JMPF	0f000h:0fff0h	;Richtung Resettaster

proc SearchHyperAPI
	DOS	352fh		;GetIntVec($2f)
	mov	cx,es		; must not be zero!
	jcxz	@@e		; if zero then no multiplex established
	mov	ah,0c0h-1	;Startwert-1
@@l:
	inc	ah
	jz	@@e		;Ausstieg
	xor	cx,cx		; zero cx
	xor	dx,dx		; zero dx
	mov	bx,'DH'		; Looking for HyperDisk
	xor	al,al		; install check request
	push	ds		; make sure not changed
	 int	2fh		; go do multiplex interrupt
	pop	ds
	or	al,al		; zero...no change
	je	@@l		; nothing installed
	cmp	al,-1		; something installed is -1
	jne	@@l		; try next Multiplex number if not -1
	cmp	cx,'YH'		; HyperWare Product?
	jne	@@l		; if not skip to next Multiplex number
	or	dx,dx		; non-zero if HyperDisk installed
	jz	@@l		; HyperDisk not here
	ret				; AH = Multiplex #
					; BX = CS segment of HyperDisk
					; DX = HyperDisk Local Data Version #
@@e:
	stc				; not found, carry Set
	ret
	endp
	alignv	2
ISRE:
;═══════════════════════════════════════

Text0	db	'rBoot 1.0 (haftmann#software): $'
Text1a	db	'hoch$'
Text1	db	'geladen, Speicherbedarf '
	dcd	%((ResPara)*16+16)
	db	' Bytes.$'
Text4	db	'in$'
Text2	db	'aktiv, Name $'
Text3	db	'vom Speicher entfernt.$'
Text4b	db	'deaktiviert.$'
Text4a	db	' (Andere TSR stahl Int21)$'
Text5	db	'Noch nicht installiert!$'
TextS1	db	'Status $'
TextH	db	'		++ FREEWARE ++',nl
	db	'Programm zur Fernauslösung eines RESETs durch Kreieren einer Datei.',nl,10
	db	'Parameter:	- Dateiname	TSR laden oder mit neuem Namen reaktivieren',nl
	db	'		- (keiner)	reaktivieren',nl
	db	'		- d		rBoot deaktivieren',nl
	db	'		- s		Statusinfo',nl
	db	'		- u		TSR entfernen',nl
	db	'		- (alles andere)diese Hilfe$'
err$	db	'Fehler im Dateinamen!$'
err2$	db	'Dateiname erforderlich!$'
_NL	db	nl,'$'

	endc
Detected encoding: OEM (CP437)1
Wrong umlauts? - Assume file is ANSI (CP1252) encoded