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,
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 entry sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
688 ASSERT(!PartEntry->IsPartitioned);
689 ASSERT(PartEntry->SectorCount.QuadPart);
704 DPRINT1(
"Partition size %I64u too small\n", SizeBytes);
716 PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart))
730 SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector;
736 PartEntry->LogicalPartition);
737 if (NewPartEntry ==
NULL)
739 DPRINT1(
"Failed to create a new empty region for disk space!\n");
744 PartEntry->SectorCount.QuadPart = StartSector - PartEntry->StartSector.QuadPart;
748 PartEntry->New =
TRUE;
749 PartEntry->IsPartitioned =
TRUE;
753 PartEntry->StartSector.QuadPart,
754 PartEntry->SectorCount.QuadPart);
758 PartEntry->FileSystem[0] =
L'\0';
759 PartEntry->BootIndicator =
FALSE;
761 DPRINT1(
"First Sector : %I64u\n", PartEntry->StartSector.QuadPart);
762 DPRINT1(
"Last Sector : %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
763 DPRINT1(
"Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
788 PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
799 if (PartEntry ==
NULL)
828 DiskEntry->ExtendedPartition = PartEntry;
837 L"\\Device\\Harddisk%lu\\Partition%lu",
838 DiskEntry->DiskNumber,
848 PartitionHandle =
NULL;
869 DPRINT1(
"InferFileSystem() failed, Status 0x%08lx\n",
Status);
907 PartitionHandle =
NULL;
943 DPRINT1(
"NtQueryVolumeInformationFile() failed, Status 0x%08lx\n",
Status);
974 DPRINT(
"ScanForUnpartitionedDiskSpace()\n");
978 DPRINT1(
"No primary partition!\n");
982 if (DiskEntry->SectorAlignment < 2048)
983 StartSector = 2048ULL;
985 StartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
986 SectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - StartSector;
989 &DiskEntry->PrimaryPartListHead,
993 if (NewPartEntry ==
NULL)
994 DPRINT1(
"Failed to create a new empty region for full disk space!\n");
1000 if (DiskEntry->SectorAlignment < 2048)
1001 LastStartSector = 2048ULL;
1003 LastStartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
1004 LastSectorCount = 0
ULL;
1005 LastUnusedSectorCount = 0
ULL;
1007 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
1008 Entry != &DiskEntry->PrimaryPartListHead;
1016 LastUnusedSectorCount =
1020 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1022 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1024 StartSector = LastStartSector + LastSectorCount;
1025 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1033 if (NewPartEntry ==
NULL)
1035 DPRINT1(
"Failed to create a new empty region for disk space!\n");
1046 if ((LastStartSector + LastSectorCount) < DiskEntry->SectorCount.QuadPart)
1048 LastUnusedSectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment);
1050 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1052 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1054 StartSector = LastStartSector + LastSectorCount;
1055 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1059 &DiskEntry->PrimaryPartListHead,
1063 if (NewPartEntry ==
NULL)
1065 DPRINT1(
"Failed to create a new empty region for trailing disk space!\n");
1071 if (DiskEntry->ExtendedPartition !=
NULL)
1075 DPRINT1(
"No logical partition!\n");
1079 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1080 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
1083 &DiskEntry->LogicalPartListHead,
1087 if (NewPartEntry ==
NULL)
1089 DPRINT1(
"Failed to create a new empty region for full extended partition space!\n");
1097 LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1098 LastSectorCount = 0
ULL;
1099 LastUnusedSectorCount = 0
ULL;
1101 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
1102 Entry != &DiskEntry->LogicalPartListHead;
1110 LastUnusedSectorCount =
1114 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1116 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1118 StartSector = LastStartSector + LastSectorCount;
1119 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1127 if (NewPartEntry ==
NULL)
1129 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1140 if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart)
1142 LastUnusedSectorCount =
AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart +
1143 DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount),
1144 DiskEntry->SectorAlignment);
1146 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1148 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1150 StartSector = LastStartSector + LastSectorCount;
1151 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1155 &DiskEntry->LogicalPartListHead,
1159 if (NewPartEntry ==
NULL)
1161 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1168 DPRINT(
"ScanForUnpartitionedDiskSpace() done\n");
1185 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1201 if (DiskEntry->LayoutBuffer->Signature == 0)
1212 Entry2 != &
List->DiskListHead;
1213 Entry2 = Entry2->
Flink)
1219 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1223 if (DiskEntry != DiskEntry2 &&
1228 if (Entry2 == &
List->DiskListHead)
1250 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1271 ULONG HwAdapterNumber = 0;
1272 ULONG HwControllerNumber = 0;
1273 ULONG RemovableDiskCount = 0;
1281 for (ListEntry =
List->BiosDiskListHead.
Flink;
1282 ListEntry != &
List->BiosDiskListHead;
1283 ListEntry = ListEntry->
Flink)
1297 RemovableDiskCount = 0;
1308 ++RemovableDiskCount;
1319 DPRINT1(
"BIOS disk %lu is not recognized by NTOS!\n", BiosDiskEntry->
DiskNumber);
1345 ULONG LayoutBufferSize;
1358 sizeof(DiskGeometry));
1382 sizeof(ScsiAddress));
1418 for (
i = 0;
i < 128;
i++)
1422 Checksum = ~Checksum + 1;
1433 if (DiskEntry ==
NULL)
1436 DPRINT1(
"Failed to allocate a new disk entry.\n");
1450 sizeof(FileFsDevice),
1454 DPRINT1(
"Couldn't detect device type for disk %lu of identifier '%S'...\n", DiskNumber,
Identifier);
1490 DiskEntry->
DiskStyle = PARTITION_STYLE_RAW;
1510 for (ListEntry =
List->BiosDiskListHead.
Flink;
1511 ListEntry != &
List->BiosDiskListHead;
1512 ListEntry = ListEntry->
Flink)
1522 BiosDiskEntry->
Checksum == Checksum &&
1549 DPRINT1(
"Disk %lu of identifier '%S' has already been found?!\n", DiskNumber,
Identifier);
1556 DPRINT1(
"WARNING: Setup could not find a matching BIOS disk entry. Disk %lu may not be bootable by the BIOS!\n", DiskNumber);
1618 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1630 DPRINT1(
"Failed to allocate the disk layout buffer!\n");
1637 DPRINT1(
"Buffer size: %lu\n", LayoutBufferSize);
1653 DPRINT1(
"NtDeviceIoControlFile() failed (Status: 0x%08lx)\n",
Status);
1662 if (NewLayoutBuffer ==
NULL)
1664 DPRINT1(
"Failed to reallocate the disk layout buffer!\n");
1673#ifdef DUMP_PARTITION_TABLE
1674 DumpPartitionTable(DiskEntry);
1678 DPRINT1(
"Disk %lu is a super-floppy\n", DiskNumber);
1699 DPRINT1(
"No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->
BytesPerSector);
1707 for (
i = 0;
i < 4;
i++)
1715 for (
i = 0;
i < 4;
i++)
1752 if (
List->SystemPartition)
1753 return List->SystemPartition->DiskEntry;
1776 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
1797 if (PartEntry->IsPartitioned &&
1799 PartEntry->BootIndicator)
1829 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1834 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
1835 ListEntry != &DiskEntry->PrimaryPartListHead;
1836 ListEntry = ListEntry->
Flink)
1846 ActivePartition = PartEntry;
1848 DPRINT1(
"Found active system partition %lu in disk %lu, drive letter %C\n",
1856 if (DiskEntry->NewDisk && ActivePartition !=
NULL)
1859 DPRINT1(
"NewDisk TRUE but already existing active partition?\n");
1863 return ActivePartition;
1905 DPRINT1(
"NtQuerySystemInformation() failed, Status 0x%08lx\n",
Status);
1910 for (DiskNumber = 0; DiskNumber < Sdi.
NumberOfDisks; DiskNumber++)
1913 L"\\Device\\Harddisk%lu\\Partition0",
2077 DiskEntry->
Bus == Bus &&
2078 DiskEntry->
Id ==
Id)
2126 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2131 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2132 Entry != &DiskEntry->PrimaryPartListHead;
2145 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
2146 Entry != &DiskEntry->LogicalPartListHead;
2183 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2194 *pDiskEntry = DiskEntry;
2195 if (pPartEntry) *pPartEntry = PartEntry;
2240 if (CurrentPart !=
NULL)
2244 if (CurrentPart->LogicalPartition)
2248 PartListEntry = CurrentPart->ListEntry.
Flink;
2269 if (CurrentPart->IsPartitioned &&
2283 PartListEntry = CurrentPart->ListEntry.
Flink;
2295 :
List->DiskListHead.Flink);
2296 DiskListEntry != &
List->DiskListHead;
2297 DiskListEntry = DiskListEntry->
Flink)
2303 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2332 if (CurrentPart !=
NULL)
2336 if (CurrentPart->LogicalPartition)
2340 PartListEntry = CurrentPart->ListEntry.
Blink;
2357 PartListEntry = CurrentPart->ListEntry.
Blink;
2362 if (CurrentPart->IsPartitioned &&
2376 :
List->DiskListHead.Blink);
2377 DiskListEntry != &
List->DiskListHead;
2378 DiskListEntry = DiskListEntry->
Blink)
2384 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2393 if (CurrentPart->IsPartitioned &&
2444 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2448 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2449 Entry != &DiskEntry->PrimaryPartListHead;
2471 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2475 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2476 ListEntry != &DiskEntry->LogicalPartListHead;
2477 ListEntry = ListEntry->
Flink)
2493 ULONG NewPartitionCount;
2494 ULONG CurrentPartitionCount = 0;
2495 ULONG LayoutBufferSize;
2498 DPRINT1(
"ReAllocateLayoutBuffer()\n");
2502 if (DiskEntry->LayoutBuffer)
2503 CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2505 DPRINT1(
"CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n",
2506 CurrentPartitionCount, NewPartitionCount);
2508 if (CurrentPartitionCount == NewPartitionCount)
2515 DiskEntry->LayoutBuffer,
2517 if (NewLayoutBuffer ==
NULL)
2519 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", LayoutBufferSize);
2526 if (NewPartitionCount > CurrentPartitionCount)
2528 for (
i = CurrentPartitionCount;
i < NewPartitionCount;
i++)
2534 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2552 DPRINT1(
"UpdateDiskLayout()\n");
2556 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2563 DPRINT(
"ReAllocateLayoutBuffer() failed.\n");
2569 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2570 ListEntry != &DiskEntry->PrimaryPartListHead;
2571 ListEntry = ListEntry->
Flink)
2590 DPRINT1(
"Updating primary partition entry %lu\n",
Index);
2613 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2614 ListEntry != &DiskEntry->LogicalPartListHead;
2615 ListEntry = ListEntry->
Flink)
2632 DPRINT1(
"Updating logical partition entry %lu\n",
Index);
2644 if (LinkInfo !=
NULL)
2648 HiddenSectors64.
QuadPart = PartEntry->
StartSector.
QuadPart - DiskEntry->SectorAlignment - DiskEntry->ExtendedPartition->StartSector.QuadPart;
2658 LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[
Index + 1];
2674 DPRINT1(
"Wiping primary partition entry %lu\n",
Index);
2688 for (
Index = 4;
Index < DiskEntry->LayoutBuffer->PartitionCount;
Index++)
2715 DiskEntry->Dirty =
TRUE;
2717#ifdef DUMP_PARTITION_TABLE
2718 DumpPartitionTable(DiskEntry);
2733 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2737 if (PartEntry->LogicalPartition)
2742 if (PartEntry->ListEntry.Blink != ListHead)
2750 return PrevPartEntry;
2768 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2772 if (PartEntry->LogicalPartition)
2777 if (PartEntry->ListEntry.Flink != ListHead)
2785 return NextPartEntry;
2800 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2805 if (PartEntry->IsPartitioned)
2811 if (!PartEntry->LogicalPartition)
2845 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2850 if (PartEntry->IsPartitioned)
2876 DPRINT1(
"CreatePartition(%I64u bytes)\n", SizeBytes);
2879 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned)
2887 DPRINT1(
"PartitionCreationChecks() failed with error %lu\n",
Error);
2910 DPRINT1(
"AddLogicalDiskSpace()\n");
2914 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
2915 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
2918 &DiskEntry->LogicalPartListHead,
2922 if (NewPartEntry ==
NULL)
2924 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
2937 DPRINT1(
"CreateExtendedPartition(%I64u bytes)\n", SizeBytes);
2940 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned)
2948 DPRINT1(
"ExtendedPartitionCreationChecks() failed with error %lu\n",
Error);
2958 if (PartEntry->StartSector.QuadPart < 1450560)
2970 PartEntry->New =
FALSE;
2973 PartEntry->DiskEntry->ExtendedPartition = PartEntry;
2996 if (!PartEntry->IsPartitioned ||
3002 !*PartEntry->FileSystem ||
3003 PartEntry->PartitionNumber == 0)
3013 L"\\Device\\Harddisk%lu\\Partition%lu",
3014 PartEntry->DiskEntry->DiskNumber,
3015 PartEntry->PartitionNumber);
3032 DPRINT1(
"ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &
Name,
Status);
3049 DPRINT1(
"WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
3065 DPRINT1(
"Failed to unmount volume (Status 0x%lx)\n",
Status);
3081 DPRINT1(
"Failed to unlock volume (Status 0x%lx)\n", LockStatus);
3103 PartEntry->DiskEntry ==
NULL || PartEntry->IsPartitioned ==
FALSE)
3111 if (
List->SystemPartition == PartEntry)
3117 DiskEntry = PartEntry->DiskEntry;
3149 if (PrevPartEntry !=
NULL && NextPartEntry !=
NULL)
3164 *FreeRegion = PrevPartEntry;
3166 else if (PrevPartEntry !=
NULL && NextPartEntry ==
NULL)
3179 *FreeRegion = PrevPartEntry;
3181 else if (PrevPartEntry ==
NULL && NextPartEntry !=
NULL)
3195 *FreeRegion = NextPartEntry;
3201 PartEntry->OnDiskPartitionNumber = 0;
3202 PartEntry->PartitionNumber = 0;
3204 PartEntry->BootIndicator =
FALSE;
3207 PartEntry->FileSystem[0] =
L'\0';
3208 PartEntry->DriveLetter = 0;
3209 RtlZeroMemory(PartEntry->VolumeLabel,
sizeof(PartEntry->VolumeLabel));
3213 *FreeRegion = PartEntry;
3235 DPRINT1(
"System partition %lu in disk %lu is an extended partition container?!\n",
3236 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3264 ASSERT(*PartEntry->FileSystem);
3267 if (
wcsicmp(PartEntry->FileSystem,
L"FAT") == 0 ||
3268 wcsicmp(PartEntry->FileSystem,
L"FAT32") == 0 ||
3270 wcsicmp(PartEntry->FileSystem,
L"BTRFS") == 0)
3277 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3278 PartEntry->FileSystem);
3284 ASSERT(!*PartEntry->FileSystem);
3286 DPRINT1(
"System partition %lu in disk %lu with no or unknown FS?!\n",
3287 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3295 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3296 PartEntry->FileSystem);
3321 goto NoSystemPartition;
3325 if (!AlternativeDisk && AlternativePart)
3326 AlternativeDisk = AlternativePart->DiskEntry;
3329 if (AlternativePart)
3330 ASSERT(AlternativeDisk && (AlternativePart->DiskEntry == AlternativeDisk));
3333 if (AlternativeDisk)
3337 CandidatePartition =
NULL;
3352 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3353 goto UseAlternativeDisk;
3357 ActivePartition =
List->SystemPartition;
3360 CandidatePartition = ActivePartition;
3362 DPRINT1(
"Use the current system partition %lu in disk %lu, drive letter %C\n",
3364 CandidatePartition->
DiskEntry->DiskNumber,
3368 return CandidatePartition;
3372 if (DiskEntry != AlternativeDisk)
3381 ListEntry = ListEntry->
Flink)
3387 if (PartEntry == ActivePartition)
3399 CandidatePartition = PartEntry;
3400 goto UseAlternativePartition;
3411 CandidatePartition = PartEntry;
3412 goto UseAlternativePartition;
3431 ListEntry = ListEntry->
Flink)
3437 if (PartEntry == ActivePartition)
3446 CandidatePartition = PartEntry;
3447 goto UseAlternativePartition;
3459 if (!AlternativeDisk || (!ForceSelect && (DiskEntry != AlternativeDisk)))
3460 goto NoSystemPartition;
3464 DPRINT1(
"Alternative disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3465 goto NoSystemPartition;
3468 if (DiskEntry != AlternativeDisk)
3471 DiskEntry = AlternativeDisk;
3477 CandidatePartition = ActivePartition;
3478 goto UseAlternativePartition;
3497 CandidatePartition = PartEntry;
3511 DPRINT1(
"Use new first active system partition %lu in disk %lu, drive letter %C\n",
3513 CandidatePartition->
DiskEntry->DiskNumber,
3517 return CandidatePartition;
3521 DPRINT1(
"NewDisk TRUE but first partition is used?\n");
3530 ListEntry = ListEntry->
Flink)
3551 DPRINT1(
"Use first active system partition %lu in disk %lu, drive letter %C\n",
3553 CandidatePartition->
DiskEntry->DiskNumber,
3557 return CandidatePartition;
3565 if (AlternativePart)
3567 DPRINT1(
"No valid or supported system partition has been found, use the alternative partition!\n");
3568 CandidatePartition = AlternativePart;
3569 goto UseAlternativePartition;
3574 DPRINT1(
"No valid or supported system partition has been found on this system!\n");
3578UseAlternativePartition:
3587 ASSERT(CandidatePartition);
3589 DPRINT1(
"Use alternative active system partition %lu in disk %lu, drive letter %C\n",
3591 CandidatePartition->
DiskEntry->DiskNumber,
3595 return CandidatePartition;
3617 if ((PartEntry ==
List->SystemPartition) ||
3623 ASSERT(PartEntry->DiskEntry);
3626 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3634 if (!(OldActivePart &&
IsPartitionActive(OldActivePart) && (OldActivePart->DiskEntry == PartEntry->DiskEntry)))
3643 OldActivePart->BootIndicator =
FALSE;
3644 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].BootIndicator =
FALSE;
3645 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].RewritePartition =
TRUE;
3646 OldActivePart->DiskEntry->Dirty =
TRUE;
3651 List->SystemPartition = PartEntry;
3654 PartEntry->BootIndicator =
TRUE;
3655 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].BootIndicator =
TRUE;
3656 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition =
TRUE;
3657 PartEntry->DiskEntry->Dirty =
TRUE;
3673 ULONG PartitionCount;
3678 DPRINT(
"WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
3681 if (!DiskEntry->Dirty)
3685 L"\\Device\\Harddisk%lu\\Partition0",
3686 DiskEntry->DiskNumber);
3707#ifdef DUMP_PARTITION_TABLE
3708 DumpPartitionTable(DiskEntry);
3718 PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
3729 DiskEntry->LayoutBuffer,
3731 DiskEntry->LayoutBuffer,
3742 DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
3747 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n",
Status);
3751#ifdef DUMP_PARTITION_TABLE
3752 DumpPartitionTable(DiskEntry);
3758 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
3759 ListEntry != &DiskEntry->PrimaryPartListHead;
3760 ListEntry = ListEntry->
Flink)
3773 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
3774 ListEntry != &DiskEntry->LogicalPartListHead;
3775 ListEntry = ListEntry->
Flink)
3801 DiskEntry->Dirty =
FALSE;
3825 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3834 DPRINT1(
"WritePartitionsToDisk() failed to update disk %lu, Status 0x%08lx\n",
3853 WCHAR ValueNameBuffer[16];
3858 L"\\DosDevices\\%c:",
Letter);
3917 Entry1 != &
List->DiskListHead;
3918 Entry1 = Entry1->
Flink)
3926 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3932 Entry2 = Entry2->
Flink)
3955 Entry2 = Entry2->
Flink)
4008 Entry1 != &
List->DiskListHead;
4009 Entry1 = Entry1->
Flink)
4017 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
4023 Entry2 = Entry2->
Flink)
4029 if (pDiskEntry) *pDiskEntry = DiskEntry;
4030 *pPartEntry = PartEntry;
4037 Entry2 = Entry2->
Flink)
4043 if (pDiskEntry) *pDiskEntry = DiskEntry;
4044 *pPartEntry = PartEntry;
4050 if (pDiskEntry) *pDiskEntry =
NULL;
4067 Entry1 != &
List->DiskListHead;
4068 Entry1 = Entry1->
Flink)
4076 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
4082 Entry2 = Entry2->
Flink)
4088 if (pDiskEntry) *pDiskEntry = DiskEntry;
4089 *pPartEntry = PartEntry;
4096 Entry2 = Entry2->
Flink)
4102 if (pDiskEntry) *pDiskEntry = DiskEntry;
4103 *pPartEntry = PartEntry;
4109 if (pDiskEntry) *pDiskEntry =
NULL;
HANDLE GetRootKeyByPredefKey(IN HANDLE KeyHandle, OUT PCWSTR *RootKeyMountPoint OPTIONAL)
#define PARTITION_ENTRY_UNUSED
#define PARTITION_EXTENDED
#define PARTITION_XINT13_EXTENDED
#define PARTITION_FAT32_XINT13
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
_In_ PFCB _In_ LONGLONG StartingOffset
#define IOCTL_DISK_GET_DRIVE_GEOMETRY
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
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
#define FILE_SYNCHRONOUS_IO_NONALERT
@ FileFsDeviceInformation
@ FileFsVolumeInformation
NTSTATUS InferFileSystem(IN PCWSTR PartitionPath OPTIONAL, IN HANDLE PartitionHandle OPTIONAL, IN OUT PWSTR FileSystemName, IN SIZE_T FileSystemNameSize)
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
struct _CM_FULL_RESOURCE_DESCRIPTOR * PCM_FULL_RESOURCE_DESCRIPTOR
#define CmResourceTypeDeviceSpecific
#define OBJ_CASE_INSENSITIVE
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
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)
static OUT PIO_STATUS_BLOCK IoStatusBlock
#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 FSCTL_LOCK_VOLUME
#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
#define FSCTL_UNLOCK_VOLUME
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define FSCTL_DISMOUNT_VOLUME
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 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 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
NTSTATUS NTAPI NtQuerySystemTime(OUT PLARGE_INTEGER SystemTime)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
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 _FILE_FS_VOLUME_INFORMATION * PFILE_FS_VOLUME_INFORMATION
struct _FILE_FS_VOLUME_INFORMATION FILE_FS_VOLUME_INFORMATION
#define IOCTL_SCSI_GET_ADDRESS
ERROR_NUMBER ExtendedPartitionCreationChecks(_In_ PPARTENTRY PartEntry)
VOID DestroyPartitionList(IN PPARTLIST List)
static VOID AddPartitionToDisk(IN ULONG DiskNumber, IN PDISKENTRY DiskEntry, IN ULONG PartitionIndex, IN BOOLEAN LogicalPartition)
ERROR_NUMBER PartitionCreationChecks(_In_ PPARTENTRY PartEntry)
static BOOLEAN InitializePartitionEntry(_Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes)
PPARTENTRY SelectPartition(IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber)
static VOID GetDriverName(IN PDISKENTRY DiskEntry)
struct _REG_DISK_MOUNT_INFO * PREG_DISK_MOUNT_INFO
BOOLEAN SetMountedDeviceValues(IN PPARTLIST List)
static PDISKENTRY GetSystemDisk(IN PPARTLIST List)
BOOLEAN GetDiskOrPartition(IN PPARTLIST List, IN ULONG DiskNumber, IN ULONG PartitionNumber OPTIONAL, OUT PDISKENTRY *pDiskEntry, OUT PPARTENTRY *pPartEntry OPTIONAL)
ULONGLONG AlignUp(IN ULONGLONG Value, IN ULONG Alignment)
static ULONG GetPrimaryPartitionCount(IN PDISKENTRY DiskEntry)
static VOID UpdateDiskLayout(IN PDISKENTRY DiskEntry)
BOOLEAN WritePartitionsToDisk(IN PPARTLIST List)
PPARTENTRY GetPartition(IN PDISKENTRY DiskEntry, IN ULONG PartitionNumber)
PDISKENTRY GetDiskByNumber(IN PPARTLIST List, IN ULONG DiskNumber)
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
VOID SetMBRPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
static VOID AssignDriveLetters(IN PPARTLIST List)
static BOOLEAN IsSamePrimaryLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo, _In_ PPARTENTRY PartEntry)
PPARTENTRY GetPrevPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
ULONGLONG AlignDown(IN ULONGLONG Value, IN ULONG Alignment)
BOOLEAN GetNextUncheckedPartition(IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
BOOLEAN DeletePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, OUT PPARTENTRY *FreeRegion OPTIONAL)
BOOLEAN IsSuperFloppy(IN PDISKENTRY DiskEntry)
static PPARTENTRY GetPrevUnpartitionedEntry(IN PPARTENTRY PartEntry)
static VOID SetDiskSignature(IN PPARTLIST List, IN PDISKENTRY DiskEntry)
static PPARTENTRY GetNextUnpartitionedEntry(IN PPARTENTRY PartEntry)
static ULONG GetLogicalPartitionCount(IN PDISKENTRY DiskEntry)
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
PPARTLIST CreatePartitionList(VOID)
PPARTENTRY GetNextPartition(IN PPARTLIST List, IN PPARTENTRY CurrentPart OPTIONAL)
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)
PDISKENTRY GetDiskByBiosNumber(IN PPARTLIST List, IN ULONG HwDiskNumber)
static VOID UpdateDiskSignatures(IN PPARTLIST List)
BOOLEAN SetActivePartition(IN PPARTLIST List, IN PPARTENTRY PartEntry, IN PPARTENTRY OldActivePart OPTIONAL)
static VOID EnumerateBiosDiskEntries(IN PPARTLIST PartList)
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)
BOOLEAN GetNextUnformattedPartition(IN PPARTLIST List, OUT PDISKENTRY *pDiskEntry OPTIONAL, OUT PPARTENTRY *pPartEntry)
struct _REG_DISK_MOUNT_INFO REG_DISK_MOUNT_INFO
static BOOLEAN InsertDiskRegion(IN PDISKENTRY DiskEntry, IN PPARTENTRY PartEntry, IN BOOLEAN LogicalPartition)
static BOOLEAN IsEmptyLayoutEntry(_In_ PPARTITION_INFORMATION PartitionInfo)
BOOLEAN SetMountedDeviceValue(IN WCHAR Letter, IN ULONG Signature, IN LARGE_INTEGER StartingOffset)
static VOID UpdateHwDiskNumbers(IN PPARTLIST List)
static BOOLEAN ReAllocateLayoutBuffer(IN PDISKENTRY DiskEntry)
PPARTENTRY FindSupportedSystemPartition(IN PPARTLIST List, IN BOOLEAN ForceSelect, IN PDISKENTRY AlternativeDisk OPTIONAL, IN PPARTENTRY AlternativePart OPTIONAL)
static BOOLEAN IsSupportedActivePartition(IN PPARTENTRY PartEntry)
PDISKENTRY GetDiskBySignature(IN PPARTLIST List, IN ULONG Signature)
NTSTATUS DismountVolume(IN PPARTENTRY PartEntry)
BOOLEAN CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes)
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
PDISKENTRY GetDiskBySCSI(IN PPARTLIST List, IN USHORT Port, IN USHORT Bus, IN USHORT Id)
static VOID AddLogicalDiskSpace(_In_ PDISKENTRY DiskEntry)
BOOLEAN CreateExtendedPartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes)
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::@393 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@393::@402 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 FileSystem[MAX_PATH+1]
struct _DISKENTRY * DiskEntry
ULONG OnDiskPartitionNumber
ULARGE_INTEGER StartSector
PARTITION Partition[PARTITION_TBL_SIZE]
unsigned char PartitionType
LARGE_INTEGER StartingOffset
PRTL_QUERY_REGISTRY_ROUTINE QueryRoutine
#define RTL_CONSTANT_STRING(s)
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_UNSUCCESSFUL
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_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
#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