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.

434 lines
10 KiB

  1. /*++
  2. Copyright (c) 2000 Microsoft Corporation
  3. Module Name:
  4. spptdump.c
  5. Abstract:
  6. Various dump routines for partition, disk and
  7. file system information
  8. Author:
  9. Vijay Jayaseelan (vijayj)
  10. Revision History:
  11. None
  12. --*/
  13. #include "spprecmp.h"
  14. #pragma hdrstop
  15. #include <initguid.h>
  16. #include <devguid.h>
  17. #include <diskguid.h>
  18. //
  19. // The dump level for dump routines
  20. //
  21. //#define PARTITION_DUMP_LEVEL DPFLTR_ERROR_LEVEL
  22. #define PARTITION_DUMP_LEVEL DPFLTR_INFO_LEVEL
  23. ULONG SPPT_DUMP_LEVEL = PARTITION_DUMP_LEVEL;
  24. PWSTR
  25. SpPtGuidToString(
  26. IN GUID* Guid,
  27. IN OUT PWSTR Buffer
  28. )
  29. /*++
  30. Routine Description:
  31. Converts a given GUID to string representation
  32. Arguments:
  33. Guid - The GUID that needs string representation
  34. Buffer - Place holder for string version of the GUID
  35. Return Value:
  36. Returns the converted string version of the given GUID
  37. --*/
  38. {
  39. if (Guid && Buffer) {
  40. swprintf(Buffer, L"(%x-%x-%x-%x%x%x%x%x%x%x%x)",
  41. Guid->Data1, Guid->Data2,
  42. Guid->Data3,
  43. Guid->Data4[0], Guid->Data4[1],
  44. Guid->Data4[2], Guid->Data4[3],
  45. Guid->Data4[4], Guid->Data4[5],
  46. Guid->Data4[6], Guid->Data4[7]);
  47. }
  48. if (!Guid && Buffer)
  49. *Buffer = UNICODE_NULL;
  50. return Buffer;
  51. }
  52. VOID
  53. SpPtDumpDiskRegion(
  54. IN PDISK_REGION Region
  55. )
  56. /*++
  57. Routine Description:
  58. Dumps the details for the given disk region
  59. Arguments:
  60. Region - The region whose information needs to be
  61. dumped
  62. Return Value:
  63. None
  64. --*/
  65. {
  66. if (Region) {
  67. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  68. "SETUP: Region:%p,DiskNumber=%d,PartitionNumber=%d,Sector-Start=%I64d,"
  69. "Sector-Count=%I64d,\nFreeSpace=%I64dKB,AdjustedFreeSpace=%I64dKB,"
  70. "FileSystem=%d,Partitioned:%d,Dirty:%d,Deleted:%d,EPType=%d,Container=%p,Sys:%d\n,"
  71. "DynVol=%d,DynVolSuitable=%d\n",
  72. Region,
  73. Region->DiskNumber,
  74. Region->PartitionNumber,
  75. Region->StartSector,
  76. Region->SectorCount,
  77. Region->FreeSpaceKB,
  78. Region->AdjustedFreeSpaceKB,
  79. Region->Filesystem,
  80. Region->PartitionedSpace,
  81. Region->Dirty,
  82. Region->Delete,
  83. Region->ExtendedType,
  84. Region->Container,
  85. Region->IsSystemPartition,
  86. Region->DynamicVolume,
  87. Region->DynamicVolumeSuitableForOS
  88. ));
  89. }
  90. }
  91. VOID
  92. SpPtDumpDiskRegionInformation(
  93. IN ULONG DiskNumber,
  94. IN BOOLEAN ExtendedRegionAlso
  95. )
  96. /*++
  97. Routine Description:
  98. Dumps all the regions for the given disk
  99. Arguments:
  100. DiskNumber : Disk whose regions need to be dumped
  101. ExtenededRegionAlso : Whether the extended region also
  102. needs to be dumped.
  103. Return Value:
  104. None
  105. --*/
  106. {
  107. if (DiskNumber < HardDiskCount) {
  108. PDISK_REGION Region = PartitionedDisks[DiskNumber].PrimaryDiskRegions;
  109. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  110. "SETUP: Dumping Primary Regions for DiskNumber=%d\n",
  111. DiskNumber));
  112. while (Region) {
  113. SpPtDumpDiskRegion(Region);
  114. Region = Region->Next;
  115. }
  116. if (ExtendedRegionAlso) {
  117. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  118. "SETUP: Dumping Extended Regions for DiskNumber=%d\n",
  119. DiskNumber));
  120. Region = PartitionedDisks[DiskNumber].ExtendedDiskRegions;
  121. while (Region) {
  122. SpPtDumpDiskRegion(Region);
  123. Region = Region->Next;
  124. }
  125. }
  126. }
  127. }
  128. VOID
  129. SpPtDumpDiskDriveInformation(
  130. IN BOOLEAN ExtenedRegionAlso
  131. )
  132. /*++
  133. Routine Description:
  134. Dumps the region information for all the disks
  135. Arguments:
  136. ExtendedRegionAlso : Indicates whether to dump the
  137. regions in the exteneded region
  138. or not
  139. Return Value:
  140. None
  141. --*/
  142. {
  143. ULONG DiskNumber;
  144. PDISK_REGION pDiskRegion;
  145. for ( DiskNumber=0; DiskNumber<HardDiskCount; DiskNumber++ ) {
  146. SpPtDumpDiskRegionInformation(DiskNumber, ExtenedRegionAlso);
  147. }
  148. }
  149. VOID
  150. SpPtDumpPartitionInformation(
  151. IN PPARTITION_INFORMATION_EX PartInfo
  152. )
  153. /*++
  154. Routine Description:
  155. Dumps all the information in the given PARTITION_INFORMATION_EX
  156. structure (header all the partition entries)
  157. Arguments:
  158. PartInfo - The partition information structure that needs to
  159. be dumped
  160. Return Value:
  161. None
  162. --*/
  163. {
  164. if (PartInfo) {
  165. PPARTITION_INFORMATION_MBR MbrInfo;
  166. PPARTITION_INFORMATION_GPT GptInfo;
  167. WCHAR GuidBuffer1[256];
  168. WCHAR GuidBuffer2[256];
  169. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  170. "SETUP: PartitionInformation = Number:%d, Style:%ws,"
  171. "Start=%I64u, Length = %I64u, Rewrite:%d\n",
  172. PartInfo->PartitionNumber,
  173. SPPT_GET_PARTITION_STYLE_STR(PartInfo->PartitionStyle),
  174. PartInfo->StartingOffset.QuadPart,
  175. PartInfo->PartitionLength.QuadPart,
  176. PartInfo->RewritePartition));
  177. switch (PartInfo->PartitionStyle) {
  178. case PARTITION_STYLE_MBR:
  179. MbrInfo = &(PartInfo->Mbr);
  180. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  181. "Type:%d,Active:%d,Recognized:%d,HiddenSectors:%d\n",
  182. MbrInfo->PartitionType,
  183. MbrInfo->BootIndicator,
  184. MbrInfo->RecognizedPartition,
  185. MbrInfo->HiddenSectors));
  186. break;
  187. case PARTITION_STYLE_GPT:
  188. GptInfo = &(PartInfo->Gpt);
  189. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  190. "Type:%ws,Id:%ws,Attributes:%I64X,Name:%ws\n",
  191. SpPtGuidToString(&GptInfo->PartitionType, GuidBuffer1),
  192. SpPtGuidToString(&GptInfo->PartitionId, GuidBuffer2),
  193. GptInfo->Attributes,
  194. GptInfo->Name));
  195. break;
  196. default:
  197. break;
  198. }
  199. }
  200. }
  201. VOID
  202. SpPtDumpDriveLayoutInformation(
  203. IN PWSTR DevicePath,
  204. IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout
  205. )
  206. /*++
  207. Routine Description:
  208. Dumps the drive layout information for the given
  209. device
  210. Arguments:
  211. DevicePath - The device whose drive layout is being
  212. dumped
  213. DriveLayout - The drive layout structure that needs to
  214. be dumped
  215. Return Value:
  216. None
  217. --*/
  218. {
  219. if (DriveLayout) {
  220. ULONG Index;
  221. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  222. "\nSETUP: Drive layout for %ws with %d partitions (%ws)\n",
  223. DevicePath,
  224. DriveLayout->PartitionCount,
  225. SPPT_GET_PARTITION_STYLE_STR(DriveLayout->PartitionStyle)
  226. ));
  227. if (DriveLayout->PartitionStyle == PARTITION_STYLE_MBR) {
  228. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  229. "Signature:%X\n", DriveLayout->Mbr.Signature));
  230. } else {
  231. WCHAR GuidBuffer[256];
  232. PDRIVE_LAYOUT_INFORMATION_GPT Gpt = &(DriveLayout->Gpt);
  233. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  234. "Disk Guid:%ws,Starting Usable Offset:%I64d,Usable Length:%I64d,"
  235. "MaxPartitionCount:%u\n",
  236. SpPtGuidToString(&Gpt->DiskId, GuidBuffer),
  237. Gpt->StartingUsableOffset.QuadPart,
  238. Gpt->UsableLength.QuadPart,
  239. Gpt->MaxPartitionCount));
  240. }
  241. for (Index=0; Index < DriveLayout->PartitionCount; Index++) {
  242. SpPtDumpPartitionInformation(&(DriveLayout->PartitionEntry[Index]));
  243. }
  244. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL, "\n"));
  245. }
  246. }
  247. VOID
  248. SpPtDumpFSAttributes(
  249. IN PFILE_FS_ATTRIBUTE_INFORMATION FsAttrs
  250. )
  251. /*++
  252. Routine Description:
  253. Dumps the given file system attribute information
  254. structure.
  255. Arguments:
  256. FsAttrs : The file system attribute information structure
  257. that needs to be dumped
  258. Return Value:
  259. None
  260. --*/
  261. {
  262. if (FsAttrs) {
  263. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  264. "SETUP: File System Attributes = Attrs:%lX,MaxCompNameLen=%d,Name:%ws\n",
  265. FsAttrs->FileSystemAttributes,
  266. FsAttrs->MaximumComponentNameLength,
  267. FsAttrs->FileSystemName));
  268. }
  269. }
  270. VOID
  271. SpPtDumpFSSizeInfo(
  272. IN PFILE_FS_SIZE_INFORMATION FsSize
  273. )
  274. /*++
  275. Routine Description:
  276. Dumps the give file size information structure
  277. Arguments:
  278. FsSize : The file size information structure that needs to
  279. be dumped
  280. Return Value:
  281. None
  282. --*/
  283. {
  284. if (FsSize) {
  285. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  286. "SETUP: File System Size Info = TotalUnits:%I64u, AvailUnits:%I64u,"
  287. "Sectors/Unit:%u,Bytes/Sector:%u\n",
  288. FsSize->TotalAllocationUnits.QuadPart,
  289. FsSize->AvailableAllocationUnits.QuadPart,
  290. FsSize->SectorsPerAllocationUnit,
  291. FsSize->BytesPerSector
  292. ));
  293. }
  294. }
  295. VOID
  296. SpPtDumpFSVolumeInfo(
  297. IN PFILE_FS_VOLUME_INFORMATION FsVolInfo
  298. )
  299. /*++
  300. Routine Description:
  301. Dumps the give volume information structure
  302. Arguments:
  303. FsVolInfo : The volume information structure that
  304. needs to be dumped
  305. Return Value:
  306. None
  307. --*/
  308. {
  309. if (FsVolInfo) {
  310. KdPrintEx(( DPFLTR_SETUP_ID, SPPT_DUMP_LEVEL,
  311. "SETUP: File System Vol Info = CreationTime:%I64X, Serial#:%d\n",
  312. "SupportsObject:%d, Name:%ws\n",
  313. FsVolInfo->VolumeCreationTime.QuadPart,
  314. FsVolInfo->VolumeSerialNumber,
  315. FsVolInfo->SupportsObjects,
  316. FsVolInfo->VolumeLabel
  317. ));
  318. }
  319. }