{***********************************************************************}
{									}
{ __IsInsInt  Check if intervention code is installed			}
{									}
{ function  __IsInsInt(Ident : _IdentStr;				}
{			    var Vectors : _IntVect;			}
{			     var PSPPtr,				}
{				 EnvPtr : _BytePtr) : boolean;		}
{									}
{	      Ident	The intervention code identification string.	}
{			It must match exactly (case is important) the	}
{			string specified when the intervention code	}
{			is installed using __IntIsr.			}
{	      Vectors	The previous vector values before the inter-	}
{			vention code filters were installed are 	}
{			returned in this record structure.  If the	}
{			intervention code cannot be detected, NIL is	}
{			returned for all values.			}
{	      PSPPtr	If filters are found for all vectors, the pro-	}
{			segment prefix for the installed intervention	}
{			code is returned.  If one of the filter vectors }
{			cannot be identified, the NIL pointer is re-	}
{			turned. 					}
{	      EnvPtr	If the PSPPtr can be returned, the pointer to	}
{			the processes environment table is also 	}
{			returned; otherwise the NIL pointer is returned.}
{									}
{ Description This function checks to see if POWER TOOLS intervention	}
{	      code is installed.  It checks each of the vectors (timer, }
{	      keyboard, COM2, COM1, disk, DOS functions, and DOS idle)	}
{	      to make sure an identifiable intervention code filter is	}
{	      present.	If even one of filters cannot be found, it is	}
{	      not safe to remove the process from memory, and probably	}
{	      not safe to reset any of the vectors. Filters are 	}
{	      identified by checking that at offset 2 in the filter is	}
{	      the offset  of the intervention code control block.	}
{									}
{	      If all filters are identified and previous vectors	}
{	      returned, then the function returns TRUE; otherwise it	}
{	      returns FALSE as its function value.			}
{									}
{ Version     4.00 (C)Copyright Blaise Computing Inc.  1987		}
{_______________________________________________________________________}

function  __IsInsInt(Ident : _IdentStr;
			  var Vectors : _IntVect;
			   var PSPPtr,
			       EnvPtr : pointer) : boolean;

  const
    IntType  : array[1..7] of integer = ($08,$09,$0B,$0C,$13,$21,$28);

  var
    IntCtrlPtr	   : _IntCtrlPtr;
    TempPtr	   : pointer;
    FilterSeg	   : word;
    OffsetPtr	   : ^word;
    PrevIntVectors : array[1..9] of pointer absolute Vectors;
    FoundFilter    : boolean;
    I		   : integer;

  begin {__IsInsInt}

    FoundFilter := TRUE;
    FillChar(PrevIntVectors,SizeOf(PrevIntVectors),0);

    { For each of the vectors used by the intervention code filters,	}
    { recover the address (stored therein) of the intervention control	}
    { block.  Inspect the structure that the address should be pointing }
    { to if the filter is really installed, and make sure that both	}
    { the signature and identification string are correct.  If found,	}
    { set the previous vector value and continue.			}

    I := 1;
    while ((I <= 7) and (FoundFilter)) do
      begin
	GetIntVec(IntType[I],TempPtr);
	FilterSeg  := _VectorAddr(TempPtr)._Seg;
	OffsetPtr  := Ptr(FilterSeg,_VectorAddr(TempPtr)._Ofs + 2);
	IntCtrlPtr := Ptr(FilterSeg,OffsetPtr^);
	with IntCtrlPtr^ do
	  if ((_IntSignature <> 'BCI') or (_IntIdent <> Ident)) then
	     FoundFilter := FALSE;
	Inc(I)
      end;

    { If all the filters have been found, then the program segment	}
    { prefix is just the value _IntPSP in the control record,		}
    { and the environment segment is at offset $2C within the PSP.	}
    { Return the previous interrupt vectors used as well.		}

    if (FoundFilter) then
       with IntCtrlPtr^ do
	 begin
	   Move(_IntVectors,PrevIntVectors,SizeOf(PrevIntVectors));
	   PSPPtr     := Ptr(_IntPSP,0);
	   EnvPtr     := Ptr(MemW[_IntPSP:$2C],0);
	   __IsInsInt := TRUE
	 end
    else
       begin
	 PSPPtr     := NIL;
	 EnvPtr     := NIL;
	 __IsInsInt := FALSE
       end

  end;	{__IsInsInt}
