34 #ifdef DUMP_PARTITION_TABLE 44 DbgPrint(
"Index Start Length Hidden Nr Type Boot RW\n");
45 DbgPrint(
"----- ------------ ------------ ---------- -- ---- ---- --\n");
50 DbgPrint(
" %3lu %12I64u %12I64u %10lu %2lu %2x %c %c\n",
115 L"\\Scsi\\Scsi Port %hu",
132 DPRINT1(
"RtlQueryRegistryValues() failed (Status %lx)\n",
Status);
151 Entry1 != &
List->DiskListHead;
152 Entry1 = Entry1->
Flink)
158 Entry2 = Entry2->
Flink)
184 Entry1 != &
List->DiskListHead;
185 Entry1 = Entry1->
Flink)
191 Entry2 = Entry2->
Flink)
323 if (*Int13Drives ==
NULL)
349 #define ROOT_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System\\MultifunctionAdapter" 357 L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System",
363 DPRINT1(
"Unable to query the 'Configuration Data' key in '\\Registry\\Machine\\HARDWARE\\DESCRIPTION\\System', status=%lx\n",
Status);
367 for (AdapterCount = 0; ; ++AdapterCount)
383 L"%s\\%lu\\DiskController",
395 L"%s\\%lu\\DiskController\\%lu",
409 L"%s\\%lu\\DiskController\\%lu\\DiskPeripheral",
423 for (DiskCount = 0; ; ++DiskCount)
426 if (BiosDiskEntry ==
NULL)
433 L"%s\\%lu\\DiskController\\%lu\\DiskPeripheral\\%lu",
438 (
PVOID)BiosDiskEntry,
447 BiosDiskEntry->AdapterNumber = 0;
449 BiosDiskEntry->DiskNumber = DiskCount;
450 BiosDiskEntry->DiskEntry =
NULL;
452 if (DiskCount < Int13Drives[0].NumberDrives)
454 BiosDiskEntry->Int13DiskData = Int13Drives[DiskCount];
458 DPRINT1(
"Didn't find Int13 drive data for disk %u\n", DiskCount);
461 InsertTailList(&PartList->BiosDiskListHead, &BiosDiskEntry->ListEntry);
464 DPRINT(
"AdapterNumber: %lu\n", BiosDiskEntry->AdapterNumber);
465 DPRINT(
"ControllerNumber: %lu\n", BiosDiskEntry->ControllerNumber);
466 DPRINT(
"DiskNumber: %lu\n", BiosDiskEntry->DiskNumber);
467 DPRINT(
"Signature: %08lx\n", BiosDiskEntry->Signature);
468 DPRINT(
"Checksum: %08lx\n", BiosDiskEntry->Checksum);
469 DPRINT(
"BytesPerSector: %lu\n", BiosDiskEntry->DiskGeometry.BytesPerSector);
470 DPRINT(
"NumberOfCylinders: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfCylinders);
471 DPRINT(
"NumberOfHeads: %lu\n", BiosDiskEntry->DiskGeometry.NumberOfHeads);
472 DPRINT(
"DriveSelect: %02x\n", BiosDiskEntry->Int13DiskData.DriveSelect);
473 DPRINT(
"MaxCylinders: %lu\n", BiosDiskEntry->Int13DiskData.MaxCylinders);
474 DPRINT(
"SectorsPerTrack: %d\n", BiosDiskEntry->Int13DiskData.SectorsPerTrack);
475 DPRINT(
"MaxHeads: %d\n", BiosDiskEntry->Int13DiskData.MaxHeads);
476 DPRINT(
"NumberDrives: %d\n", BiosDiskEntry->Int13DiskData.NumberDrives);
508 if (DiskEntry->LayoutBuffer ==
NULL)
512 if (DiskEntry->LayoutBuffer->PartitionCount != 1)
526 if (DiskEntry->LayoutBuffer->Signature != 1)
528 DPRINT1(
"Super-Floppy disk %lu signature %08x != 1!\n",
529 DiskEntry->DiskNumber, DiskEntry->LayoutBuffer->Signature);
542 DPRINT1(
"Super-Floppy disk %lu does not return default settings!\n" 543 " PartitionNumber = %lu, expected 0\n" 544 " RecognizedPartition = %s, expected TRUE\n" 545 " PartitionType = 0x%02x, expected 0x04 (PARTITION_FAT_16)\n" 546 " BootIndicator = %s, expected FALSE\n",
547 DiskEntry->DiskNumber,
555 PartitionLengthEstimate = DiskEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector;
556 if (
PartitionInfo->PartitionLength.QuadPart != PartitionLengthEstimate)
558 DPRINT1(
"PartitionLength = %I64u is different from PartitionLengthEstimate = %I64u\n",
559 PartitionInfo->PartitionLength.QuadPart, PartitionLengthEstimate);
585 List = &DiskEntry->LogicalPartListHead;
587 List = &DiskEntry->PrimaryPartListHead;
614 min( PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1,
617 DPRINT1(
"Disk region overlap problem, stopping there!\n" 618 "Partition to be inserted:\n" 619 " StartSector = %I64u ; EndSector = %I64u\n" 620 "Existing disk region:\n" 621 " StartSector = %I64u ; EndSector = %I64u\n",
622 PartEntry->StartSector.QuadPart,
623 PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1,
652 if (NewPartEntry ==
NULL)
685 DPRINT1(
"Current partition sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
692 ASSERT(!PartEntry->IsPartitioned);
694 if ((AutoCreate !=
FALSE) ||
696 PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart))
698 PartEntry->AutoCreate = AutoCreate;
709 SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector;
715 PartEntry->LogicalPartition);
716 if (NewPartEntry ==
NULL)
718 DPRINT1(
"Failed to create a new empty region for disk space!\n");
723 PartEntry->SectorCount.QuadPart = StartSector - PartEntry->StartSector.QuadPart;
727 PartEntry->New =
TRUE;
728 PartEntry->IsPartitioned =
TRUE;
732 PartEntry->StartSector.QuadPart,
733 PartEntry->SectorCount.QuadPart);
737 PartEntry->FileSystem[0] =
L'\0';
739 PartEntry->BootIndicator =
FALSE;
741 DPRINT1(
"First Sector : %I64u\n", PartEntry->StartSector.QuadPart);
742 DPRINT1(
"Last Sector : %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
743 DPRINT1(
"Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
768 PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
779 if (PartEntry ==
NULL)
808 DiskEntry->ExtendedPartition = PartEntry;
817 L"\\Device\\Harddisk%lu\\Partition%lu",
818 DiskEntry->DiskNumber,
828 PartitionHandle =
NULL;
849 DPRINT1(
"InferFileSystem() failed, Status 0x%08lx\n",
Status);
887 PartitionHandle =
NULL;
923 DPRINT1(
"NtQueryVolumeInformationFile() failed, Status 0x%08lx\n",
Status);
954 DPRINT(
"ScanForUnpartitionedDiskSpace()\n");
958 DPRINT1(
"No primary partition!\n");
962 if (DiskEntry->SectorAlignment < 2048)
963 StartSector = 2048
ULL;
965 StartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
966 SectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - StartSector;
969 &DiskEntry->PrimaryPartListHead,
973 if (NewPartEntry ==
NULL)
974 DPRINT1(
"Failed to create a new empty region for full disk space!\n");
980 if (DiskEntry->SectorAlignment < 2048)
981 LastStartSector = 2048
ULL;
983 LastStartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
984 LastSectorCount = 0
ULL;
985 LastUnusedSectorCount = 0
ULL;
987 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
988 Entry != &DiskEntry->PrimaryPartListHead;
996 LastUnusedSectorCount =
1000 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1002 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1004 StartSector = LastStartSector + LastSectorCount;
1005 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1013 if (NewPartEntry ==
NULL)
1015 DPRINT1(
"Failed to create a new empty region for disk space!\n");
1026 if ((LastStartSector + LastSectorCount) < DiskEntry->SectorCount.QuadPart)
1028 LastUnusedSectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment);
1030 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1032 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1034 StartSector = LastStartSector + LastSectorCount;
1035 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1039 &DiskEntry->PrimaryPartListHead,
1043 if (NewPartEntry ==
NULL)
1045 DPRINT1(
"Failed to create a new empty region for trailing disk space!\n");
1051 if (DiskEntry->ExtendedPartition !=
NULL)
1055 DPRINT1(
"No logical partition!\n");
1059 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1060 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
1063 &DiskEntry->LogicalPartListHead,
1067 if (NewPartEntry ==
NULL)
1069 DPRINT1(
"Failed to create a new empty region for full extended partition space!\n");
1077 LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1078 LastSectorCount = 0
ULL;
1079 LastUnusedSectorCount = 0
ULL;
1081 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
1082 Entry != &DiskEntry->LogicalPartListHead;
1090 LastUnusedSectorCount =
1094 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1096 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1098 StartSector = LastStartSector + LastSectorCount;
1099 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1107 if (NewPartEntry ==
NULL)
1109 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1120 if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart)
1122 LastUnusedSectorCount =
AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart +
1123 DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount),
1124 DiskEntry->SectorAlignment);
1126 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1128 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1130 StartSector = LastStartSector + LastSectorCount;
1131 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1135 &DiskEntry->LogicalPartListHead,
1139 if (NewPartEntry ==
NULL)
1141 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1148 DPRINT(
"ScanForUnpartitionedDiskSpace() done\n");
1165 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1181 if (DiskEntry->LayoutBuffer->Signature == 0)
1192 Entry2 != &
List->DiskListHead;
1193 Entry2 = Entry2->
Flink)
1199 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1203 if (DiskEntry != DiskEntry2 &&
1208 if (Entry2 == &
List->DiskListHead)
1230 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1251 ULONG HwAdapterNumber = 0;
1252 ULONG HwControllerNumber = 0;
1253 ULONG RemovableDiskCount = 0;
1261 for (ListEntry =
List->BiosDiskListHead.
Flink;
1262 ListEntry != &
List->BiosDiskListHead;
1263 ListEntry = ListEntry->
Flink)
1277 RemovableDiskCount = 0;
1288 ++RemovableDiskCount;
1299 DPRINT1(
"BIOS disk %lu is not recognized by NTOS!\n", BiosDiskEntry->
DiskNumber);
1319 WCHAR Identifier[20];
1325 ULONG LayoutBufferSize;
1338 sizeof(DiskGeometry));
1362 sizeof(ScsiAddress));
1398 for (
i = 0;
i < 128;
i++)
1402 Checksum = ~Checksum + 1;
1408 DPRINT(
"Identifier: %S\n", Identifier);
1413 if (DiskEntry ==
NULL)
1416 DPRINT1(
"Failed to allocate a new disk entry.\n");
1430 sizeof(FileFsDevice),
1434 DPRINT1(
"Couldn't detect device type for disk %lu of identifier '%S'...\n", DiskNumber, Identifier);
1446 DPRINT1(
"Disk %lu of identifier '%S' is removable\n", DiskNumber, Identifier);
1450 DPRINT1(
"Disk %lu of identifier '%S' is fixed\n", DiskNumber, Identifier);
1470 DiskEntry->
DiskStyle = PARTITION_STYLE_RAW;
1474 Mbr->Partition[1].PartitionType == 0 &&
1475 Mbr->Partition[2].PartitionType == 0 &&
1476 Mbr->Partition[3].PartitionType == 0)
1490 for (ListEntry =
List->BiosDiskListHead.
Flink;
1491 ListEntry != &
List->BiosDiskListHead;
1492 ListEntry = ListEntry->
Flink)
1502 BiosDiskEntry->
Checksum == Checksum &&
1529 DPRINT1(
"Disk %lu of identifier '%S' has already been found?!\n", DiskNumber, Identifier);
1536 DPRINT1(
"WARNING: Setup could not find a matching BIOS disk entry. Disk %lu may not be bootable by the BIOS!\n", DiskNumber);
1598 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1610 DPRINT1(
"Failed to allocate the disk layout buffer!\n");
1617 DPRINT1(
"Buffer size: %lu\n", LayoutBufferSize);
1633 DPRINT1(
"NtDeviceIoControlFile() failed (Status: 0x%08lx)\n",
Status);
1642 if (NewLayoutBuffer ==
NULL)
1644 DPRINT1(
"Failed to reallocate the disk layout buffer!\n");
1653 #ifdef DUMP_PARTITION_TABLE 1654 DumpPartitionTable(DiskEntry);
1658 DPRINT1(
"Disk %lu is a super-floppy\n", DiskNumber);
1679 DPRINT1(
"No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->
BytesPerSector);
1687 for (
i = 0;
i < 4;
i++)
1695 for (
i = 0;
i < 4;
i++)
1732 if (
List->SystemPartition)
1733 return List->SystemPartition->DiskEntry;
1756 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
1777 if (PartEntry->IsPartitioned &&
1779 PartEntry->BootIndicator)
1809 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1814 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
1815 ListEntry != &DiskEntry->PrimaryPartListHead;
1816 ListEntry = ListEntry->
Flink)
1826 ActivePartition = PartEntry;
1828 DPRINT1(
"Found active system partition %lu in disk %lu, drive letter %C\n",
1836 if (DiskEntry->NewDisk && ActivePartition !=
NULL)
1839 DPRINT1(
"NewDisk TRUE but already existing active partition?\n");
1843 return ActivePartition;
1885 DPRINT1(
"NtQuerySystemInformation() failed, Status 0x%08lx",
Status);
1890 for (DiskNumber = 0; DiskNumber < Sdi.
NumberOfDisks; DiskNumber++)
1893 L"\\Device\\Harddisk%lu\\Partition0",
2057 DiskEntry->
Bus == Bus &&
2058 DiskEntry->
Id ==
Id)
2106 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2111 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2112 Entry != &DiskEntry->PrimaryPartListHead;
2125 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
2126 Entry != &DiskEntry->LogicalPartListHead;
2163 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2174 *pDiskEntry = DiskEntry;
2175 if (pPartEntry) *pPartEntry = PartEntry;
2220 if (CurrentPart !=
NULL)
2224 if (CurrentPart->LogicalPartition)
2228 PartListEntry = CurrentPart->ListEntry.
Flink;
2249 if (CurrentPart->IsPartitioned &&
2263 PartListEntry = CurrentPart->ListEntry.
Flink;
2275 :
List->DiskListHead.Flink);
2276 DiskListEntry != &
List->DiskListHead;
2277 DiskListEntry = DiskListEntry->
Flink)
2283 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2312 if (CurrentPart !=
NULL)
2316 if (CurrentPart->LogicalPartition)
2320 PartListEntry = CurrentPart->ListEntry.
Blink;
2337 PartListEntry = CurrentPart->ListEntry.
Blink;
2342 if (CurrentPart->IsPartitioned &&
2356 :
List->DiskListHead.Blink);
2357 DiskListEntry != &
List->DiskListHead;
2358 DiskListEntry = DiskListEntry->
Blink)
2364 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2373 if (CurrentPart->IsPartitioned &&
2416 if (
PartitionInfo->StartingOffset.QuadPart == PartEntry->StartSector.QuadPart * DiskEntry->BytesPerSector &&
2417 PartitionInfo->PartitionLength.QuadPart == PartEntry->SectorCount.QuadPart * DiskEntry->BytesPerSector)
2437 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2441 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2442 Entry != &DiskEntry->PrimaryPartListHead;
2464 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2468 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2469 ListEntry != &DiskEntry->LogicalPartListHead;
2470 ListEntry = ListEntry->
Flink)
2486 ULONG NewPartitionCount;
2487 ULONG CurrentPartitionCount = 0;
2488 ULONG LayoutBufferSize;
2491 DPRINT1(
"ReAllocateLayoutBuffer()\n");
2495 if (DiskEntry->LayoutBuffer)
2496 CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2498 DPRINT1(
"CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n",
2499 CurrentPartitionCount, NewPartitionCount);
2501 if (CurrentPartitionCount == NewPartitionCount)
2508 DiskEntry->LayoutBuffer,
2510 if (NewLayoutBuffer ==
NULL)
2512 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", LayoutBufferSize);
2519 if (NewPartitionCount > CurrentPartitionCount)
2521 for (
i = CurrentPartitionCount;
i < NewPartitionCount;
i++)
2527 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2545 DPRINT1(
"UpdateDiskLayout()\n");
2549 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2556 DPRINT(
"ReAllocateLayoutBuffer() failed.\n");
2562 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2563 ListEntry != &DiskEntry->PrimaryPartListHead;
2564 ListEntry = ListEntry->
Flink)
2583 DPRINT1(
"Updating primary partition entry %lu\n",
Index);
2606 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2607 ListEntry != &DiskEntry->LogicalPartListHead;
2608 ListEntry = ListEntry->
Flink)
2625 DPRINT1(
"Updating logical partition entry %lu\n",
Index);
2637 if (LinkInfo !=
NULL)
2641 HiddenSectors64.
QuadPart = PartEntry->
StartSector.
QuadPart - DiskEntry->SectorAlignment - DiskEntry->ExtendedPartition->StartSector.QuadPart;
2651 LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[
Index + 1];
2667 DPRINT1(
"Wiping primary partition entry %lu\n",
Index);
2681 for (
Index = 4;
Index < DiskEntry->LayoutBuffer->PartitionCount;
Index++)
2708 DiskEntry->Dirty =
TRUE;
2710 #ifdef DUMP_PARTITION_TABLE 2711 DumpPartitionTable(DiskEntry);
2726 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2730 if (PartEntry->LogicalPartition)
2735 if (PartEntry->ListEntry.Blink != ListHead)
2743 return PrevPartEntry;
2761 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2765 if (PartEntry->LogicalPartition)
2770 if (PartEntry->ListEntry.Flink != ListHead)
2778 return NextPartEntry;
2797 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned)
2805 DPRINT1(
"PrimaryPartitionCreationChecks() failed with error %lu\n",
Error);
2830 DPRINT1(
"AddLogicalDiskSpace()\n");
2834 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
2835 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
2838 &DiskEntry->LogicalPartListHead,
2842 if (NewPartEntry ==
NULL)
2844 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
2860 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned)
2868 DPRINT1(
"ExtendedPartitionCreationChecks() failed with error %lu\n",
Error);
2878 if (PartEntry->StartSector.QuadPart < 1450560)
2890 PartEntry->New =
FALSE;
2893 PartEntry->DiskEntry->ExtendedPartition = PartEntry;
2915 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned)
2923 DPRINT1(
"LogicalPartitionCreationChecks() failed with error %lu\n",
Error);
2952 if (!PartEntry->IsPartitioned ||
2958 !*PartEntry->FileSystem ||
2959 PartEntry->PartitionNumber == 0)
2969 L"\\Device\\Harddisk%lu\\Partition%lu",
2970 PartEntry->DiskEntry->DiskNumber,
2971 PartEntry->PartitionNumber);
2988 DPRINT1(
"ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &
Name,
Status);
3005 DPRINT1(
"WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
3021 DPRINT1(
"Failed to unmount volume (Status 0x%lx)\n",
Status);
3037 DPRINT1(
"Failed to unlock volume (Status 0x%lx)\n", LockStatus);
3059 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned ==
FALSE)
3067 if (
List->SystemPartition == PartEntry)
3073 DiskEntry = PartEntry->DiskEntry;
3105 if (PrevPartEntry !=
NULL && NextPartEntry !=
NULL)
3120 *FreeRegion = PrevPartEntry;
3122 else if (PrevPartEntry !=
NULL && NextPartEntry ==
NULL)
3135 *FreeRegion = PrevPartEntry;
3137 else if (PrevPartEntry ==
NULL && NextPartEntry !=
NULL)
3151 *FreeRegion = NextPartEntry;
3157 PartEntry->OnDiskPartitionNumber = 0;
3158 PartEntry->PartitionNumber = 0;
3160 PartEntry->BootIndicator =
FALSE;
3163 PartEntry->FileSystem[0] =
L'\0';
3164 PartEntry->DriveLetter = 0;
3165 RtlZeroMemory(PartEntry->VolumeLabel,
sizeof(PartEntry->VolumeLabel));
3169 *FreeRegion = PartEntry;
3191 DPRINT1(
"System partition %lu in disk %lu is an extended partition container?!\n",
3192 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3220 ASSERT(*PartEntry->FileSystem);
3223 if (
wcsicmp(PartEntry->FileSystem,
L"FAT") == 0 ||
3224 wcsicmp(PartEntry->FileSystem,
L"FAT32") == 0 ||
3226 wcsicmp(PartEntry->FileSystem,
L"BTRFS") == 0)
3233 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3234 PartEntry->FileSystem);
3240 ASSERT(!*PartEntry->FileSystem);
3242 DPRINT1(
"System partition %lu in disk %lu with no or unknown FS?!\n",
3243 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3251 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3252 PartEntry->FileSystem);
3277 goto NoSystemPartition;
3281 if (!AlternativeDisk && AlternativePart)
3282 AlternativeDisk = AlternativePart->DiskEntry;
3285 if (AlternativePart)
3286 ASSERT(AlternativeDisk && (AlternativePart->DiskEntry == AlternativeDisk));
3289 if (AlternativeDisk)
3293 CandidatePartition =
NULL;
3308 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3309 goto UseAlternativeDisk;
3313 ActivePartition =
List->SystemPartition;
3316 CandidatePartition = ActivePartition;
3318 DPRINT1(
"Use the current system partition %lu in disk %lu, drive letter %C\n",
3320 CandidatePartition->
DiskEntry->DiskNumber,
3324 return CandidatePartition;
3328 if (DiskEntry != AlternativeDisk)
3337 ListEntry = ListEntry->
Flink)
3343 if (PartEntry == ActivePartition)
3355 CandidatePartition = PartEntry;
3356 goto UseAlternativePartition;
3367 CandidatePartition = PartEntry;
3368 goto UseAlternativePartition;
3387 ListEntry = ListEntry->
Flink)
3393 if (PartEntry == ActivePartition)
3402 CandidatePartition = PartEntry;
3403 goto UseAlternativePartition;
3415 if (!AlternativeDisk || (!ForceSelect && (DiskEntry != AlternativeDisk)))
3416 goto NoSystemPartition;
3420 DPRINT1(
"Alternative disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3421 goto NoSystemPartition;
3424 if (DiskEntry != AlternativeDisk)
3427 DiskEntry = AlternativeDisk;
3433 CandidatePartition = ActivePartition;
3434 goto UseAlternativePartition;
3453 CandidatePartition = PartEntry;
3467 DPRINT1(
"Use new first active system partition %lu in disk %lu, drive letter %C\n",
3469 CandidatePartition->
DiskEntry->DiskNumber,
3473 return CandidatePartition;
3477 DPRINT1(
"NewDisk TRUE but first partition is used?\n");
3486 ListEntry = ListEntry->
Flink)
3507 DPRINT1(
"Use first active system partition %lu in disk %lu, drive letter %C\n",
3509 CandidatePartition->
DiskEntry->DiskNumber,
3513 return CandidatePartition;
3521 if (AlternativePart)
3523 DPRINT1(
"No valid or supported system partition has been found, use the alternative partition!\n");
3524 CandidatePartition = AlternativePart;
3525 goto UseAlternativePartition;
3530 DPRINT1(
"No valid or supported system partition has been found on this system!\n");
3534 UseAlternativePartition:
3543 ASSERT(CandidatePartition);
3545 DPRINT1(
"Use alternative active system partition %lu in disk %lu, drive letter %C\n",
3547 CandidatePartition->
DiskEntry->DiskNumber,
3551 return CandidatePartition;
3573 if ((PartEntry ==
List->SystemPartition) ||
3579 ASSERT(PartEntry->DiskEntry);
3582 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3590 if (!(OldActivePart &&
IsPartitionActive(OldActivePart) && (OldActivePart->DiskEntry == PartEntry->DiskEntry)))
3599 OldActivePart->BootIndicator =
FALSE;
3600 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].BootIndicator =
FALSE;
3601 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].RewritePartition =
TRUE;
3602 OldActivePart->DiskEntry->Dirty =
TRUE;
3607 List->SystemPartition = PartEntry;
3610 PartEntry->BootIndicator =
TRUE;
3611 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].BootIndicator =
TRUE;
3612 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition =
TRUE;
3613 PartEntry->DiskEntry->Dirty =
TRUE;
3629 ULONG PartitionCount;
3634 DPRINT(
"WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
3637 if (!DiskEntry->Dirty)
3641 L"\\Device\\Harddisk%lu\\Partition0",
3642 DiskEntry->DiskNumber);
3663 #ifdef DUMP_PARTITION_TABLE 3664 DumpPartitionTable(DiskEntry);
3674 PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
3685 DiskEntry->LayoutBuffer,
3687 DiskEntry->LayoutBuffer,
3698 DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
3703 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n",
Status);
3707 #ifdef DUMP_PARTITION_TABLE 3708 DumpPartitionTable(DiskEntry);
3714 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
3715 ListEntry != &DiskEntry->PrimaryPartListHead;
3716 ListEntry = ListEntry->
Flink)
3729 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
3730 ListEntry != &DiskEntry->LogicalPartListHead;
3731 ListEntry = ListEntry->
Flink)
3757 DiskEntry->Dirty =
FALSE;
3781 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3790 DPRINT1(
"WritePartitionsToDisk() failed to update disk %lu, Status 0x%08lx\n",
3809 WCHAR ValueNameBuffer[16];
3814 L"\\DosDevices\\%c:",
Letter);
3873 Entry1 != &
List->DiskListHead;
3874 Entry1 = Entry1->
Flink)
3882 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3888 Entry2 = Entry2->
Flink)
3911 Entry2 = Entry2->
Flink)
3961 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3966 if (PartEntry->IsPartitioned)
3988 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3993 if (PartEntry->IsPartitioned)
4019 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
4024 if (PartEntry->IsPartitioned)
4045 Entry1 != &
List->DiskListHead;
4046 Entry1 = Entry1->
Flink)
4054 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
4060 Entry2 = Entry2->
Flink)
4066 if (pDiskEntry) *pDiskEntry = DiskEntry;
4067 *pPartEntry = PartEntry;
4074 Entry2 = Entry2->
Flink)
4080 if (pDiskEntry) *pDiskEntry = DiskEntry;
4081 *pPartEntry = PartEntry;
4087 if (pDiskEntry) *pDiskEntry =
NULL;
4104 Entry1 != &
List->DiskListHead;
4105 Entry1 = Entry1->
Flink)
4113 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
4119 Entry2 = Entry2->
Flink)
4125 if (pDiskEntry) *pDiskEntry = DiskEntry;
4126 *pPartEntry = PartEntry;
4133 Entry2 = Entry2->
Flink)
4139 if (pDiskEntry) *pDiskEntry = DiskEntry;
4140 *pPartEntry = PartEntry;
4146 if (pDiskEntry) *pDiskEntry =
NULL;
LIST_ENTRY PrimaryPartListHead
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
struct _PARTLIST * PartList
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
PPARTLIST CreatePartitionList(VOID)
PDISKENTRY GetDiskBySignature(IN PPARTLIST List, IN ULONG Signature)
#define CmResourceTypeDeviceSpecific
_In_ PCWSTR _Inout_ _At_ QueryTable _Pre_unknown_ PRTL_QUERY_REGISTRY_TABLE QueryTable
ULARGE_INTEGER StartSector
ERROR_NUMBER ExtendedPartitionCreationChecks(IN PPARTENTRY PartEntry)
#define FSCTL_UNLOCK_VOLUME
LARGE_INTEGER StartingOffset
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
#define IOCTL_SCSI_GET_ADDRESS
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)
struct _PARTLIST * PPARTLIST
_In_ PFCB _In_ LONGLONG StartingOffset
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define OBJ_CASE_INSENSITIVE
static PPARTENTRY GetActiveDiskPartition(IN PDISKENTRY DiskEntry)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
static BOOLEAN ReAllocateLayoutBuffer(IN PDISKENTRY DiskEntry)
IN BOOLEAN OUT PSTR Buffer
BOOLEAN DeletePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, OUT PPARTENTRY *FreeRegion OPTIONAL)
struct _LIST_ENTRY * Blink
ULARGE_INTEGER SectorCount
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
BOOLEAN SetMountedDeviceValue(IN WCHAR Letter, IN ULONG Signature, IN LARGE_INTEGER StartingOffset)
FORCEINLINE BOOLEAN IsEmptyLayoutEntry(IN PPARTITION_INFORMATION PartitionInfo)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
ERROR_NUMBER LogicalPartitionCreationChecks(IN PPARTENTRY PartEntry)
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378::@387 DeviceSpecificData
static BOOLEAN IsSupportedActivePartition(IN PPARTENTRY PartEntry)
#define IsContainerPartition(PartitionType)
BOOLEAN WritePartitionsToDisk(IN PPARTLIST List)
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)
struct _CM_DISK_GEOMETRY_DEVICE_DATA * PCM_DISK_GEOMETRY_DEVICE_DATA
#define InsertTailList(ListHead, Entry)
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@378 u
_In_ ULONG _In_ ULONG PartitionNumber
struct _PARTITION_INFORMATION PARTITION_INFORMATION
struct _BIOSDISKENTRY * PBIOSDISKENTRY
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG _Out_opt_ PULONG _Out_opt_ PULONG ValueType
NTSTATUS InferFileSystem(IN PCWSTR PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
static VOID UpdateDiskSignatures(IN PPARTLIST List)
static BOOLEAN InitializePartitionEntry(IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
#define STATUS_BUFFER_TOO_SMALL
PPARTENTRY ExtendedPartition
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
#define PARTITION_ENTRY_UNUSED
struct _REG_DISK_MOUNT_INFO REG_DISK_MOUNT_INFO
CM_PARTIAL_RESOURCE_LIST PartialResourceList
static VOID GetDriverName(IN PDISKENTRY DiskEntry)
NTSTATUS DismountVolume(IN PPARTENTRY PartEntry)
PPARTENTRY GetPartition(IN PDISKENTRY DiskEntry, IN ULONG PartitionNumber)
PARTITION_STYLE DiskStyle
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
struct _DRIVE_LAYOUT_INFORMATION DRIVE_LAYOUT_INFORMATION
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
union Alignment_ Alignment
_In_ PCWSTR _Inout_ _At_ QueryTable EntryContext
static NTSTATUS NTAPI SystemConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
_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
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
BOOLEAN GetNextUncheckedPartition(IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
BOOLEAN CreateLogicalPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
static BOOLEAN InsertDiskRegion(IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry, IN BOOLEAN LogicalPartition)
ULONGLONG AlignUp(IN ULONGLONG Value, IN ULONG Alignment)
#define REG_FULL_RESOURCE_DESCRIPTOR
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
BOOLEAN SetMountedDeviceValues(IN PPARTLIST List)
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
ULARGE_INTEGER SectorCount
#define PARTITION_EXTENDED
PPARTENTRY GetNextPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
#define FSCTL_DISMOUNT_VOLUME
PPARTENTRY SelectPartition(IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber)
struct _FILE_FS_VOLUME_INFORMATION * PFILE_FS_VOLUME_INFORMATION
#define REG_OPTION_NON_VOLATILE
BOOLEAN RtlTimeToTimeFields(IN PLARGE_INTEGER Time, IN PTIME_FIELDS TimeFields)
PDISKENTRY GetDiskByNumber(IN PPARTLIST List, IN ULONG DiskNumber)
struct _LIST_ENTRY * Flink
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)
ERROR_NUMBER PrimaryPartitionCreationChecks(IN PPARTENTRY PartEntry)
static PPARTENTRY CreateInsertBlankRegion(IN PDISKENTRY DiskEntry, IN OUT PLIST_ENTRY ListHead, IN ULONGLONG StartSector, IN ULONGLONG SectorCount, IN BOOLEAN LogicalSpace)
struct _DISKENTRY * DiskEntry
NTSYSAPI NTSTATUS NTAPI NtFsControlFile(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 EFI_PMBR_OSTYPE_EFI
#define NT_SUCCESS(StatCode)
static VOID UpdateHwDiskNumbers(IN PPARTLIST List)
UNICODE_STRING DriverName
_In_ WDFCOLLECTION _In_ ULONG Index
ULONG OnDiskPartitionNumber
#define IsRecognizedPartition(PartitionType)
CM_DISK_GEOMETRY_DEVICE_DATA DiskGeometry
_In_ GUID _In_ PVOID ValueData
_In_ ULONG _In_ struct _SET_PARTITION_INFORMATION_EX * PartitionInfo
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
WCHAR FileSystem[MAX_PATH+1]
UCHAR FileSystemToMBRPartitionType(IN PCWSTR FileSystem, IN ULONGLONG StartSector, IN ULONGLONG SectorCount)
ULONGLONG AlignDown(IN ULONGLONG Value, IN ULONG Alignment)
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
#define FILE_READ_ATTRIBUTES
#define STATUS_UNSUCCESSFUL
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
static VOID ScanForUnpartitionedDiskSpace(IN PDISKENTRY DiskEntry)
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
static VOID SetDiskSignature(IN PPARTLIST List, IN PDISKENTRY DiskEntry)
enum _ERROR_NUMBER ERROR_NUMBER
_Must_inspect_result_ _In_ WDFCMRESLIST List
PPARTENTRY GetPrevPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
#define memcpy(s1, s2, n)
VOID DestroyPartitionList(IN PPARTLIST List)
#define RTL_REGISTRY_ABSOLUTE
#define InsertAscendingList(ListHead, NewEntry, Type, ListEntryField, SortField)
#define PARTITION_XINT13_EXTENDED
BOOLEAN CreatePrimaryPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount, IN BOOLEAN AutoCreate)
#define IOCTL_DISK_GET_DRIVE_LAYOUT
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
NTSTATUS NTAPI NtQueryVolumeInformationFile(HANDLE FileHandle, PIO_STATUS_BLOCK IoStatusBlock, PVOID FsInformation, ULONG Length, FS_INFORMATION_CLASS FsInformationClass)
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
static VOID AddDiskToList(IN HANDLE FileHandle, IN ULONG DiskNumber, IN PPARTLIST List)
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_ PFCB _In_ LONGLONG FileOffset
#define InitializeListHead(ListHead)
BOOLEAN GetDiskOrPartition(IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber OPTIONAL, OUT PDISKENTRY *pDiskEntry, OUT PPARTENTRY *pPartEntry OPTIONAL)
static PPARTENTRY GetPrevUnpartitionedEntry(IN PPARTENTRY PartEntry)
struct _REG_DISK_MOUNT_INFO * PREG_DISK_MOUNT_INFO
static OUT PIO_STATUS_BLOCK IoStatusBlock
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
NTSYSAPI NTSTATUS NTAPI NtSetValueKey(IN HANDLE KeyHandle, IN PUNICODE_STRING ValueName, IN ULONG TitleIndex OPTIONAL, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
PDISKENTRY GetDiskByBiosNumber(IN PPARTLIST List, IN ULONG HwDiskNumber)
LIST_ENTRY LogicalPartListHead
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
#define FILE_SYNCHRONOUS_IO_NONALERT
static PPARTENTRY GetNextUnpartitionedEntry(IN PPARTENTRY PartEntry)
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
#define FSCTL_LOCK_VOLUME
BOOLEAN CreateExtendedPartition(IN PPARTLIST List, IN OUT PPARTENTRY PartEntry, IN ULONGLONG SectorCount)
_In_ LARGE_INTEGER Divisor
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
PDISKENTRY GetDiskBySCSI(IN PPARTLIST List, IN USHORT Port, IN USHORT Bus, IN USHORT Id)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
#define InitializeObjectAttributes(p, n, a, r, s)
#define IOCTL_DISK_SET_DRIVE_LAYOUT
static VOID AddLogicalDiskSpace(IN PDISKENTRY DiskEntry)
#define PARTITION_FAT32_XINT13
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
BOOLEAN IsPartitionActive(IN PPARTENTRY PartEntry)
#define RTL_REGISTRY_DEVICEMAP
static ULONG GetLogicalPartitionCount(IN PDISKENTRY DiskEntry)
static PTIME_FIELDS TimeFields
BOOLEAN GetNextUnformattedPartition(IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
static const WCHAR Signature[]
PDRIVE_LAYOUT_INFORMATION LayoutBuffer
FORCEINLINE BOOLEAN IsSamePrimaryLayoutEntry(IN PPARTITION_INFORMATION PartitionInfo, IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry)
base of all file and directory entries
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
static VOID AssignDriveLetters(IN PPARTLIST List)
#define RTL_QUERY_REGISTRY_DIRECT
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)
VOID SetMBRPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
#define HKEY_LOCAL_MACHINE
#define RTL_CONSTANT_STRING(s)
static VOID AddPartitionToDisk(IN ULONG DiskNumber, IN PDISKENTRY DiskEntry, IN ULONG PartitionIndex, IN BOOLEAN LogicalPartition)
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
PULONG MinorVersion OPTIONAL