36#ifdef DUMP_PARTITION_TABLE
46 DbgPrint(
"Index Start Length Hidden Nr Type Boot RW\n");
47 DbgPrint(
"----- ------------ ------------ ---------- -- ---- ---- --\n");
52 DbgPrint(
" %3lu %12I64u %12I64u %10lu %2lu %2x %c %c\n",
117 L"\\Scsi\\Scsi Port %hu",
134 DPRINT1(
"RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
153 Entry1 != &
List->DiskListHead;
154 Entry1 = Entry1->
Flink)
160 Entry2 = Entry2->
Flink)
181 Entry1 != &
List->DiskListHead;
182 Entry1 = Entry1->
Flink)
188 Entry2 = Entry2->
Flink)
315 if (*Int13Drives ==
NULL)
341#define ROOT_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter"
349 L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
355 DPRINT1(
"Unable to query the 'Configuration Data' key in '\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System', status=%lx\n",
Status);
359 for (AdapterCount = 0; ; ++AdapterCount)
375 L"%s\\%lu\\DiskController",
387 L"%s\\%lu\\DiskController\\%lu",
401 L"%s\\%lu\\DiskController\\%lu\\DiskPeripheral",
415 for (DiskCount = 0; ; ++DiskCount)
418 if (BiosDiskEntry ==
NULL)
425 L"%s\\%lu\\DiskController\\%lu\\DiskPeripheral\\%lu",
430 (
PVOID)BiosDiskEntry,
439 BiosDiskEntry->AdapterNumber = 0;
441 BiosDiskEntry->DiskNumber = DiskCount;
442 BiosDiskEntry->DiskEntry =
NULL;
444 if (DiskCount < Int13Drives[0].NumberDrives)
446 BiosDiskEntry->Int13DiskData = Int13Drives[DiskCount];
450 DPRINT1(
"Didn't find Int13 drive data for disk %u\n", DiskCount);
453 InsertTailList(&PartList->BiosDiskListHead, &BiosDiskEntry->ListEntry);
456 DPRINT(
"AdapterNumber: %lu\n", BiosDiskEntry->AdapterNumber);
457 DPRINT(
"ControllerNumber: %lu\n", BiosDiskEntry->ControllerNumber);
458 DPRINT(
"DiskNumber: %lu\n", BiosDiskEntry->DiskNumber);
459 DPRINT(
"Signature: %08lx\n", BiosDiskEntry->Signature);
460 DPRINT(
"Checksum: %08lx\n", BiosDiskEntry->Checksum);
461 DPRINT(
"BytesPerSector: %lu\n", BiosDiskEntry->DiskGeometry.BytesPerSector);
462 DPRINT(
"NumberOfCylinders: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfCylinders);
463 DPRINT(
"NumberOfHeads: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfHeads);
464 DPRINT(
"DriveSelect: %02x\n", BiosDiskEntry->Int13DiskData.DriveSelect);
465 DPRINT(
"MaxCylinders: %lu\n", BiosDiskEntry->Int13DiskData.MaxCylinders);
466 DPRINT(
"SectorsPerTrack: %d\n", BiosDiskEntry->Int13DiskData.SectorsPerTrack);
467 DPRINT(
"MaxHeads: %d\n", BiosDiskEntry->Int13DiskData.MaxHeads);
468 DPRINT(
"NumberDrives: %d\n", BiosDiskEntry->Int13DiskData.NumberDrives);
494 _In_ const DISK_PARTITION_INFO* DiskInfo,
514 if (DiskInfo->Mbr.Signature != 1)
516 DPRINT1(
"Super-Floppy signature %08x != 1\n", DiskInfo->Mbr.Signature);
524 DPRINT1(
"Super-Floppy does not return default settings:\n"
525 " RecognizedPartition = %s, expected TRUE\n"
526 " PartitionType = 0x%02x, expected 0x04 (PARTITION_FAT_16)\n"
527 " BootIndicator = %s, expected FALSE\n",
534 if (DiskSize && (
PartitionInfo->PartitionLength.QuadPart != *DiskSize))
536 DPRINT1(
"PartitionLength = %I64u is different from DiskSize = %I64u\n",
548 DISK_PARTITION_INFO DiskInfo;
551 if (Layout->PartitionCount != 1)
557 DiskInfo.Mbr.Signature = Layout->Signature;
558 DiskInfo.Mbr.CheckSum = 0;
566 _In_ const DRIVE_LAYOUT_INFORMATION_EX* LayoutEx,
569 DISK_PARTITION_INFO DiskInfo;
576 if (LayoutEx->PartitionCount != 1)
582 DiskInfo.Mbr.Signature = LayoutEx->Mbr.Signature;
583 DiskInfo.Mbr.CheckSum = 0;
586 PartitionInfoEx = LayoutEx->PartitionEntry;
608 if (!DiskEntry->LayoutBuffer)
639 List = &DiskEntry->LogicalPartListHead;
641 List = &DiskEntry->PrimaryPartListHead;
668 min( PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1,
671 DPRINT1(
"Disk region overlap problem, stopping there!\n"
672 "Partition to be inserted:\n"
673 " StartSector = %I64u ; EndSector = %I64u\n"
674 "Existing disk region:\n"
675 " StartSector = %I64u ; EndSector = %I64u\n",
676 PartEntry->StartSector.QuadPart,
677 PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1,
735 if (PartEntry->Volume)
749 DPRINT(
"AddLogicalDiskSpace()\n");
753 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
754 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
757 &DiskEntry->LogicalPartListHead,
762 DPRINT1(
"Failed to create a new empty region for full extended partition space!\n");
781 DPRINT1(
"Current entry sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
784 ASSERT(!PartEntry->IsPartitioned);
785 ASSERT(PartEntry->SectorCount.QuadPart);
786 ASSERT(!PartEntry->Volume);
790 ASSERT(!isContainer || !PartEntry->LogicalPartition);
805 DPRINT1(
"Partition size %I64u too small\n", SizeBytes);
817 PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart))
831 SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector;
837 PartEntry->LogicalPartition);
840 DPRINT1(
"Failed to create a new empty region for disk space!\n");
845 PartEntry->SectorCount.QuadPart = StartSector - PartEntry->StartSector.QuadPart;
849 PartEntry->New =
TRUE;
850 PartEntry->IsPartitioned =
TRUE;
852 PartEntry->BootIndicator =
FALSE;
866 if ((PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1)
882 PartEntry->StartSector.QuadPart,
883 PartEntry->SectorCount.QuadPart);
893 DPRINT1(
"First Sector : %I64u\n", PartEntry->StartSector.QuadPart);
894 DPRINT1(
"Last Sector : %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
895 DPRINT1(
"Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
910 ASSERT(PartEntry->IsPartitioned && PartEntry->PartitionNumber != 0);
915 L"\\Device\\Harddisk%lu\\Partition%lu",
916 PartEntry->DiskEntry->DiskNumber,
917 PartEntry->PartitionNumber);
944 if (*
Volume->Info.DeviceName)
986 DPRINT1(
"IOCTL_MOUNTDEV_QUERY_DEVICE_NAME failed, Status 0x%08lx\n",
Status);
1031 ASSERT(PartEntry->DiskEntry->PartList ==
List);
1032 Volume->PartEntry = PartEntry;
1049 PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
1084 DiskEntry->ExtendedPartition = PartEntry;
1099 DPRINT1(
"Couldn't allocate a volume for device '%S'\n",
1111 DPRINT1(
"Failed to mount volume '%S', Status 0x%08lx\n",
1140 DPRINT1(
"Disk %lu Partition %lu is not recognized (Type 0x%02x)\n",
1162 DPRINT(
"ScanForUnpartitionedDiskSpace()\n");
1166 DPRINT1(
"No primary partition!\n");
1170 if (DiskEntry->SectorAlignment < 2048)
1171 StartSector = 2048ULL;
1173 StartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
1174 SectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - StartSector;
1177 &DiskEntry->PrimaryPartListHead,
1182 DPRINT1(
"Failed to create a new empty region for full disk space!\n");
1188 if (DiskEntry->SectorAlignment < 2048)
1189 LastStartSector = 2048ULL;
1191 LastStartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
1192 LastSectorCount = 0
ULL;
1193 LastUnusedSectorCount = 0
ULL;
1195 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
1196 Entry != &DiskEntry->PrimaryPartListHead;
1204 LastUnusedSectorCount =
1208 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1210 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1212 StartSector = LastStartSector + LastSectorCount;
1213 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1223 DPRINT1(
"Failed to create a new empty region for disk space!\n");
1234 if ((LastStartSector + LastSectorCount) < DiskEntry->SectorCount.QuadPart)
1236 LastUnusedSectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment);
1238 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1240 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1242 StartSector = LastStartSector + LastSectorCount;
1243 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1247 &DiskEntry->PrimaryPartListHead,
1253 DPRINT1(
"Failed to create a new empty region for trailing disk space!\n");
1259 if (DiskEntry->ExtendedPartition !=
NULL)
1263 DPRINT1(
"No logical partition!\n");
1271 LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1272 LastSectorCount = 0
ULL;
1273 LastUnusedSectorCount = 0
ULL;
1275 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
1276 Entry != &DiskEntry->LogicalPartListHead;
1284 LastUnusedSectorCount =
1288 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1290 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1292 StartSector = LastStartSector + LastSectorCount;
1293 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1303 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1314 if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart)
1316 LastUnusedSectorCount =
AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart +
1317 DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount),
1318 DiskEntry->SectorAlignment);
1320 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1322 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1324 StartSector = LastStartSector + LastSectorCount;
1325 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1329 &DiskEntry->LogicalPartListHead,
1335 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1342 DPRINT(
"ScanForUnpartitionedDiskSpace() done\n");
1359 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1375 if (DiskEntry->LayoutBuffer->Signature == 0)
1386 Entry2 != &
List->DiskListHead;
1387 Entry2 = Entry2->
Flink)
1393 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1397 if (DiskEntry != DiskEntry2 &&
1402 if (Entry2 == &
List->DiskListHead)
1424 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1445 ULONG HwAdapterNumber = 0;
1446 ULONG HwControllerNumber = 0;
1447 ULONG RemovableDiskCount = 0;
1455 for (ListEntry =
List->BiosDiskListHead.
Flink;
1456 ListEntry != &
List->BiosDiskListHead;
1457 ListEntry = ListEntry->
Flink)
1471 RemovableDiskCount = 0;
1482 ++RemovableDiskCount;
1493 DPRINT1(
"BIOS disk %lu is not recognized by NTOS!\n", BiosDiskEntry->
DiskNumber);
1519 ULONG LayoutBufferSize;
1532 sizeof(DiskGeometry));
1556 sizeof(ScsiAddress));
1592 for (
i = 0;
i < 128;
i++)
1596 Checksum = ~Checksum + 1;
1607 if (DiskEntry ==
NULL)
1610 DPRINT1(
"Failed to allocate a new disk entry.\n");
1624 sizeof(FileFsDevice),
1628 DPRINT1(
"Couldn't detect device type for disk %lu of identifier '%S'...\n", DiskNumber,
Identifier);
1664 DiskEntry->
DiskStyle = PARTITION_STYLE_RAW;
1684 for (ListEntry =
List->BiosDiskListHead.
Flink;
1685 ListEntry != &
List->BiosDiskListHead;
1686 ListEntry = ListEntry->
Flink)
1696 BiosDiskEntry->
Checksum == Checksum &&
1723 DPRINT1(
"Disk %lu of identifier '%S' has already been found?!\n", DiskNumber,
Identifier);
1730 DPRINT1(
"WARNING: Setup could not find a matching BIOS disk entry. Disk %lu may not be bootable by the BIOS!\n", DiskNumber);
1792 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1804 DPRINT1(
"Failed to allocate the disk layout buffer!\n");
1811 DPRINT1(
"Buffer size: %lu\n", LayoutBufferSize);
1827 DPRINT1(
"NtDeviceIoControlFile() failed (Status: 0x%08lx)\n",
Status);
1836 if (NewLayoutBuffer ==
NULL)
1838 DPRINT1(
"Failed to reallocate the disk layout buffer!\n");
1847#ifdef DUMP_PARTITION_TABLE
1848 DumpPartitionTable(DiskEntry);
1852 DPRINT1(
"Disk %lu is a super-floppy\n", DiskNumber);
1873 DPRINT1(
"No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->
BytesPerSector);
1881 for (
i = 0;
i < 4;
i++)
1889 for (
i = 0;
i < 4;
i++)
1926 if (
List->SystemPartition)
1927 return List->SystemPartition->DiskEntry;
1950 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
1971 if (PartEntry->IsPartitioned &&
1973 PartEntry->BootIndicator)
2003 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2008 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2009 ListEntry != &DiskEntry->PrimaryPartListHead;
2010 ListEntry = ListEntry->
Flink)
2021 ActivePartition = PartEntry;
2023 DPRINT1(
"Found active system partition %lu in disk %lu, drive letter %C\n",
2031 if (DiskEntry->NewDisk && ActivePartition !=
NULL)
2034 DPRINT1(
"NewDisk TRUE but already existing active partition?\n");
2038 return ActivePartition;
2083 DPRINT1(
"NtQuerySystemInformation() failed, Status 0x%08lx\n",
Status);
2088 for (DiskNumber = 0; DiskNumber < Sdi.
NumberOfDisks; DiskNumber++)
2091 L"\\Device\\Harddisk%lu\\Partition0",
2256 DiskEntry->
Bus == Bus &&
2257 DiskEntry->
Id ==
Id)
2304 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2305 Entry != &DiskEntry->PrimaryPartListHead;
2318 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
2319 Entry != &DiskEntry->LogicalPartListHead;
2372 if (CurrentPart !=
NULL)
2376 if (CurrentPart->LogicalPartition)
2380 PartListEntry = CurrentPart->ListEntry.
Flink;
2401 if (CurrentPart->IsPartitioned &&
2415 PartListEntry = CurrentPart->ListEntry.
Flink;
2427 :
List->DiskListHead.Flink);
2428 DiskListEntry != &
List->DiskListHead;
2429 DiskListEntry = DiskListEntry->
Flink)
2435 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2465 if (CurrentPart !=
NULL)
2469 if (CurrentPart->LogicalPartition)
2473 PartListEntry = CurrentPart->ListEntry.
Blink;
2490 PartListEntry = CurrentPart->ListEntry.
Blink;
2495 if (CurrentPart->IsPartitioned &&
2509 :
List->DiskListHead.Blink);
2510 DiskListEntry != &
List->DiskListHead;
2511 DiskListEntry = DiskListEntry->
Blink)
2517 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2526 if (CurrentPart->IsPartitioned &&
2580 for (
Entry = PartListHead->Flink;
2581 Entry != PartListHead;
2592#define GetPrimaryPartitionCount(DiskEntry) \
2593 GetPartitionCount(&(DiskEntry)->PrimaryPartListHead)
2595#define GetLogicalPartitionCount(DiskEntry) \
2596 (((DiskEntry)->DiskStyle == PARTITION_STYLE_MBR) \
2597 ? GetPartitionCount(&(DiskEntry)->LogicalPartListHead) : 0)
2606 ULONG NewPartitionCount;
2607 ULONG CurrentPartitionCount = 0;
2608 ULONG LayoutBufferSize;
2611 DPRINT1(
"ReAllocateLayoutBuffer()\n");
2615 if (DiskEntry->LayoutBuffer)
2616 CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2618 DPRINT1(
"CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n",
2619 CurrentPartitionCount, NewPartitionCount);
2621 if (CurrentPartitionCount == NewPartitionCount)
2628 DiskEntry->LayoutBuffer,
2630 if (NewLayoutBuffer ==
NULL)
2632 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", LayoutBufferSize);
2639 if (NewPartitionCount > CurrentPartitionCount)
2641 for (
i = CurrentPartitionCount;
i < NewPartitionCount;
i++)
2647 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2665 DPRINT1(
"UpdateDiskLayout()\n");
2669 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2676 DPRINT(
"ReAllocateLayoutBuffer() failed.\n");
2682 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2683 ListEntry != &DiskEntry->PrimaryPartListHead;
2684 ListEntry = ListEntry->
Flink)
2703 DPRINT1(
"Updating primary partition entry %lu\n",
Index);
2727 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2728 ListEntry != &DiskEntry->LogicalPartListHead;
2729 ListEntry = ListEntry->
Flink)
2746 DPRINT1(
"Updating logical partition entry %lu\n",
Index);
2762 HiddenSectors64.
QuadPart = PartEntry->
StartSector.
QuadPart - DiskEntry->SectorAlignment - DiskEntry->ExtendedPartition->StartSector.QuadPart;
2777 LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[
Index + 1];
2793 DPRINT1(
"Wiping primary partition entry %lu\n",
Index);
2807 for (
Index = 4;
Index < DiskEntry->LayoutBuffer->PartitionCount;
Index++)
2834 DiskEntry->Dirty =
TRUE;
2836#ifdef DUMP_PARTITION_TABLE
2837 DumpPartitionTable(DiskEntry);
2865 PartEntry->LogicalPartition)
2875 AdjEntry = PartEntry->ListEntry.
Flink;
2877 AdjEntry = PartEntry->ListEntry.
Blink;
2879 if (AdjEntry != ListHead)
2882 if (!PartEntry->IsPartitioned)
2902 ASSERT(!PartEntry->IsPartitioned);
2907 if (PartEntry->LogicalPartition)
2918 if (!PartEntry->LogicalPartition || isContainer)
2954 if (PartEntry->IsPartitioned)
2964 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2984 PCSTR mainType =
"Primary";
2987 mainType =
"Extended";
2988 else if (PartEntry && PartEntry->LogicalPartition)
2989 mainType =
"Logical";
2991 DPRINT1(
"CreatePartition(%s, %I64u bytes)\n", mainType, SizeBytes);
2993 if (!
List || !PartEntry ||
2994 !PartEntry->DiskEntry || PartEntry->IsPartitioned)
3002 DPRINT1(
"PartitionCreateChecks(%s) failed with error %lu\n", mainType,
Error);
3010 DiskEntry = PartEntry->DiskEntry;
3013 ASSERT(!PartEntry->Volume);
3021 ASSERT(PartEntry->Volume);
3036 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3042 ASSERT(PartEntry->IsPartitioned);
3047 PartEntry->Volume =
NULL;
3086 if (!
List || !PartEntry ||
3087 !PartEntry->DiskEntry || !PartEntry->IsPartitioned)
3092 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3096 if (
List->SystemPartition == PartEntry)
3102 DiskEntry = PartEntry->DiskEntry;
3132 if (PrevPartEntry !=
NULL && NextPartEntry !=
NULL)
3147 *FreeRegion = PrevPartEntry;
3149 else if (PrevPartEntry !=
NULL && NextPartEntry ==
NULL)
3162 *FreeRegion = PrevPartEntry;
3164 else if (PrevPartEntry ==
NULL && NextPartEntry !=
NULL)
3178 *FreeRegion = NextPartEntry;
3184 PartEntry->IsPartitioned =
FALSE;
3186 PartEntry->OnDiskPartitionNumber = 0;
3187 PartEntry->PartitionNumber = 0;
3189 PartEntry->BootIndicator =
FALSE;
3192 if (PartEntry->Volume)
3197 PartEntry->Volume =
NULL;
3201 *FreeRegion = PartEntry;
3225 DPRINT1(
"System partition %lu in disk %lu is an extended partition container?!\n",
3226 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3230 Volume = PartEntry->Volume;
3273 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3274 Volume->Info.FileSystem);
3282 DPRINT1(
"System partition %lu in disk %lu with no or unknown FS?!\n",
3283 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3291 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3292 Volume->Info.FileSystem);
3317 goto NoSystemPartition;
3321 if (!AlternativeDisk && AlternativePart)
3322 AlternativeDisk = AlternativePart->DiskEntry;
3325 if (AlternativePart)
3326 ASSERT(AlternativeDisk && (AlternativePart->DiskEntry == AlternativeDisk));
3329 if (AlternativeDisk)
3333 CandidatePartition =
NULL;
3348 goto UseAlternativeDisk;
3353 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3354 goto UseAlternativeDisk;
3358 ActivePartition =
List->SystemPartition;
3361 CandidatePartition = ActivePartition;
3363 DPRINT1(
"Use the current system partition %lu in disk %lu, drive letter %C\n",
3365 CandidatePartition->
DiskEntry->DiskNumber,
3369 return CandidatePartition;
3373 if (DiskEntry != AlternativeDisk)
3382 ListEntry = ListEntry->
Flink)
3388 if (PartEntry == ActivePartition)
3400 CandidatePartition = PartEntry;
3401 goto UseAlternativePartition;
3412 CandidatePartition = PartEntry;
3413 goto UseAlternativePartition;
3432 ListEntry = ListEntry->
Flink)
3438 if (PartEntry == ActivePartition)
3447 CandidatePartition = PartEntry;
3448 goto UseAlternativePartition;
3460 if (!AlternativeDisk || (!ForceSelect && (DiskEntry != AlternativeDisk)))
3461 goto NoSystemPartition;
3465 DPRINT1(
"Alternative disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3466 goto NoSystemPartition;
3469 if (DiskEntry != AlternativeDisk)
3472 DiskEntry = AlternativeDisk;
3478 CandidatePartition = ActivePartition;
3479 goto UseAlternativePartition;
3498 CandidatePartition = PartEntry;
3512 DPRINT1(
"Use new first active system partition %lu in disk %lu, drive letter %C\n",
3514 CandidatePartition->
DiskEntry->DiskNumber,
3519 return CandidatePartition;
3523 DPRINT1(
"NewDisk TRUE but first partition is used?\n");
3532 ListEntry = ListEntry->
Flink)
3553 DPRINT1(
"Use first active system partition %lu in disk %lu, drive letter %C\n",
3555 CandidatePartition->
DiskEntry->DiskNumber,
3560 return CandidatePartition;
3568 if (AlternativePart)
3570 DPRINT1(
"No valid or supported system partition has been found, use the alternative partition!\n");
3571 CandidatePartition = AlternativePart;
3572 goto UseAlternativePartition;
3577 DPRINT1(
"No valid or supported system partition has been found on this system!\n");
3581UseAlternativePartition:
3590 ASSERT(CandidatePartition);
3592 DPRINT1(
"Use alternative active system partition %lu in disk %lu, drive letter %C\n",
3594 CandidatePartition->
DiskEntry->DiskNumber,
3599 return CandidatePartition;
3621 if ((PartEntry ==
List->SystemPartition) ||
3627 ASSERT(PartEntry->DiskEntry);
3630 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3638 if (!(OldActivePart &&
IsPartitionActive(OldActivePart) && (OldActivePart->DiskEntry == PartEntry->DiskEntry)))
3647 OldActivePart->BootIndicator =
FALSE;
3648 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].BootIndicator =
FALSE;
3649 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].RewritePartition =
TRUE;
3650 OldActivePart->DiskEntry->Dirty =
TRUE;
3655 List->SystemPartition = PartEntry;
3658 PartEntry->BootIndicator =
TRUE;
3659 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].BootIndicator =
TRUE;
3660 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition =
TRUE;
3661 PartEntry->DiskEntry->Dirty =
TRUE;
3677 ULONG PartitionCount;
3682 DPRINT(
"WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
3685 if (!DiskEntry->Dirty)
3689 L"\\Device\\Harddisk%lu\\Partition0",
3690 DiskEntry->DiskNumber);
3711#ifdef DUMP_PARTITION_TABLE
3712 DumpPartitionTable(DiskEntry);
3722 PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
3735 DiskEntry->LayoutBuffer,
3737 DiskEntry->LayoutBuffer,
3748 DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
3753 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n",
Status);
3757#ifdef DUMP_PARTITION_TABLE
3758 DumpPartitionTable(DiskEntry);
3764 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
3765 ListEntry != &DiskEntry->PrimaryPartListHead;
3766 ListEntry = ListEntry->
Flink)
3791 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
3792 ListEntry != &DiskEntry->LogicalPartListHead;
3793 ListEntry = ListEntry->
Flink)
3824 DiskEntry->Dirty =
FALSE;
3865 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3874 DPRINT1(
"WritePartitionsToDisk() failed to update disk %lu, Status 0x%08lx\n",
3920 L"\\DosDevices\\%c:",
Letter);
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
#define PARTITION_ENTRY_UNUSED
#define PARTITION_EXTENDED
#define PARTITION_XINT13_EXTENDED
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
_In_ PFCB _In_ LONGLONG FileOffset
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
NTSTATUS pOpenDevice(_In_ PCWSTR DevicePath, _Out_ PHANDLE DeviceHandle)
Open an existing device given by its NT-style path, which is assumed to be for a disk device or a par...
#define NT_SUCCESS(StatCode)
#define RTL_CONSTANT_STRING(s)
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
static const WCHAR Signature[]
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define IsListEmpty(ListHead)
#define RemoveHeadList(ListHead)
#define InitializeListHead(ListHead)
enum _ERROR_NUMBER ERROR_NUMBER
@ ERROR_ONLY_ONE_EXTENDED
@ ERROR_PARTITION_TABLE_FULL
@ SystemDeviceInformation
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
_Must_inspect_result_ _Out_ PHANDLE VolumeHandle
#define FILE_SYNCHRONOUS_IO_NONALERT
@ FileFsDeviceInformation
UCHAR FileSystemToMBRPartitionType(IN PCWSTR FileSystem, IN ULONGLONG StartSector, IN ULONGLONG SectorCount)
union Alignment_ Alignment
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
_In_ GUID _In_ PVOID ValueData
#define IsOEMPartition(PartitionType)
struct _PARTLIST * PPARTLIST
struct _BIOSDISKENTRY * PBIOSDISKENTRY
#define GetDiskSizeInBytes(DiskEntry)
#define EFI_PMBR_OSTYPE_EFI
#define GetPartEntryOffsetInBytes(PartEntry)
#define GetPartEntrySizeInBytes(PartEntry)
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)
#define memcpy(s1, s2, n)
#define IOCTL_MOUNTDEV_QUERY_DEVICE_NAME
#define InitializeObjectAttributes(p, n, a, r, s)
static PTIME_FIELDS TimeFields
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
NTSYSAPI NTSTATUS NTAPI NtOpenFile(OUT PHANDLE phFile, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG ShareMode, IN ULONG OpenMode)
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
#define FILE_READ_ATTRIBUTES
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_REGISTRY_ABSOLUTE
#define REG_OPTION_NON_VOLATILE
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
#define RTL_REGISTRY_DEVICEMAP
#define RTL_QUERY_REGISTRY_DIRECT
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define REG_FULL_RESOURCE_DESCRIPTOR
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
#define RTL_SIZEOF_THROUGH_FIELD(type, field)
#define IOCTL_DISK_SET_DRIVE_LAYOUT
#define IsContainerPartition(PartitionType)
#define IsRecognizedPartition(PartitionType)
#define IOCTL_DISK_GET_DRIVE_LAYOUT
struct _PARTITION_INFORMATION PARTITION_INFORMATION
struct _DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION
static OUT PIO_STATUS_BLOCK IoStatusBlock
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
NTSTRSAFEAPI RtlStringCchCopyNW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_reads_or_z_(cchToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cchToCopy)
NTSTRSAFEAPI RtlStringCchCopyW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
#define OBJ_CASE_INSENSITIVE
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
#define CmResourceTypeDeviceSpecific
#define IOCTL_SCSI_GET_ADDRESS
BOOLEAN SetMountedDeviceValues(_In_ PPARTLIST List)
static VOID AddPartitionToDisk(IN ULONG DiskNumber, IN PDISKENTRY DiskEntry, IN ULONG PartitionIndex, IN BOOLEAN LogicalPartition)
static NTSTATUS InitVolumeDeviceName(_Inout_ PVOLENTRY Volume, _In_opt_ PCWSTR AltDeviceName)
BOOLEAN IsDiskSuperFloppy2(_In_ const DISK_PARTITION_INFO *DiskInfo, _In_opt_ const ULONGLONG *DiskSize, _In_ const PARTITION_INFORMATION *PartitionInfo)
static ERROR_NUMBER MBRPartitionCreateChecks(_In_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
ERROR_NUMBER NTAPI PartitionCreateChecks(_In_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
static BOOLEAN SetMountedDeviceValue(_In_ PVOLENTRY Volume)
Assign a "\DosDevices\#:" mount point drive letter to a disk partition or volume, specified by a give...
static VOID GetDriverName(IN PDISKENTRY DiskEntry)
struct _REG_DISK_MOUNT_INFO * PREG_DISK_MOUNT_INFO
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
ULONGLONG AlignUp(IN ULONGLONG Value, IN ULONG Alignment)
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
static VOID DestroyRegion(_Inout_ PPARTENTRY PartEntry)
BOOLEAN WritePartitionsToDisk(IN PPARTLIST List)
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
VOID SetMBRPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
VOID NTAPI DestroyPartitionList(IN PPARTLIST List)
BOOLEAN IsSuperFloppy(_In_ PDISKENTRY DiskEntry)
static VOID AssignDriveLetters(IN PPARTLIST List)
static ULONG GetPartitionCount(_In_ PLIST_ENTRY PartListHead)
Counts the number of partitioned disk regions in a given partition list.
static VOID InitPartitionDeviceName(_Inout_ PPARTENTRY PartEntry)
static BOOLEAN IsSamePrimaryLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo, _In_ PPARTENTRY PartEntry)
ULONGLONG AlignDown(IN ULONGLONG Value, IN ULONG Alignment)
PPARTENTRY NTAPI GetAdjUnpartitionedEntry(_In_ PPARTENTRY PartEntry, _In_ BOOLEAN Direction)
Retrieves, if any, the unpartitioned disk region that is adjacent (next or previous) to the specified...
static VOID SetDiskSignature(IN PPARTLIST List, IN PDISKENTRY DiskEntry)
PDISKENTRY GetDiskByBiosNumber(_In_ PPARTLIST List, _In_ ULONG HwDiskNumber)
BOOLEAN NTAPI CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
PDISKENTRY GetDiskBySCSI(_In_ PPARTLIST List, _In_ USHORT Port, _In_ USHORT Bus, _In_ USHORT Id)
BOOLEAN NTAPI DeletePartition(_In_ PPARTLIST List, _In_ PPARTENTRY PartEntry, _Out_opt_ PPARTENTRY *FreeRegion)
PDISKENTRY GetDiskBySignature(_In_ PPARTLIST List, _In_ ULONG Signature)
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
PPARTENTRY GetPartition(_In_ PDISKENTRY DiskEntry, _In_ ULONG PartitionNumber)
static VOID AddDiskToList(IN HANDLE FileHandle, IN ULONG DiskNumber, IN PPARTLIST List)
static VOID ScanForUnpartitionedDiskSpace(IN PDISKENTRY DiskEntry)
static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
BOOLEAN IsPartitionActive(IN PPARTENTRY PartEntry)
PPARTLIST NTAPI CreatePartitionList(VOID)
static NTSTATUS DismountPartition(_In_ PPARTLIST List, _In_ PPARTENTRY PartEntry)
static VOID UpdateDiskSignatures(IN PPARTLIST List)
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
PPARTENTRY NTAPI GetPrevPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
static PPARTENTRY CreateInsertBlankRegion(IN PDISKENTRY DiskEntry, IN OUT PLIST_ENTRY ListHead, IN ULONGLONG StartSector, IN ULONGLONG SectorCount, IN BOOLEAN LogicalSpace)
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
struct _REG_DISK_MOUNT_INFO REG_DISK_MOUNT_INFO
static PVOLENTRY InitVolume(_In_ PPARTLIST List, _In_opt_ PPARTENTRY PartEntry)
BOOLEAN IsDiskSuperFloppyEx(_In_ const DRIVE_LAYOUT_INFORMATION_EX *LayoutEx, _In_opt_ const ULONGLONG *DiskSize)
PPARTENTRY SelectPartition(_In_ PPARTLIST List, _In_ ULONG DiskNumber, _In_ ULONG PartitionNumber)
PPARTENTRY NTAPI GetNextPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
static BOOLEAN InsertDiskRegion(IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry, IN BOOLEAN LogicalPartition)
static BOOLEAN IsEmptyLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo)
PDISKENTRY GetDiskByNumber(_In_ PPARTLIST List, _In_ ULONG DiskNumber)
static VOID UpdateHwDiskNumbers(IN PPARTLIST List)
static BOOLEAN ReAllocateLayoutBuffer(IN PDISKENTRY DiskEntry)
#define GetLogicalPartitionCount(DiskEntry)
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
static BOOLEAN IsSupportedActivePartition(IN PPARTENTRY PartEntry)
static BOOLEAN InitializePartitionEntry(_Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
#define GetPrimaryPartitionCount(DiskEntry)
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
BOOLEAN IsDiskSuperFloppy(_In_ const DRIVE_LAYOUT_INFORMATION *Layout, _In_opt_ const ULONGLONG *DiskSize)
static VOID AddLogicalDiskSpace(_In_ PDISKENTRY DiskEntry)
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
#define STATUS_BUFFER_TOO_SMALL
NTSTATUS NTAPI NtReadFile(HANDLE FileHandle, HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, PVOID Buffer, ULONG Length, PLARGE_INTEGER ByteOffset, PULONG Key)
PULONG MinorVersion OPTIONAL
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
base of all file and directory entries
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
CM_PARTIAL_RESOURCE_LIST PartialResourceList
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@384::@393 DeviceSpecificData
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
ULARGE_INTEGER SectorCount
UNICODE_STRING DriverName
PPARTENTRY ExtendedPartition
LIST_ENTRY LogicalPartListHead
struct _PARTLIST * PartList
PARTITION_STYLE DiskStyle
LIST_ENTRY PrimaryPartListHead
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
ULARGE_INTEGER SectorCount
WCHAR DeviceName[MAX_PATH]
NT device name: "\Device\HarddiskM\PartitionN".
struct _DISKENTRY * DiskEntry
ULONG OnDiskPartitionNumber
ULARGE_INTEGER StartSector
PARTITION Partition[PARTITION_TBL_SIZE]
unsigned char PartitionType
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_UNSUCCESSFUL
NTSTATUS DismountVolume(_Inout_ PVOLINFO Volume, _In_ BOOLEAN Force)
Attempts to dismount the designated volume.
NTSTATUS MountVolume(_Inout_ PVOLINFO Volume, _In_opt_ UCHAR MbrPartitionType)
#define IsUnknown(VolInfo)
#define IsUnformatted(VolInfo)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_Must_inspect_result_ _In_ WDFCMRESLIST List
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T) __WINE_ALLOC_SIZE(4) __WINE_DEALLOC(RtlFreeHeap
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define HKEY_LOCAL_MACHINE
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
_In_ ULONG _In_ ULONG PartitionNumber
_In_ LARGE_INTEGER Divisor