home *** CD-ROM | disk | FTP | other *** search
/ PC World 1999 October / PCWorld_1999-10_cd1.bin / Hardware / Drivers / APISpy / APISpy32.h < prev    next >
C/C++ Source or Header  |  1999-07-25  |  1KB  |  85 lines

  1. #ifndef APISPY32_H
  2. #define APISPY32_H
  3.  
  4. #include <windows.h>
  5.  
  6. #ifdef WIN95
  7.  
  8. // Increase this value if you wish to intercept more than
  9. // 100 API functions under Windows 95/98.
  10.  
  11. #define MAX_API 100
  12.  
  13. #endif
  14.  
  15. #define MAX_API_NAME 50
  16. #define MAX_TEXT_LEN 40
  17. #define MAX_PARAM    20
  18.  
  19. struct tagAPIInfo;
  20.  
  21. typedef void (*tagAPIAddr)();
  22. typedef void (*tagHandlerAddr)(tagAPIInfo *, PSTR, ...);
  23.  
  24. enum tagParamType
  25. {
  26.   PARAM_INT,
  27.   PARAM_DWORD,
  28.   PARAM_WORD,
  29.   PARAM_BYTE,
  30.   PARAM_PSTR,
  31.   PARAM_PVOID,
  32.   PARAM_PINT,
  33.   PARAM_PDWORD,
  34.   PARAM_PWORD,
  35.   PARAM_PBYTE,
  36.   PARAM_HANDLE,
  37.   PARAM_HWND,
  38.   PARAM_BOOL,
  39.   PARAM_PWSTR,
  40.   PARAM_UNKNOWN
  41. };
  42.  
  43. struct tagParamSpec
  44. {
  45.   char *ParamName;
  46.   tagParamType ParamType;
  47.   char *ParamFormat;
  48.   DWORD dwParamMask;
  49. };
  50.  
  51. struct tagAPIInfo
  52. {
  53.   BYTE Opcodes[5];
  54.   tagAPIAddr APIAddress;
  55.  
  56.   #ifdef WIN95
  57.  
  58.   char szAPIName[MAX_API_NAME + 1];
  59.   HANDLE hMutex;
  60.  
  61.   #endif
  62.  
  63.   #ifdef WINNT
  64.  
  65.   DWORD dwOldProtectionFlags;
  66.   PSTR szAPIName;
  67.   CRITICAL_SECTION CriticalSection;
  68.  
  69.   #endif
  70.  
  71.   tagHandlerAddr APIEnterHandler;
  72.   tagParamType ParamList[MAX_PARAM];
  73.   BYTE ParamCount;
  74.   tagAPIInfo *Next;
  75. };
  76.  
  77. tagAPIInfo *HookAPIFunction(PSTR pszModuleName,
  78.                             PSTR pszAPIName,
  79.                             tagHandlerAddr APIEnterHandler);
  80.  
  81. void UnhookAPIFunction(tagAPIInfo *pAPIInfo);
  82.  
  83. void UnhookAllAPIFunctions();
  84.  
  85. #endif