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.

185 lines
4.5 KiB

  1. /*++
  2. Copyright (c) 1992 Microsoft Corporation
  3. Module Name:
  4. kuser.c
  5. Abstract:
  6. WinDbg Extension Api
  7. Author:
  8. Ramon J San Andres (ramonsa) 5-Nov-1993
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "precomp.h"
  14. #pragma hdrstop
  15. VOID
  16. KUserExtension(
  17. PCSTR lpArgumentString,
  18. ULONG64 SharedData
  19. );
  20. DECLARE_API( kuser )
  21. /*++
  22. Routine Description:
  23. This function is called as an NTSD extension to dump the shared user mode
  24. page (KUSER_SHARED_DATA)
  25. Called as:
  26. !kuser
  27. Arguments:
  28. None
  29. Return Value:
  30. None
  31. --*/
  32. {
  33. INIT_API();
  34. KUserExtension( args, g_SharedUserData );
  35. EXIT_API();
  36. return S_OK;
  37. }
  38. char *DriveTypes[] = {
  39. "DOSDEVICE_DRIVE_UNKNOWN",
  40. "DOSDEVICE_DRIVE_CALCULATE",
  41. "DOSDEVICE_DRIVE_REMOVABLE",
  42. "DOSDEVICE_DRIVE_FIXED",
  43. "DOSDEVICE_DRIVE_REMOTE",
  44. "DOSDEVICE_DRIVE_CDROM",
  45. "DOSDEVICE_DRIVE_RAMDISK"
  46. };
  47. VOID
  48. KUserExtension(
  49. PCSTR lpArgumentString,
  50. ULONG64 SharedData
  51. )
  52. {
  53. BOOLEAN fFirst;
  54. ULONG i;
  55. WCHAR NtSystemRoot[MAX_PATH];
  56. ULONG TickCount;
  57. ULARGE_INTEGER TickCount64;
  58. try {
  59. if (InitTypeRead(SharedData, nt!_KUSER_SHARED_DATA))
  60. {
  61. dprintf("Cannot read _KUSER_SHARED_DATA @ %p\n", SharedData);
  62. __leave;
  63. }
  64. dprintf( "_KUSER_SHARED_DATA at %p\n", SharedData ),
  65. TickCount = (ULONG) ReadField(TickCountLow);
  66. if (TickCount) {
  67. dprintf( "TickCount: %x * %08x\n",
  68. (ULONG)ReadField(TickCountMultiplier),
  69. TickCount
  70. );
  71. } else {
  72. TickCount64.LowPart = (ULONG)ReadField(TickCount.LowPart);
  73. TickCount64.HighPart = (ULONG)ReadField(TickCount.High1Part);
  74. dprintf( "TickCount: %x * %016I64x\n",
  75. (ULONG)ReadField(TickCountMultiplier),
  76. TickCount64.QuadPart
  77. );
  78. }
  79. #if 0
  80. dprintf( "Interrupt Time: %x:%08x:%08x\n",
  81. (ULONG)ReadField(InterruptTime.High2Time),
  82. (ULONG)ReadField(InterruptTime.High1Time),
  83. (ULONG)ReadField(InterruptTime.LowPart)
  84. );
  85. dprintf( "System Time: %x:%08x:%08x\n",
  86. (ULONG)ReadField(SystemTime.High2Time),
  87. (ULONG)ReadField(SystemTime.High1Time),
  88. (ULONG)ReadField(SystemTime.LowPart)
  89. );
  90. dprintf( "TimeZone Bias: %x:%08x:%08x\n",
  91. (ULONG)ReadField(TimeZoneBias.High2Time),
  92. (ULONG)ReadField(TimeZoneBias.High1Time),
  93. (ULONG)ReadField(TimeZoneBias.LowPart)
  94. );
  95. #endif
  96. dprintf( "TimeZone Id: %x\n", (ULONG)ReadField(TimeZoneId) );
  97. dprintf( "ImageNumber Range: [%x .. %x]\n",
  98. (ULONG)ReadField(ImageNumberLow),
  99. (ULONG)ReadField(ImageNumberHigh)
  100. );
  101. dprintf( "Crypto Exponent: %x\n", (ULONG)ReadField(CryptoExponent) );
  102. GetFieldValue(SharedData, "nt!_KUSER_SHARED_DATA", "NtSystemRoot", NtSystemRoot);
  103. dprintf( "SystemRoot: '%ws'\n",
  104. NtSystemRoot
  105. );
  106. #if 0
  107. dprintf( "DosDeviceMap: %08x", (ULONG)ReadField(DosDeviceMap) );
  108. fFirst = TRUE;
  109. for (i=0; i<32; i++) {
  110. if ((ULONG)ReadField(DosDeviceMap) & (1 << i)) {
  111. if (fFirst) {
  112. dprintf( " (" );
  113. fFirst = FALSE;
  114. }
  115. else {
  116. dprintf( " " );
  117. }
  118. dprintf( "%c:", 'A'+i );
  119. }
  120. }
  121. if (!fFirst) {
  122. dprintf( ")" );
  123. }
  124. dprintf( "\n" );
  125. for (i=0; i<32; i++) {
  126. CHAR Field[40];
  127. ULONG DosDeviceDriveType;
  128. sprintf(Field, "DosDeviceDriveType[%d]", i);
  129. DosDeviceDriveType = (ULONG) GetShortField(0, Field, 0);
  130. if (DosDeviceDriveType > DOSDEVICE_DRIVE_UNKNOWN &&
  131. DosDeviceDriveType <= DOSDEVICE_DRIVE_RAMDISK
  132. ) {
  133. dprintf( "DriveType[ %02i ] (%c:) == %s\n",
  134. i, 'A'+i,
  135. DriveTypes[ DosDeviceDriveType ]
  136. );
  137. }
  138. }
  139. #endif
  140. } except (EXCEPTION_EXECUTE_HANDLER) {
  141. ;
  142. }
  143. }