PAGE 64,132
title	(Faking Out Star Trek's Copy Protection - Version #01)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
;	This program was specifically designed to thwart a copy 
;	protection scheme that formatted one track with 16 sectors.  
; 
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
envrnmt_seg	equ	2Ch	; pointer to program's environment segment
int03loc	equ	03*04	; vector location for int03
int13loc	equ	13h*04	; vector location for int13h
;
cseg    segment 
	org 100h
;
bypass	proc far
        assume cs:cseg,ds:cseg
;
	jmp	install
;
		dw	'BP'	; flag that this program was already installed 
oldint13	dd	00	; save area for old int13 vector
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
newint13	equ	$
	sti			; first reenable interrupts 
	pushf			; this will get altered 
;
	or	dx,dx		; side zero on drive A: ???
	jnz	intcall		; if not don't bother 
	cmp	ch,09		; track #09 ???
	jnz	intcall		; if not don't bother 
	cmp	ax,0401h	; only verify one sector ???
	jnz	intcall
;				; looks like we have it men 
;;;	call	cs:oldint13	; this is no longer needed 
	popf
	mov	ah,00		; fake out verify operation with OK status 
	clc			; clear carry flag 
	ret	02
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
intcall	equ	$
	popf
	jmp	cs:oldint13	; branch to normal int 13h routine 
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
inst_msg	db	'Star Trek Bypass is now installed.......'
		db	0Dh,0Ah,'$'
deinst_msg	db	'Star Trek Bypass is now deinstalled.......'
		db	0Dh,0Ah,'$'
;
install	label	near		; install and make routine resident 
	xor	ax,ax		; first get old interrupt 13h vector
	mov	es,ax
	mov	bx,es:word ptr int13loc
	mov	ax,es:word ptr int13loc+02
;
	mov	ds,ax		; see if this program was already installed 
	cmp	ds:[bx-06],'BP'
	jnz	install02	; no 
;
	cli
	mov	ax,ds:[bx-04]	; restore old vector offset 
	mov	es:word ptr int13loc,ax
	mov	ax,ds:[bx-02]	; restore old vector segment 
	mov	es:word ptr int13loc+02,ax
	sti
;
	mov	ax,ds
	mov	es,ax
	mov	ah,49h
	int	21h		; deallocate old bypass program segment 
;
	mov	ax,cs		; bring ds back to reality 
	mov	ds,ax
;
	mov	dx,offset deinst_msg
	mov	ah,09		; message offset already in dx 
	int	21h		; print string 
;
	mov	ah,4Ch		; exit to DOS 
	int	21h
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
install02	equ	$
	push	cs
	pop	ds		; restore ds
;
	mov	ds:word ptr oldint13,bx
	mov	ds:word ptr oldint13+02,ax
	cli			; disable interrupts 
	mov	es:word ptr int13loc,offset newint13
	mov	es:word ptr int13loc+02,cs
;				; write in our new interrupt 13h vector 
	sti			; reenable interrupts 
;
	mov	es,ds:word ptr envrnmt_seg
	mov	ah,49h
	int	21h		; deallocate old bypass environment segment
;
	mov	dx,offset inst_msg
	mov	ah,09		; Print string function
	int	21h		; Print "install" message
;				; get rid of code after label inst_msg 
	mov	dx,offset inst_msg
	int	27h		; Terminate and stay resident
;
bypass	endp
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
cseg	ends
	end	bypass
