CAPTURING INTERRUPTS








  PRODUCT  :  TURBO C                                NUMBER  :  396
  VERSION  :  1.0
       OS  :  PC-DOS
     DATE  :  November 18, 1987                        PAGE  :  1/2

    TITLE  :  CAPTURING INTERRUPTS




  The following program demonstrates the use of getvect and setvect
  to safely capture and restore interrupt vectors.  This code could
  be easily modified to disable  the  print  screen  utility during
  program execution.

  #include <stdio.h>
  #include <dos.h>

  void interrupt (*oldfunc)();
  int __LOOPING__ = 1;

  /*--------------------------------------------------------------------
   * get_out - this is our new interrupt routine
   *------------------------------------------------------------------*/
  void interrupt get_out()
  {
         setvect(5,oldfunc); /* restore to original interrupt routine */

       __LOOPING__ = 0;

  }

  /*--------------------------------------------------------------------
   * capture_prtscr - installs a new interrupt for <Shift><PrtSc>
   *  arguments :  func  -- new interrupt function pointer
   *------------------------------------------------------------------*/
  void capture_prtscr(void interrupt (*func)())
  {
       oldfunc  = getvect(5);        /* save the old interrupt */
       setvect(5,func);              /* install our interrupt handler */
  }

  void main () {

       puts("Press <Shift><PrtSc> to terminate");
       capture_prtscr(get_out);  /* capture the print screen interrupt */

       while (__LOOPING__)
         ;   /* do nothing */

       puts("Success");
  }














  PRODUCT  :  TURBO C                                NUMBER  :  396
  VERSION  :  1.0
       OS  :  PC-DOS
     DATE  :  November 18, 1987                        PAGE  :  2/2

    TITLE  :  CAPTURING INTERRUPTS




  DISCLAIMER:  You  have  the right to use  this  technical  information
  subject to the terms  of  the  No-Nonsense  License Statement that you
  received with the Borland product to which this information pertains.

Comments

Popular posts from this blog

BOTTOM LIVE script

Evidence supporting quantum information processing in animals

ARMIES OF CHAOS