home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name issense -- Detect an installed interrupt service routine
- * (ISR)
- *
- * Synopsis pctrl = issense(ptr,pident);
- *
- * ISRCTRL far *pctrl
- * Address of ISR control block, or
- * (FARNIL) if not found.
- * void far *ptr Far pointer to potential ISR entry point.
- * char *pident Pointer to array of 16 bytes of
- * identifying information
- *
- * Description This function examines the contents of memory pointed to
- * by an interrupt vector to see whether it contains a
- * particular Turbo C TOOLS, LIGHT TOOLS, or C TOOLS PLUS
- * ISR control block. If so, the function returns the
- * address of the found ISR control block; if not, the
- * function returns FARNIL.
- *
- * The ISR control block contains the information necessary
- * to disable the ISR and to remove the program that
- * contains it.
- *
- * Limitation This version does NOT trace chains of "cascaded" ISRs.
- * That is, if the ISR pointed to by ptr is not the desired
- * ISR but merely passes control to the desired ISR, the
- * desired ISR will not be found.
- *
- * Returns pctrl Address of ISR control block, or
- * FARNIL if not found.
- *
- * Version 6.00 (C)Copyright Blaise Computing Inc. 1986,1987,1989
- *
- **/
-
- #include <dos.h>
- #include <string.h>
-
- #include <bintrupt.h>
-
- ISRCTRL far *issense(ptr,pident)
- void far *ptr;
- const char *pident;
- {
- unsigned int offset;
- ISRCTRL far *ptest;
- int i;
-
- if (ptr == FARNIL)
- return FARNIL;
-
- offset = utoff(ptr);
-
- /* Make sure that the control block does not straddle a segment */
- /* boundary. Notice that this computation requires that */
- /* sizeof(ISRCTRL) be at least 2 (which it is). */
-
- if ( offset < ICB_ENTRY_OFFSET
- || offset >= (unsigned) 0xffff - sizeof(ISRCTRL) + 2)
- return FARNIL;
-
- /* If this vector points to a Turbo C TOOLS, C TOOLS PLUS */
- /* or LIGHT TOOLS interrupt service routine, then the */
- /* actual item pointed to is at offset ICB_ENTRY_OFFSET in an */
- /* ISRCTRL structure. */
-
- ptest = uttofar (utseg(ptr),offset - ICB_ENTRY_OFFSET,ISRCTRL);
-
- /* Check for signature word in ISRCTRL structure. */
-
- if (ptest->signature != ICB_SIGNATURE)
- return FARNIL;
-
- /* Confirm signature by checking its one's-complement. */
-
- if (ptest->sign2 != (unsigned) ~ICB_SIGNATURE)
- return FARNIL;
-
- /* Check identifying "string". */
-
- for (i = 0;
- (i < sizeof (ptest->ident)) &&
- (ptest->ident[i] == pident[i]);
- i++)
- ;
-
- if (i < sizeof (ptest->ident))
- return FARNIL;
-
- /* Fall through: all tests passed, this is the desired ISR. */
-
- return ptest;
- }