.386p

.MODEL TPASCAL
.DATA

 oldint3 dd ?
 old_interrupt3 dd ?
.CODE

public protected_stopping
protected_stopping proc pascal
	pusha
	cli                         ; disable interrupts
	mov eax,cr0                 ; switch to Protected mode
	or eax,1
	mov cr0,eax
	jmp PROTECTION_ENABLED      ; clear execution pipe
PROTECTION_ENABLED:

	and al,0FEh                 ; switch back to Real mode
	mov cr0,eax                 ; do not reset CPU
	jmp PROTECTION_DISABLED     ; clear execution pipe
PROTECTION_DISABLED:
	sti                         ; enable interrupts again
	popa
  ret
protected_stopping endp

public check_for_vector
check_for_vector proc pascal check : dword;
  mov bx,0
  mov es,bx
  mov bx,18
  mov eax,es:[bx]
  mov oldint3,eax
  mov eax,check
  mov es:[bx],eax
  ret
check_for_vector endp

public vector_ok
vector_ok proc pascal check : dword;
  mov bx,0
  mov es,bx
  mov bx,18
  mov eax,es:[bx]
  cmp eax,check
  je  @check_ok
  mov al,0
  jmp @check_end
@check_ok:
  mov al,1
@check_end:
  ret
Vector_ok endp

public restore_checkvector
restore_checkvector proc pascal
  mov bx,0
  mov es,bx
  mov bx,18
  mov eax,oldint3
  mov es:[bx],eax
  ret
restore_checkvector endp

public copy_int21_int3
copy_int21_int3 proc pascal
  mov bx,0
  mov es,bx
  mov bx,18
  mov eax,es:[bx]
  mov old_interrupt3,eax              ; store old int3
  mov bx,84                             ; load int 21
  mov eax,es:[bx]
  mov bx,18                             ; save in int3
  mov es:[bx],eax
  ret
copy_int21_int3 endp








END
