home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l430 / 1.ddi / CHAP5.ZIP / GP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-08  |  1.2 KB  |  45 lines

  1. /*
  2.     GP.C -- Lists GP fault handlers
  3.  
  4.     From Chapter 5 of "Undocumented Windows" (Addison-Wesley 1992)
  5.     by Andrew Schulman, Dave Maxey and Matt Pietrek
  6.  
  7.     Build using: WINIOBC GP (for Borland C++ v3.00)
  8.                  WINIOMS GP (for Microsoft C/SDK)
  9. */
  10.  
  11. #include <windows.h>
  12. #include "winio.h"
  13.  
  14. typedef struct {
  15.     WORD seg, low, high, func;
  16.     } GPTAB;
  17.  
  18. main(int argc, char *argv[])
  19. {
  20.     GPTAB far *__GP;
  21.     GPTAB far *p;
  22.     char *modname;
  23.     
  24.     winio_about("GP"
  25.         "\nLists GP fault handlers"
  26.         "\nUsage: GP [module name]"
  27.         "\n\nFrom Chapter 5 of"
  28.         "\n\"Undocumented Windows\" (Addison-Wesley, 1992)"
  29.         "\nby Andrew Schulman, David Maxey and Matt Pietrek"
  30.         );
  31.     
  32.     modname = (argc < 2) ? "KERNEL" : argv[1];
  33.     
  34.     // MUST use GetProcAddress, because __GP in more than one module
  35.     if (! (__GP = GetProcAddress(GetModuleHandle(modname), "__GP")))
  36.         fail("Cannot locate __GP in module");
  37.  
  38.     printf("GP fault handling in %s\n", modname);
  39.     for (p=__GP; p->seg; p++)
  40.         printf("GP faults in %04x:%04x-%04x handled by %04x:%04x\n", 
  41.             p->seg, p->low, p->high, p->seg, p->func);
  42.     return 0;
  43. }
  44.  
  45.