home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 1 / FFMCD01.bin / bbs / libdisks / d700t799 / disk793.lha / Snap / src.lha / src / patch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-15  |  765 b   |  38 lines

  1. #ifdef LATTICE
  2. typedef ULONG (*FPTR)();
  3. #endif
  4. #ifdef AZTEC_C
  5. typedef VOID (*FPTR)();
  6. #endif
  7.  
  8. IMPORT struct IntuitionBase *IntuitionBase;
  9. #define LVOActivateWindow -0x01c2L
  10.  
  11. VOID myActivateWindow();
  12.  
  13. LONG oldActivateWindow;
  14.  
  15. STATIC WORD patched = 0;
  16.  
  17. VOID SafePatch()
  18. {
  19.     if (!patched) {
  20.         Forbid();     /* I don't expect interrupts to do much intuition */
  21.         oldActivateWindow = (LONG)SetFunction((struct Library *)IntuitionBase,
  22.           LVOActivateWindow, (FPTR)myActivateWindow);
  23.         Permit();
  24.         patched = 1;
  25.     }
  26. }
  27.  
  28. VOID SafeRestore()
  29. {
  30.     if (patched) {
  31.         Forbid();
  32.         (VOID)SetFunction((struct Library *)IntuitionBase,
  33.           LVOActivateWindow, (FPTR)oldActivateWindow);
  34.         Permit();
  35.         patched = 0;
  36.     }
  37. }
  38.