Leaked source code of windows server 2003
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.

233 lines
6.0 KiB

  1. /*
  2. ** memmon.h
  3. **
  4. ** Structures, equates, and function prototypes to
  5. ** access the Memmon VxD.
  6. */
  7. /*
  8. ** Information per VxD
  9. */
  10. typedef struct {
  11. unsigned vi_size;
  12. unsigned vi_vhandle; /* VxDLdr's handle */
  13. unsigned short vi_flags;
  14. unsigned short vi_cobj; /* Number of objects */
  15. char vi_name[8]; /* Not NULL-terminated */
  16. } VxDInfo;
  17. #define VXD_INITALIZED 0x0001
  18. #define VXD_DYNAMIC 0x8000
  19. /*
  20. ** Information per VxD object
  21. */
  22. typedef struct {
  23. unsigned voi_linearaddr;
  24. unsigned voi_size; /* In bytes */
  25. unsigned voi_objtype;
  26. } VxDObjInfo;
  27. /*
  28. ** VxD Object Types, copied directly from VMM.H
  29. */
  30. #define RCODE_OBJ -1
  31. #define LCODE_OBJ 0x01
  32. #define LDATA_OBJ 0x02
  33. #define PCODE_OBJ 0x03
  34. #define PDATA_OBJ 0x04
  35. #define SCODE_OBJ 0x05
  36. #define SDATA_OBJ 0x06
  37. #define CODE16_OBJ 0x07
  38. #define LMSG_OBJ 0x08
  39. #define PMSG_OBJ 0x09
  40. #define DBOC_OBJ 0x0B
  41. #define DBOD_OBJ 0x0C
  42. #define ICODE_OBJ 0x11
  43. #define IDATA_OBJ 0x12
  44. #define ICODE16_OBJ 0x13
  45. #define IMSG_OBJ 0x14
  46. /*
  47. ** Load information for a VxD
  48. */
  49. typedef struct {
  50. unsigned vli_size;
  51. VxDObjInfo vli_objinfo[1];
  52. } VxDLoadInfo;
  53. /*
  54. ** Information for each context
  55. */
  56. typedef struct {
  57. unsigned ciContext; /* Context ID */
  58. unsigned ciProcessID; /* Win32 process ID */
  59. unsigned ciBlockCount;
  60. unsigned ciHandle; /* Memmon's handle */
  61. unsigned short ciFlags;
  62. unsigned short ciNumContexts;
  63. } ContextInfo;
  64. #define CONTEXT_NEW 0x0001 /* Never sampled before */
  65. #define CONTEXT_CHANGE 0x0002 /* context list has changed */
  66. /*
  67. ** Information for each block in a context
  68. */
  69. typedef struct {
  70. unsigned brLinAddr;
  71. unsigned brPages;
  72. unsigned brFlags; /* PageAllocate flags */
  73. unsigned brEIP; /* Caller's EIP */
  74. } BlockRecord;
  75. /*
  76. ** Page lock information
  77. */
  78. typedef struct {
  79. unsigned liProcessID;
  80. unsigned liAddr;
  81. unsigned char * liBuffer;
  82. } LockInfo;
  83. /*
  84. ** The following structure is used internally to for GetPageInfo and
  85. ** ClearAccessed. See memmon.c for usage.
  86. */
  87. typedef struct {
  88. unsigned uAddr;
  89. unsigned uNumPages;
  90. unsigned uProcessID;
  91. unsigned uCurrentProcessID;
  92. unsigned uOperation;
  93. char * pBuffer;
  94. } PAGEINFO;
  95. #define PAGES_CLEAR 0
  96. #define PAGES_QUERY 1
  97. /*
  98. ** Structure filled in by GetSysInfo
  99. */
  100. typedef struct {
  101. unsigned infoSize;
  102. unsigned infoMinCacheSize;
  103. unsigned infoMaxCacheSize;
  104. unsigned infoCurCacheSize;
  105. } SYSINFO, *PSYSINFO;
  106. /*
  107. ** Structure used to describe block names
  108. */
  109. typedef struct {
  110. char bnName[32];
  111. unsigned bnAddress;
  112. unsigned bnNext;
  113. } BLOCKNAME, *PBLOCKNAME;
  114. /*
  115. ** DeviceIoCtrl functions. See memmon.c / psapi.c for usage.
  116. */
  117. #define MEMMON_DIOC_FindFirstVxD 0x80
  118. #define MEMMON_DIOC_FindNextVxD 0x81
  119. #define MEMMON_DIOC_GetVxDLoadInfo 0x82
  120. #define MEMMON_DIOC_GetFirstContext 0x83
  121. #define MEMMON_DIOC_GetNextContext 0x84
  122. #define MEMMON_DIOC_GetContextInfo 0x85
  123. #define MEMMON_DIOC_SetBuffer 0x86
  124. #define MEMMON_DIOC_FreeBuffer 0x87
  125. #define MEMMON_DIOC_PageInfo 0x88
  126. #define MEMMON_DIOC_WatchProcess 0x89
  127. #define MEMMON_DIOC_GetChanges 0x8A
  128. #define MEMMON_DIOC_QueryWS 0x8B
  129. #define MEMMON_DIOC_EmptyWS 0x8C
  130. #define MEMMON_DIOC_GetHeapSize 0x8D
  131. #define MEMMON_DIOC_GetHeapList 0x8E
  132. #define MEMMON_DIOC_GetSysInfo 0x8F
  133. #define MEMMON_DIOC_AddName 0x90
  134. #define MEMMON_DIOC_RemoveName 0x91
  135. #define MEMMON_DIOC_GetFirstName 0x92
  136. #define MEMMON_DIOC_GetNextName 0x93
  137. /*
  138. ** Flags returned in GetBlockInfo and PageInfo calls
  139. */
  140. #define MEMMON_Present 0x01
  141. #define MEMMON_Committed 0x02
  142. #define MEMMON_Accessed 0x04
  143. #define MEMMON_Writeable 0x08
  144. #define MEMMON_Phys 0x10
  145. #define MEMMON_Lock 0x20
  146. /*
  147. ** Flags used for heap analysis
  148. */
  149. #define MEMMON_HEAPLOCK 0x00000000
  150. #define MEMMON_HEAPSWAP 0x00000200
  151. #define MEMMON_HP_FREE 0x00000001
  152. #define MEMMON_HP_VALID 0x00000002
  153. #define MEMMON_HP_FLAGS 0x00000003
  154. #define MEMMON_HP_ADDRESS 0xFFFFFFFC
  155. /*
  156. ** Function prototypes (memmon.c)
  157. */
  158. int OpenMemmon( void );
  159. void CloseMemmon( void );
  160. int FindFirstVxD( VxDInfo * info );
  161. int FindNextVxD( VxDInfo * info );
  162. int GetVxDLoadInfo( VxDLoadInfo * info, int handle, int size );
  163. int GetFirstContext( ContextInfo * context, BOOL bIgnoreStatus );
  164. int GetNextContext( ContextInfo * context, BOOL bIgnoreStatus );
  165. int GetContextInfo( int context, BlockRecord * info, int numblocks );
  166. int GetLockInfo( unsigned uAddr, unsigned uProcessID, char * pBuffer );
  167. void * SetBuffer( int pages );
  168. int FreeBuffer( void );
  169. int GetPageInfo( unsigned, unsigned, unsigned, char * );
  170. int ClearAccessed( unsigned, unsigned, unsigned );
  171. void GetHeapSizeEstimate( unsigned *, unsigned * );
  172. int GetHeapList( unsigned *, unsigned, unsigned );
  173. int GetSysInfo( PSYSINFO );
  174. int AddName( unsigned uAddress, char * pszName );
  175. int RemoveName( unsigned uAddress );
  176. int GetFirstName( ContextInfo * pContext, PBLOCKNAME pBlock );
  177. int GetNextName( PBLOCKNAME pBlock );