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.

124 lines
3.7 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation
  3. Module Name:
  4. dump.cpp
  5. Abstract:
  6. Merge/refactor stuff in sxstest with dumpers.cpp
  7. Eventually merge with debug extensions, let it be optionally
  8. driven by symbol info available to debug extensions via .pdbs.
  9. Author:
  10. Jay Krell (JayKrell) November 2001
  11. Revision History:
  12. --*/
  13. #include "nt.h"
  14. #include "ntrtl.h"
  15. #include "nturtl.h"
  16. #include "windows.h"
  17. #include "fusiondump.h"
  18. #include "fusiontrace.h"
  19. #include "fusionstring.h"
  20. #if DBG // until we work out factoring between sxs.dll, sxstest.dll, fusiondbg.dll.
  21. typedef const BYTE * PCBYTE;
  22. BOOL
  23. FusionpDumpStruct(
  24. PCFUSIONP_DUMP_CALLBACKS Callbacks,
  25. PCFUSIONP_DUMP_BUILTIN_SYMBOLS_STRUCT TypeInfo,
  26. ULONG64 pint,
  27. PCSTR Name,
  28. const ULONG64 * Bases
  29. )
  30. {
  31. //
  32. // This code currently runs inproc, but it should be transitioned to
  33. // run in a debugger, or to do either, based on "builtin typeinfo" vs.
  34. // availability of .pdb.
  35. //
  36. typedef FUSIONP_DUMP_BUILTIN_SYMBOLS_FIELD FIELD;
  37. FN_PROLOG_WIN32
  38. ULONG MaxNameLength = 0;
  39. ULONG i = 0;
  40. CAnsiString AnsiStringField;
  41. CAnsiString AnsiStringStruct(Name);
  42. LARGE_INTEGER li = { 0 };
  43. PCWSTR s = 0;
  44. PCBYTE Base = 0;
  45. const FIELD * Field = 0;
  46. const FIELD * FieldEnd = 0;
  47. const FIELD * Fields = TypeInfo->Fields;
  48. PCBYTE p = reinterpret_cast<const BYTE*>(static_cast<ULONG_PTR>(pint));
  49. for ( FieldEnd = Fields ; FieldEnd->Name ; ++FieldEnd )
  50. {
  51. /* nothing */
  52. }
  53. for ( Field = Fields ; Field != FieldEnd ; ++Field )
  54. {
  55. if (Field->NameLength > MaxNameLength)
  56. MaxNameLength = Field->NameLength;
  57. }
  58. for ( Field = Fields ; Field != FieldEnd ; ++Field )
  59. {
  60. AnsiStringField.Buffer = const_cast<PSTR>(Field->Name);
  61. AnsiStringField.Length = Field->NameLength;
  62. switch (Field->Type & 0x0F)
  63. {
  64. case FUSIONP_DUMP_TYPE_ULONG:
  65. PARAMETER_CHECK(Field->Size == sizeof(ULONG));
  66. i = *reinterpret_cast<const ULONG*>(p + Field->Offset);
  67. Callbacks->Printf("%Z.%-*Z: 0x%lx (0n%lu)\n",
  68. &AnsiStringStruct,
  69. static_cast<int>(MaxNameLength + 1),
  70. &AnsiStringField,
  71. i,
  72. i
  73. );
  74. break;
  75. case FUSIONP_DUMP_TYPE_ULONG_OFFSET_TO_PCWSTR:
  76. PARAMETER_CHECK(Field->Size == sizeof(ULONG));
  77. i = *reinterpret_cast<const ULONG*>(p + Field->Offset);
  78. Base = reinterpret_cast<PCBYTE>(static_cast<ULONG_PTR>(Bases[(Field->Type >> 4) & 0x0F]));
  79. s = (i != 0) ? reinterpret_cast<PCWSTR>(Base + i) : L"";
  80. Callbacks->Printf("%Z.%-*Z: %ls (base 0x%I64x + offset 0x%lx (0n%lu))\n",
  81. &AnsiStringStruct,
  82. static_cast<int>(MaxNameLength + 1),
  83. &AnsiStringField,
  84. s,
  85. Base,
  86. i,
  87. i
  88. );
  89. break;
  90. case FUSIONP_DUMP_TYPE_LARGE_INTEGER_TIME:
  91. PARAMETER_CHECK(Field->Size == sizeof(LARGE_INTEGER));
  92. li = *reinterpret_cast<const LARGE_INTEGER*>(p + Field->Offset);
  93. Callbacks->Printf("%Z.%-*Z: %s (0x%I64x (0n%I64u))\n",
  94. &AnsiStringStruct,
  95. static_cast<int>(MaxNameLength + 1),
  96. &AnsiStringField,
  97. Callbacks->FormatTime(li),
  98. li.QuadPart,
  99. li.QuadPart
  100. );
  101. break;
  102. }
  103. }
  104. FN_EPILOG;
  105. }
  106. #endif