Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

169 lines
4.8 KiB

  1. /*++
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. apimon.h
  5. Abstract:
  6. Common types & structures for the APIMON projects.
  7. Author:
  8. Wesley Witt (wesw) 28-June-1995
  9. Environment:
  10. User Mode
  11. --*/
  12. #ifndef _APIMON_
  13. #define _APIMON_
  14. #ifdef __cplusplus
  15. #define CLINKAGE extern "C"
  16. #else
  17. #define CLINKAGE
  18. #endif
  19. #define TROJANDLL "apidll.dll"
  20. #define MAX_NAME_SZ 32
  21. #define MAX_DLLS 512
  22. #define MEGABYTE (1024*1024)
  23. #define MAX_MEM_ALLOC (MEGABYTE*32)
  24. #define MAX_APIS ((MAX_MEM_ALLOC/2)/sizeof(API_INFO))
  25. #define THUNK_SIZE MEGABYTE
  26. #define Align(p,x) (((x) & ((p)-1)) ? (((x) & ~((p)-1)) + p) : (x))
  27. #define KERNEL32 "kernel32.dll"
  28. #define NTDLL "ntdll.dll"
  29. #define USER32 "user32.dll"
  30. #define WNDPROCDLL "wndprocs"
  31. #define LOADLIBRARYA "LoadLibraryA"
  32. #define LOADLIBRARYW "LoadLibraryW"
  33. #define FREELIBRARY "FreeLibrary"
  34. #define GETPROCADDRESS "GetProcAddress"
  35. #define REGISTERCLASSA "RegisterClassA"
  36. #define REGISTERCLASSW "RegisterClassW"
  37. #define SETWINDOWLONGA "SetWindowLongA"
  38. #define SETWINDOWLONGW "SetWindowLongW"
  39. #define ALLOCATEHEAP "RtlAllocateHeap"
  40. #define CREATEHEAP "RtlCreateHeap"
  41. #if defined(_ALPHA_)
  42. #define UPPER_ADDR(_addr) LOWORD(((LONG_PTR)(_addr) >> 32) + (HIGH_ADDR((_addr)) >> 15))
  43. #define HIGH_ADDR(_addr) LOWORD(HIWORD((_addr)) + (LOWORD((_addr)) >> 15))
  44. #define LOW_ADDR(_addr) LOWORD((_addr))
  45. #endif
  46. //
  47. // api table type definitions
  48. //
  49. #define DFLT_TRACE_ARGS 8
  50. #define MAX_TRACE_ARGS 8
  51. //
  52. // Handle type, index corresponds to the entries in the alias array
  53. //
  54. enum Handles { T_HACCEL, T_HANDLE, T_HBITMAP, T_HBRUSH, T_HCURSOR, T_HDC,
  55. T_HDCLPPOINT, T_HDESK, T_HDWP, T_HENHMETAFILE, T_HFONT, T_HGDIOBJ,
  56. T_HGLOBAL, T_HGLRC, T_HHOOK, T_HICON, T_HINSTANCE, T_HKL, T_HMENU,
  57. T_HMETAFILE, T_HPALETTE, T_HPEN, T_HRGN, T_HWINSTA, T_HWND};
  58. #define T_DWORD 101
  59. #define T_LPSTR 102
  60. #define T_LPWSTR 103
  61. #define T_UNISTR 104 // UNICODE string (counted)
  62. #define T_OBJNAME 105 // Name from OBJECT_ATTRIBUTES struct
  63. #define T_LPSTRC 106 // Counted string (count is following arg)
  64. #define T_LPWSTRC 107 // Counted UNICODE string (count is following arg)
  65. #define T_DWORDPTR 108 // Indirect DWORD
  66. #define T_DLONGPTR 109 // Indirect DWORDLONG
  67. // User macro for creating T_DWPTR type with offset encoded in high word
  68. #define T_PDWORD(off) (((off)<<16) + T_DWORDPTR)
  69. #define T_PDLONG(off) (((off)<<16) + T_DLONGPTR)
  70. #define T_PSTR(off) (((off)<<16) + T_LPSTR)
  71. #define T_PWSTR(off) (((off)<<16) + T_LPWSTR)
  72. //
  73. // api trace modes
  74. #define API_TRACE 1 // Trace this api
  75. #define API_FULLTRACE 2 // Trace this api and its callees
  76. typedef struct _API_TABLE {
  77. LPSTR Name;
  78. ULONG RetType;
  79. ULONG ArgCount;
  80. ULONG ArgType[MAX_TRACE_ARGS];
  81. } API_TABLE, *PAPI_TABLE;
  82. typedef struct _API_MASTER_TABLE {
  83. LPSTR Name;
  84. BOOL Processed;
  85. PAPI_TABLE ApiTable;
  86. } API_MASTER_TABLE, *PAPI_MASTER_TABLE;
  87. typedef struct _API_INFO {
  88. ULONG Name;
  89. ULONG_PTR Address;
  90. ULONG_PTR ThunkAddress;
  91. ULONG Count;
  92. DWORDLONG Time;
  93. DWORDLONG CalleeTime;
  94. ULONG NestCount;
  95. ULONG TraceEnabled;
  96. PAPI_TABLE ApiTable;
  97. ULONG_PTR HardFault;
  98. ULONG_PTR SoftFault;
  99. ULONG_PTR CodeFault;
  100. ULONG_PTR DataFault;
  101. ULONG Size;
  102. ULONG ApiTableIndex;
  103. ULONG_PTR DllOffset;
  104. } API_INFO, *PAPI_INFO;
  105. typedef struct _DLL_INFO {
  106. CHAR Name[MAX_NAME_SZ];
  107. ULONG_PTR BaseAddress;
  108. ULONG Size;
  109. ULONG ApiCount;
  110. ULONG ApiOffset;
  111. ULONG Unloaded;
  112. ULONG Enabled;
  113. ULONG OrigEnable;
  114. ULONG Snapped;
  115. ULONG InList;
  116. ULONG StaticProfile;
  117. ULONG Hits;
  118. ULONG LoadCount;
  119. } DLL_INFO, *PDLL_INFO;
  120. typedef struct _TRACE_ENTRY {
  121. ULONG SizeOfStruct;
  122. ULONG_PTR Address;
  123. ULONG_PTR ReturnValue;
  124. ULONG LastError;
  125. ULONG_PTR Caller;
  126. ULONG ApiTableIndex;
  127. DWORDLONG EnterTime;
  128. DWORDLONG Duration;
  129. ULONG ThreadNum;
  130. ULONG Level;
  131. ULONG_PTR Args[MAX_TRACE_ARGS];
  132. } TRACE_ENTRY, *PTRACE_ENTRY;
  133. typedef struct _TRACE_BUFFER {
  134. ULONG Size;
  135. ULONG Offset;
  136. ULONG Count;
  137. TRACE_ENTRY Entry[1];
  138. } TRACE_BUFFER, *PTRACE_BUFFER;
  139. #endif
  140.