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.

193 lines
3.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1992 - 1999
  5. //
  6. // File: PCH.cxx
  7. //
  8. // Contents: Pre-compiled header
  9. //
  10. // History: 21-Dec-92 BartoszM Created
  11. //
  12. //--------------------------------------------------------------------------
  13. #include <nt.h>
  14. #include <ntrtl.h>
  15. #include <nturtl.h>
  16. #include <windows.h>
  17. #include <ntosp.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include <scsi.h>
  22. #include <srb.h>
  23. #define KDEXT_64BIT
  24. #include <wdbgexts.h>
  25. #include <dbgeng.h>
  26. #ifdef __cplusplus
  27. extern "C" {
  28. #endif
  29. //
  30. // undef the wdbgexts
  31. //
  32. #undef DECLARE_API
  33. #define DECLARE_API(extension) \
  34. CPPMOD HRESULT CALLBACK extension(PDEBUG_CLIENT Client, PCSTR args)
  35. #define INIT_API() \
  36. HRESULT Status; \
  37. if ((Status = ExtQuery(Client)) != S_OK) return Status;
  38. // Safe release and NULL.
  39. #define EXT_RELEASE(Unk) \
  40. ((Unk) != NULL ? ((Unk)->Release(), (Unk) = NULL) : NULL)
  41. // Global variables initialized by query.
  42. extern PDEBUG_ADVANCED g_ExtAdvanced;
  43. extern PDEBUG_CLIENT g_ExtClient;
  44. extern PDEBUG_CONTROL g_ExtControl;
  45. extern PDEBUG_DATA_SPACES g_ExtData;
  46. extern PDEBUG_REGISTERS g_ExtRegisters;
  47. extern PDEBUG_SYMBOLS g_ExtSymbols;
  48. extern PDEBUG_SYSTEM_OBJECTS g_ExtSystem;
  49. HRESULT
  50. ExtQuery(PDEBUG_CLIENT Client);
  51. void
  52. ExtRelease(void);
  53. #define EXIT_API ExtRelease
  54. extern WINDBG_EXTENSION_APIS ExtensionApis;
  55. #define SCSIKD_PRINT_ERROR(r)\
  56. dprintf("scsikd error (%x): %s @ line %d\n", (r), __FILE__, __LINE__);
  57. #define RECUR DBG_DUMP_FIELD_RECUR_ON_THIS
  58. #define F_ADDR DBG_DUMP_FIELD_RETURN_ADDRESS
  59. #define COPY DBG_DUMP_FIELD_FULL_NAME | DBG_DUMP_FIELD_COPY_FIELD_DATA | DBG_DUMP_FIELD_RETURN_ADDRESS
  60. #define ADDROF DBG_DUMP_FIELD_RETURN_ADDRESS | DBG_DUMP_FIELD_FULL_NAME
  61. // Stolen from ntrtl.h to override RECOMASSERT
  62. #undef ASSERT
  63. #undef ASSERTMSG
  64. #if DBG
  65. #define ASSERT( exp ) \
  66. if (!(exp)) \
  67. RtlAssert( #exp, __FILE__, __LINE__, NULL )
  68. #define ASSERTMSG( msg, exp ) \
  69. if (!(exp)) \
  70. RtlAssert( #exp, __FILE__, __LINE__, msg )
  71. #else
  72. #define ASSERT( exp )
  73. #define ASSERTMSG( msg, exp )
  74. #endif // DBG
  75. #define OFFSET(struct, elem) ((char *) &(struct->elem) - (char *) struct)
  76. #define _DRIVER
  77. //#define KDBG_EXT
  78. #include "wmistr.h"
  79. #define PRINT_FLAGS(Flags,b) if (Flags & b) {dprintf(#b", ");}
  80. __inline
  81. VOID
  82. xdindent(
  83. ULONG Depth
  84. )
  85. {
  86. ULONG i;
  87. for (i=0; i<Depth; i++)
  88. dprintf(" ");
  89. }
  90. #define xdprintfEx(d, expr)\
  91. xdindent((d));\
  92. dprintf expr
  93. typedef struct {
  94. ULONG Flag;
  95. PUCHAR Name;
  96. } FLAG_NAME, *PFLAG_NAME;
  97. #define FLAG_NAME(flag) {flag, #flag}
  98. extern FLAG_NAME SrbFlags[];
  99. PUCHAR
  100. DevicePowerStateToString(
  101. IN DEVICE_POWER_STATE State
  102. );
  103. VOID
  104. GetAddressAndDetailLevel(
  105. IN PCSTR Args,
  106. OUT PULONG64 Address,
  107. OUT PLONG Detail
  108. );
  109. VOID
  110. GetAddressAndDetailLevel64(
  111. IN PCSTR Args,
  112. OUT PULONG64 Address,
  113. OUT PLONG Detail
  114. );
  115. VOID
  116. GetAddress(
  117. IN PCSTR Args,
  118. OUT PULONG64 Address
  119. );
  120. PUCHAR
  121. SystemPowerStateToString(
  122. IN DEVICE_POWER_STATE State
  123. );
  124. VOID
  125. xdprintf(
  126. ULONG Depth,
  127. PCCHAR S,
  128. ...
  129. );
  130. VOID
  131. DumpFlags(
  132. ULONG Depth,
  133. PUCHAR Name,
  134. ULONG Flags,
  135. PFLAG_NAME FlagTable
  136. );
  137. BOOLEAN
  138. GetAnsiString(
  139. IN ULONG64 Address,
  140. IN PUCHAR Buffer,
  141. IN OUT PULONG Length
  142. );
  143. PCHAR
  144. GuidToString(
  145. GUID* GUID
  146. );
  147. ULONG64
  148. GetDeviceExtension(
  149. ULONG64 address
  150. );
  151. #ifdef __cplusplus
  152. }
  153. #endif