home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / text / manipulation / snap164.lha / patch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-30  |  802 b   |  42 lines

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