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.

400 lines
11 KiB

  1. /*++
  2. Copyright (c) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. inetdbgp.h
  5. Abstract:
  6. Common header file for NTSDEXTS component source files.
  7. Author:
  8. Murali Krishnan (MuraliK) 22-Aug-1996
  9. Revision History:
  10. --*/
  11. # ifndef _INETDBGP_H_
  12. # define _INETDBGP_H_
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #undef IF_DEBUG
  17. #include <windows.h>
  18. #include <ntsdexts.h>
  19. // TODO: use wdbgexts.h instead of ntsdexts.h
  20. // #include <wdbgexts.h>
  21. #include <stdio.h>
  22. #include <stdlib.h>
  23. #include <string.h>
  24. #include <wchar.h>
  25. #include <stdlib.h>
  26. //
  27. // To obtain the private & protected members of C++ class,
  28. // let me fake the "private" keyword
  29. //
  30. # define private public
  31. # define protected public
  32. //
  33. // Turn off dllexp et al so this DLL won't export tons of unnecessary garbage.
  34. //
  35. #define dllexp
  36. #undef _NTDDK_
  37. #undef _WMIKM_
  38. #define IRTL_DLLEXP
  39. #define IRTL_EXPIMP
  40. #define DLL_IMPLEMENTATION
  41. #define IMPLEMENTATION_EXPORT
  42. # include <dbgutil.h>
  43. // undef these so that we can avoid linking with iisrtl
  44. # undef DBG_ASSERT
  45. # define DBG_ASSERT(exp) ((void)0) /* Do Nothing */
  46. # undef SET_CRITICAL_SECTION_SPIN_COUNT
  47. # define SET_CRITICAL_SECTION_SPIN_COUNT(lpCS, dwSpins) \
  48. SetCriticalSectionSpinCount(lpCS, dwSpins)
  49. # undef INITIALIZE_CRITICAL_SECTION
  50. # define INITIALIZE_CRITICAL_SECTION(lpCS) \
  51. InitializeCriticalSection(lpCS)
  52. # undef INITIALIZE_CRITICAL_SECTION_SPIN
  53. # define INITIALIZE_CRITICAL_SECTION_SPIN(lpCS, dwSpin) \
  54. InitializeCriticalSectionAndSpinCount(lpCS, dwSpin)
  55. #include <lkrhash.h>
  56. # include <reftrace.h>
  57. # include <strlog.hxx>
  58. # include <atq.h>
  59. # include <atqtypes.hxx>
  60. # include <acache.hxx>
  61. # include <iistypes.hxx>
  62. # include <iis64.h>
  63. # include <timer.h>
  64. # include <issched.hxx>
  65. # include <sched.hxx>
  66. # include <w3p.hxx>
  67. # define _IIS_TYPES_HXX_
  68. typedef class IIS_SERVER_INSTANCE *PIIS_SERVER_INSTANCE;
  69. # include <tsunamip.hxx>
  70. # include <filehash.hxx>
  71. # include <filecach.hxx>
  72. /************************************************************
  73. * Macro Definitions
  74. ************************************************************/
  75. // Set IISRTL_NAME to the name of the DLL hosting the IIS RunTime Library
  76. #define IISRTL_NAME "iisrtl"
  77. // #define IISRTL_NAME "misrtl"
  78. // #define IISRTL_NAME "gisrtl"
  79. // TODO: make this variable configurable
  80. extern CHAR g_szIisRtlName[MAX_PATH];
  81. LPSTR
  82. IisRtlVar(
  83. LPCSTR pszFormat);
  84. // For use as arguments to '%c%c%c%c'
  85. #define DECODE_SIGNATURE(dw) \
  86. isprint(((dw) >> 0) & 0xFF) ? (((dw) >> 0) & 0xFF) : '?', \
  87. isprint(((dw) >> 8) & 0xFF) ? (((dw) >> 8) & 0xFF) : '?', \
  88. isprint(((dw) >> 16) & 0xFF) ? (((dw) >> 16) & 0xFF) : '?', \
  89. isprint(((dw) >> 24) & 0xFF) ? (((dw) >> 24) & 0xFF) : '?'
  90. #define move(dst, src)\
  91. __try {\
  92. ReadMemory((LPVOID) (src), &(dst), sizeof(dst), NULL);\
  93. } __except (EXCEPTION_EXECUTE_HANDLER) {\
  94. return;\
  95. }
  96. #define moveBlock(dst, src, size)\
  97. __try {\
  98. ReadMemory((LPVOID) (src), &(dst), (size), NULL);\
  99. } __except (EXCEPTION_EXECUTE_HANDLER) {\
  100. return;\
  101. }
  102. #define MoveWithRet(dst, src, retVal)\
  103. __try {\
  104. ReadMemory((LPVOID) (src), &(dst), sizeof(dst), NULL);\
  105. } __except (EXCEPTION_EXECUTE_HANDLER) {\
  106. return retVal;\
  107. }
  108. #define MoveBlockWithRet(dst, src, size, retVal)\
  109. __try {\
  110. ReadMemory((LPVOID) (src), &(dst), (size), NULL);\
  111. } __except (EXCEPTION_EXECUTE_HANDLER) {\
  112. return retVal;\
  113. }
  114. #ifdef __cplusplus
  115. #define CPPMOD extern "C"
  116. #else
  117. #define CPPMOD
  118. #endif
  119. #ifndef DECLARE_API
  120. # define DECLARE_API(s) \
  121. CPPMOD VOID \
  122. s( \
  123. HANDLE hCurrentProcess, \
  124. HANDLE hCurrentThread, \
  125. DWORD dwCurrentPc, \
  126. PNTSD_EXTENSION_APIS lpExtensionApis, \
  127. LPSTR lpArgumentString \
  128. )
  129. #endif
  130. #define INIT_API() { \
  131. ExtensionApis = *lpExtensionApis; \
  132. ExtensionCurrentProcess = hCurrentProcess; \
  133. }
  134. #define dprintf (ExtensionApis.lpOutputRoutine)
  135. #define GetExpression (ExtensionApis.lpGetExpressionRoutine)
  136. #define GetSymbol (ExtensionApis.lpGetSymbolRoutine)
  137. #define Disasm (ExtensionApis.lpDisasmRoutine)
  138. #define CheckControlC (ExtensionApis.lpCheckControlCRoutine)
  139. #define ReadMemory(a,b,c,d) ReadProcessMemory( ExtensionCurrentProcess, (LPCVOID)(a), (b), (c), (d) )
  140. #define WriteMemory(a,b,c,d) WriteProcessMemory( ExtensionCurrentProcess, (LPVOID)(a), (LPVOID)(b), (c), (d) )
  141. #ifndef malloc
  142. # define malloc( n ) HeapAlloc( GetProcessHeap(), 0, (n) )
  143. #endif
  144. #ifndef calloc
  145. # define calloc( n , s) HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, (n)*(s) )
  146. #endif
  147. #ifndef realloc
  148. # define realloc( p, n ) HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, (p), (n) )
  149. #endif
  150. #ifndef free
  151. # define free( p ) HeapFree( GetProcessHeap(), 0, (p) )
  152. #endif
  153. #define NUM_STACK_SYMBOLS_TO_DUMP 48
  154. #define MAX_SYMBOL_LEN 1024
  155. # define BoolValue( b) ((b) ? " TRUE" : " FALSE")
  156. #define DumpDword( symbol ) \
  157. { \
  158. ULONG_PTR dw = GetExpression( "&" symbol ); \
  159. ULONG_PTR dwValue = 0; \
  160. \
  161. if ( dw ) \
  162. { \
  163. if ( ReadMemory( (LPVOID) dw, \
  164. &dwValue, \
  165. sizeof(dwValue), \
  166. NULL )) \
  167. { \
  168. dprintf( "\t" symbol " = %8d (0x%p)\n", \
  169. dwValue, \
  170. dwValue ); \
  171. } \
  172. } \
  173. }
  174. //
  175. // C++ Structures typically require the constructors and most times
  176. // we may not have default constructors
  177. // => trouble in defining a copy of these struct/class inside the
  178. // Debugger extension DLL for debugger process
  179. // So we will define them as CHARACTER arrays with appropriate sizes.
  180. // This is okay, since we are not really interested in structure as is,
  181. // however, we will copy over data block from the debuggee process to
  182. // these structure variables in the debugger process.
  183. //
  184. # define DEFINE_CPP_VAR( className, classVar) \
  185. CHAR classVar[sizeof(className)]
  186. # define GET_CPP_VAR_PTR( className, classVar) \
  187. (className * ) &classVar
  188. /************************************************************
  189. * Prototype Definitions
  190. ************************************************************/
  191. extern NTSD_EXTENSION_APIS ExtensionApis;
  192. extern HANDLE ExtensionCurrentProcess;
  193. VOID dstring( CHAR * pszName, PVOID pvString, DWORD cbLen);
  194. VOID PrintLargeInteger( CHAR * pszName, LARGE_INTEGER * pli);
  195. VOID Print2Dwords( CHAR * pszN1, DWORD d1,
  196. CHAR * pszN2, DWORD d2
  197. );
  198. VOID PrintUsage( IN PSTR CommandName );
  199. //
  200. // Determine if a linked list is empty.
  201. //
  202. #define IS_LIST_EMPTY( localaddr, remoteaddr, type, fieldname ) \
  203. ( ((type *)(localaddr))->fieldname.Flink == \
  204. (PLIST_ENTRY)( (remoteaddr) + \
  205. FIELD_OFFSET( type, fieldname ) ) )
  206. //
  207. // Module enumerator.
  208. //
  209. typedef struct _MODULE_INFO {
  210. ULONG_PTR DllBase;
  211. ULONG_PTR EntryPoint;
  212. ULONG SizeOfImage;
  213. CHAR BaseName[MAX_PATH];
  214. CHAR FullName[MAX_PATH];
  215. } MODULE_INFO, *PMODULE_INFO;
  216. typedef
  217. BOOLEAN
  218. (CALLBACK * PFN_ENUMMODULES)(
  219. IN PVOID Param,
  220. IN PMODULE_INFO ModuleInfo
  221. );
  222. BOOLEAN
  223. EnumModules(
  224. IN PFN_ENUMMODULES EnumProc,
  225. IN PVOID Param
  226. );
  227. BOOLEAN
  228. FindModuleByAddress(
  229. IN ULONG_PTR ModuleAddress,
  230. OUT PMODULE_INFO ModuleInfo
  231. );
  232. //
  233. // Enumerator for NT's standard doubly linked list LIST_ENTRY
  234. //
  235. // PFN_LIST_ENUMERATOR
  236. // This is the callback function for printing the CLIENT_CONN object.
  237. //
  238. // Arguments:
  239. // pvDebuggee - pointer to object in the debuggee process
  240. // pvDebugger - pointer to object in the debugger process
  241. // verbosity - character indicating the verbosity level desired
  242. //
  243. typedef
  244. VOID
  245. (CALLBACK * PFN_LIST_ENUMERATOR)(
  246. IN PVOID pvDebugee,
  247. IN PVOID pvDebugger,
  248. IN CHAR chVerbosity, //verbosity value supplied for the enumerator
  249. IN DWORD iCount //index for the item being enumerated
  250. );
  251. BOOL
  252. EnumLinkedList(
  253. IN LIST_ENTRY * pListHead,
  254. IN PFN_LIST_ENUMERATOR pfnListEnumerator,
  255. IN CHAR chVerbosity,
  256. IN DWORD cbSizeOfStructure,
  257. IN DWORD cbListEntryOffset
  258. );
  259. // Enumerator for an LKRhash table node entry
  260. class CLKRLinearHashTable;
  261. class CLKRHashTable;
  262. typedef
  263. BOOL
  264. (CALLBACK * PFN_ENUM_LKRHASH)(
  265. IN const void* pvParam,
  266. IN DWORD dwSignature,
  267. IN INT nVerbose);
  268. BOOL
  269. EnumerateLKRhashTable(
  270. IN PFN_ENUM_LKRHASH pfnEnum,
  271. IN CLKRHashTable* pht,
  272. IN INT nVerbose);
  273. BOOL
  274. EnumerateLKRLinearHashTable(
  275. IN PFN_ENUM_LKRHASH pfnEnum,
  276. IN CLKRLinearHashTable* plht,
  277. IN INT nVerbose);
  278. // Functions from dbglocks.cxx
  279. const char*
  280. LockName(
  281. LOCK_LOCKTYPE lt);
  282. int
  283. LockSize(
  284. LOCK_LOCKTYPE lt);
  285. BOOL
  286. PrintLock(
  287. LOCK_LOCKTYPE lt,
  288. IN PVOID pvLock,
  289. IN INT nVerbose);
  290. // Call debugger extension in other extension DLL
  291. typedef VOID (_stdcall *PWINDBG_EXTENSION_FUNCTION)(
  292. HANDLE, HANDLE, ULONG, ULONG, PCSTR);
  293. #define DO_EXTENSION(szModule, szCommand, szArgs) \
  294. CallExtension((szModule), (szCommand), hCurrentProcess, hCurrentThread,\
  295. dwCurrentPc, dwProcessor, (szArgs))
  296. NTSTATUS
  297. CallExtension(
  298. PCSTR szModuleName,
  299. PCSTR szFunction,
  300. HANDLE hCurrentProcess,
  301. HANDLE hCurrentThread,
  302. ULONG dwCurrentPc,
  303. ULONG dwProcessor,
  304. PCSTR args);
  305. /***********************************************************************
  306. * w3svc's CLIENT_CONN functions needed by other objects
  307. **********************************************************************/
  308. // Walks and dumps information for the client-conn list
  309. VOID DumpClientConnList( CHAR Verbosity, PFN_LIST_ENUMERATOR pfnCC);
  310. # endif // _INETDBGP_H_