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 DPRINT(
"AddLogicalDiskSpace()\n");
689 StartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
690 SectorCount = DiskEntry->ExtendedPartition->SectorCount.QuadPart - (
ULONGLONG)DiskEntry->SectorAlignment;
693 &DiskEntry->LogicalPartListHead,
698 DPRINT1(
"Failed to create a new empty region for full extended partition space!\n");
717 DPRINT1(
"Current entry sector count: %I64u\n", PartEntry->SectorCount.QuadPart);
720 ASSERT(!PartEntry->IsPartitioned);
721 ASSERT(PartEntry->SectorCount.QuadPart);
725 ASSERT(!isContainer || !PartEntry->LogicalPartition);
740 DPRINT1(
"Partition size %I64u too small\n", SizeBytes);
752 PartEntry->StartSector.QuadPart == PartEntry->SectorCount.QuadPart))
766 SectorCount2 = PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - StartSector;
772 PartEntry->LogicalPartition);
775 DPRINT1(
"Failed to create a new empty region for disk space!\n");
780 PartEntry->SectorCount.QuadPart = StartSector - PartEntry->StartSector.QuadPart;
784 PartEntry->New =
TRUE;
785 PartEntry->IsPartitioned =
TRUE;
787 PartEntry->BootIndicator =
FALSE;
801 if ((PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1)
817 PartEntry->StartSector.QuadPart,
818 PartEntry->SectorCount.QuadPart);
823 PartEntry->FileSystem[0] =
L'\0';
831 DPRINT1(
"First Sector : %I64u\n", PartEntry->StartSector.QuadPart);
832 DPRINT1(
"Last Sector : %I64u\n", PartEntry->StartSector.QuadPart + PartEntry->SectorCount.QuadPart - 1);
833 DPRINT1(
"Total Sectors: %I64u\n", PartEntry->SectorCount.QuadPart);
858 PartitionInfo = &DiskEntry->LayoutBuffer->PartitionEntry[PartitionIndex];
869 if (PartEntry ==
NULL)
898 DiskEntry->ExtendedPartition = PartEntry;
907 L"\\Device\\Harddisk%lu\\Partition%lu",
908 DiskEntry->DiskNumber,
918 PartitionHandle =
NULL;
939 DPRINT1(
"InferFileSystem() failed, Status 0x%08lx\n",
Status);
977 PartitionHandle =
NULL;
1003 sizeof(LabelBuffer),
1013 DPRINT1(
"NtQueryVolumeInformationFile() failed, Status 0x%08lx\n",
Status);
1018 if (PartitionHandle)
1044 DPRINT(
"ScanForUnpartitionedDiskSpace()\n");
1048 DPRINT1(
"No primary partition!\n");
1052 if (DiskEntry->SectorAlignment < 2048)
1053 StartSector = 2048ULL;
1055 StartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
1056 SectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart, DiskEntry->SectorAlignment) - StartSector;
1059 &DiskEntry->PrimaryPartListHead,
1064 DPRINT1(
"Failed to create a new empty region for full disk space!\n");
1070 if (DiskEntry->SectorAlignment < 2048)
1071 LastStartSector = 2048ULL;
1073 LastStartSector = (
ULONGLONG)DiskEntry->SectorAlignment;
1074 LastSectorCount = 0
ULL;
1075 LastUnusedSectorCount = 0
ULL;
1077 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
1078 Entry != &DiskEntry->PrimaryPartListHead;
1086 LastUnusedSectorCount =
1090 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1092 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1094 StartSector = LastStartSector + LastSectorCount;
1095 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1105 DPRINT1(
"Failed to create a new empty region for disk space!\n");
1116 if ((LastStartSector + LastSectorCount) < DiskEntry->SectorCount.QuadPart)
1118 LastUnusedSectorCount =
AlignDown(DiskEntry->SectorCount.QuadPart - (LastStartSector + LastSectorCount), DiskEntry->SectorAlignment);
1120 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1122 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1124 StartSector = LastStartSector + LastSectorCount;
1125 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1129 &DiskEntry->PrimaryPartListHead,
1135 DPRINT1(
"Failed to create a new empty region for trailing disk space!\n");
1141 if (DiskEntry->ExtendedPartition !=
NULL)
1145 DPRINT1(
"No logical partition!\n");
1153 LastStartSector = DiskEntry->ExtendedPartition->StartSector.QuadPart + (
ULONGLONG)DiskEntry->SectorAlignment;
1154 LastSectorCount = 0
ULL;
1155 LastUnusedSectorCount = 0
ULL;
1157 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
1158 Entry != &DiskEntry->LogicalPartListHead;
1166 LastUnusedSectorCount =
1170 LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1172 DPRINT(
"Unpartitioned disk space %I64u sectors\n", LastUnusedSectorCount);
1174 StartSector = LastStartSector + LastSectorCount;
1175 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1185 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1196 if ((LastStartSector + LastSectorCount) < DiskEntry->ExtendedPartition->StartSector.QuadPart + DiskEntry->ExtendedPartition->SectorCount.QuadPart)
1198 LastUnusedSectorCount =
AlignDown(DiskEntry->ExtendedPartition->StartSector.QuadPart +
1199 DiskEntry->ExtendedPartition->SectorCount.QuadPart - (LastStartSector + LastSectorCount),
1200 DiskEntry->SectorAlignment);
1202 if (LastUnusedSectorCount >= (
ULONGLONG)DiskEntry->SectorAlignment)
1204 DPRINT(
"Unpartitioned disk space: %I64u sectors\n", LastUnusedSectorCount);
1206 StartSector = LastStartSector + LastSectorCount;
1207 SectorCount =
AlignDown(StartSector + LastUnusedSectorCount, DiskEntry->SectorAlignment) - StartSector;
1211 &DiskEntry->LogicalPartListHead,
1217 DPRINT1(
"Failed to create a new empty region for extended partition space!\n");
1224 DPRINT(
"ScanForUnpartitionedDiskSpace() done\n");
1241 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1257 if (DiskEntry->LayoutBuffer->Signature == 0)
1268 Entry2 != &
List->DiskListHead;
1269 Entry2 = Entry2->
Flink)
1275 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1279 if (DiskEntry != DiskEntry2 &&
1284 if (Entry2 == &
List->DiskListHead)
1306 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1327 ULONG HwAdapterNumber = 0;
1328 ULONG HwControllerNumber = 0;
1329 ULONG RemovableDiskCount = 0;
1337 for (ListEntry =
List->BiosDiskListHead.
Flink;
1338 ListEntry != &
List->BiosDiskListHead;
1339 ListEntry = ListEntry->
Flink)
1353 RemovableDiskCount = 0;
1364 ++RemovableDiskCount;
1375 DPRINT1(
"BIOS disk %lu is not recognized by NTOS!\n", BiosDiskEntry->
DiskNumber);
1401 ULONG LayoutBufferSize;
1414 sizeof(DiskGeometry));
1438 sizeof(ScsiAddress));
1474 for (
i = 0;
i < 128;
i++)
1478 Checksum = ~Checksum + 1;
1489 if (DiskEntry ==
NULL)
1492 DPRINT1(
"Failed to allocate a new disk entry.\n");
1506 sizeof(FileFsDevice),
1510 DPRINT1(
"Couldn't detect device type for disk %lu of identifier '%S'...\n", DiskNumber,
Identifier);
1546 DiskEntry->
DiskStyle = PARTITION_STYLE_RAW;
1566 for (ListEntry =
List->BiosDiskListHead.
Flink;
1567 ListEntry != &
List->BiosDiskListHead;
1568 ListEntry = ListEntry->
Flink)
1578 BiosDiskEntry->
Checksum == Checksum &&
1605 DPRINT1(
"Disk %lu of identifier '%S' has already been found?!\n", DiskNumber,
Identifier);
1612 DPRINT1(
"WARNING: Setup could not find a matching BIOS disk entry. Disk %lu may not be bootable by the BIOS!\n", DiskNumber);
1674 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1686 DPRINT1(
"Failed to allocate the disk layout buffer!\n");
1693 DPRINT1(
"Buffer size: %lu\n", LayoutBufferSize);
1709 DPRINT1(
"NtDeviceIoControlFile() failed (Status: 0x%08lx)\n",
Status);
1718 if (NewLayoutBuffer ==
NULL)
1720 DPRINT1(
"Failed to reallocate the disk layout buffer!\n");
1729#ifdef DUMP_PARTITION_TABLE
1730 DumpPartitionTable(DiskEntry);
1734 DPRINT1(
"Disk %lu is a super-floppy\n", DiskNumber);
1755 DPRINT1(
"No valid partition table found! Use megabyte (%lu Sectors) alignment!\n", (1024 * 1024) / DiskEntry->
BytesPerSector);
1763 for (
i = 0;
i < 4;
i++)
1771 for (
i = 0;
i < 4;
i++)
1808 if (
List->SystemPartition)
1809 return List->SystemPartition->DiskEntry;
1832 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
1853 if (PartEntry->IsPartitioned &&
1855 PartEntry->BootIndicator)
1885 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
1890 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
1891 ListEntry != &DiskEntry->PrimaryPartListHead;
1892 ListEntry = ListEntry->
Flink)
1902 ActivePartition = PartEntry;
1904 DPRINT1(
"Found active system partition %lu in disk %lu, drive letter %C\n",
1912 if (DiskEntry->NewDisk && ActivePartition !=
NULL)
1915 DPRINT1(
"NewDisk TRUE but already existing active partition?\n");
1919 return ActivePartition;
1961 DPRINT1(
"NtQuerySystemInformation() failed, Status 0x%08lx\n",
Status);
1966 for (DiskNumber = 0; DiskNumber < Sdi.
NumberOfDisks; DiskNumber++)
1969 L"\\Device\\Harddisk%lu\\Partition0",
2127 DiskEntry->
Bus == Bus &&
2128 DiskEntry->
Id ==
Id)
2175 for (
Entry = DiskEntry->PrimaryPartListHead.Flink;
2176 Entry != &DiskEntry->PrimaryPartListHead;
2189 for (
Entry = DiskEntry->LogicalPartListHead.Flink;
2190 Entry != &DiskEntry->LogicalPartListHead;
2242 if (CurrentPart !=
NULL)
2246 if (CurrentPart->LogicalPartition)
2250 PartListEntry = CurrentPart->ListEntry.
Flink;
2271 if (CurrentPart->IsPartitioned &&
2285 PartListEntry = CurrentPart->ListEntry.
Flink;
2297 :
List->DiskListHead.Flink);
2298 DiskListEntry != &
List->DiskListHead;
2299 DiskListEntry = DiskListEntry->
Flink)
2305 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2334 if (CurrentPart !=
NULL)
2338 if (CurrentPart->LogicalPartition)
2342 PartListEntry = CurrentPart->ListEntry.
Blink;
2359 PartListEntry = CurrentPart->ListEntry.
Blink;
2364 if (CurrentPart->IsPartitioned &&
2378 :
List->DiskListHead.Blink);
2379 DiskListEntry != &
List->DiskListHead;
2380 DiskListEntry = DiskListEntry->
Blink)
2386 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2395 if (CurrentPart->IsPartitioned &&
2449 for (
Entry = PartListHead->Flink;
2450 Entry != PartListHead;
2461#define GetPrimaryPartitionCount(DiskEntry) \
2462 GetPartitionCount(&(DiskEntry)->PrimaryPartListHead)
2464#define GetLogicalPartitionCount(DiskEntry) \
2465 (((DiskEntry)->DiskStyle == PARTITION_STYLE_MBR) \
2466 ? GetPartitionCount(&(DiskEntry)->LogicalPartListHead) : 0)
2475 ULONG NewPartitionCount;
2476 ULONG CurrentPartitionCount = 0;
2477 ULONG LayoutBufferSize;
2480 DPRINT1(
"ReAllocateLayoutBuffer()\n");
2484 if (DiskEntry->LayoutBuffer)
2485 CurrentPartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
2487 DPRINT1(
"CurrentPartitionCount: %lu ; NewPartitionCount: %lu\n",
2488 CurrentPartitionCount, NewPartitionCount);
2490 if (CurrentPartitionCount == NewPartitionCount)
2497 DiskEntry->LayoutBuffer,
2499 if (NewLayoutBuffer ==
NULL)
2501 DPRINT1(
"Failed to allocate the new layout buffer (size: %lu)\n", LayoutBufferSize);
2508 if (NewPartitionCount > CurrentPartitionCount)
2510 for (
i = CurrentPartitionCount;
i < NewPartitionCount;
i++)
2516 DiskEntry->LayoutBuffer = NewLayoutBuffer;
2534 DPRINT1(
"UpdateDiskLayout()\n");
2538 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2545 DPRINT(
"ReAllocateLayoutBuffer() failed.\n");
2551 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
2552 ListEntry != &DiskEntry->PrimaryPartListHead;
2553 ListEntry = ListEntry->
Flink)
2572 DPRINT1(
"Updating primary partition entry %lu\n",
Index);
2596 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
2597 ListEntry != &DiskEntry->LogicalPartListHead;
2598 ListEntry = ListEntry->
Flink)
2615 DPRINT1(
"Updating logical partition entry %lu\n",
Index);
2631 HiddenSectors64.
QuadPart = PartEntry->
StartSector.
QuadPart - DiskEntry->SectorAlignment - DiskEntry->ExtendedPartition->StartSector.QuadPart;
2646 LinkInfo = &DiskEntry->LayoutBuffer->PartitionEntry[
Index + 1];
2662 DPRINT1(
"Wiping primary partition entry %lu\n",
Index);
2676 for (
Index = 4;
Index < DiskEntry->LayoutBuffer->PartitionCount;
Index++)
2703 DiskEntry->Dirty =
TRUE;
2705#ifdef DUMP_PARTITION_TABLE
2706 DumpPartitionTable(DiskEntry);
2734 PartEntry->LogicalPartition)
2744 AdjEntry = PartEntry->ListEntry.
Flink;
2746 AdjEntry = PartEntry->ListEntry.
Blink;
2748 if (AdjEntry != ListHead)
2751 if (!PartEntry->IsPartitioned)
2768 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2773 if (PartEntry->IsPartitioned)
2779 if (!PartEntry->LogicalPartition)
2813 DPRINT1(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
2818 if (PartEntry->IsPartitioned)
2822 if (PartEntry->LogicalPartition)
2852 PCSTR mainType =
"Primary";
2855 mainType =
"Extended";
2856 else if (PartEntry && PartEntry->LogicalPartition)
2857 mainType =
"Logical";
2859 DPRINT1(
"CreatePartition(%s, %I64u bytes)\n", mainType, SizeBytes);
2861 if (!
List || !PartEntry ||
2862 !PartEntry->DiskEntry || PartEntry->IsPartitioned)
2873 DPRINT1(
"PartitionCreationChecks(%s) failed with error %lu\n", mainType,
Error);
2884 PartEntry->New =
FALSE;
2907 if (!PartEntry->IsPartitioned ||
2913 !*PartEntry->FileSystem ||
2914 PartEntry->PartitionNumber == 0)
2924 L"\\Device\\Harddisk%lu\\Partition%lu",
2925 PartEntry->DiskEntry->DiskNumber,
2926 PartEntry->PartitionNumber);
2943 DPRINT1(
"ERROR: Cannot open volume %wZ for dismounting! (Status 0x%lx)\n", &
Name,
Status);
2960 DPRINT1(
"WARNING: Failed to lock volume! Operations may fail! (Status 0x%lx)\n", LockStatus);
2976 DPRINT1(
"Failed to unmount volume (Status 0x%lx)\n",
Status);
2992 DPRINT1(
"Failed to unlock volume (Status 0x%lx)\n", LockStatus);
3013 if (!
List || !PartEntry ||
3014 !PartEntry->DiskEntry || !PartEntry->IsPartitioned)
3022 if (
List->SystemPartition == PartEntry)
3028 DiskEntry = PartEntry->DiskEntry;
3060 if (PrevPartEntry !=
NULL && NextPartEntry !=
NULL)
3075 *FreeRegion = PrevPartEntry;
3077 else if (PrevPartEntry !=
NULL && NextPartEntry ==
NULL)
3090 *FreeRegion = PrevPartEntry;
3092 else if (PrevPartEntry ==
NULL && NextPartEntry !=
NULL)
3106 *FreeRegion = NextPartEntry;
3112 PartEntry->OnDiskPartitionNumber = 0;
3113 PartEntry->PartitionNumber = 0;
3115 PartEntry->BootIndicator =
FALSE;
3118 PartEntry->FileSystem[0] =
L'\0';
3119 PartEntry->DriveLetter = 0;
3120 RtlZeroMemory(PartEntry->VolumeLabel,
sizeof(PartEntry->VolumeLabel));
3124 *FreeRegion = PartEntry;
3146 DPRINT1(
"System partition %lu in disk %lu is an extended partition container?!\n",
3147 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3175 ASSERT(*PartEntry->FileSystem);
3178 if (
wcsicmp(PartEntry->FileSystem,
L"FAT") == 0 ||
3179 wcsicmp(PartEntry->FileSystem,
L"FAT32") == 0 ||
3181 wcsicmp(PartEntry->FileSystem,
L"BTRFS") == 0)
3188 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3189 PartEntry->FileSystem);
3195 ASSERT(!*PartEntry->FileSystem);
3197 DPRINT1(
"System partition %lu in disk %lu with no or unknown FS?!\n",
3198 PartEntry->PartitionNumber, PartEntry->DiskEntry->DiskNumber);
3206 DPRINT1(
"Recognized file system '%S' that doesn't have write support yet!\n",
3207 PartEntry->FileSystem);
3232 goto NoSystemPartition;
3236 if (!AlternativeDisk && AlternativePart)
3237 AlternativeDisk = AlternativePart->DiskEntry;
3240 if (AlternativePart)
3241 ASSERT(AlternativeDisk && (AlternativePart->DiskEntry == AlternativeDisk));
3244 if (AlternativeDisk)
3248 CandidatePartition =
NULL;
3263 goto UseAlternativeDisk;
3268 DPRINT1(
"System disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3269 goto UseAlternativeDisk;
3273 ActivePartition =
List->SystemPartition;
3276 CandidatePartition = ActivePartition;
3278 DPRINT1(
"Use the current system partition %lu in disk %lu, drive letter %C\n",
3280 CandidatePartition->
DiskEntry->DiskNumber,
3284 return CandidatePartition;
3288 if (DiskEntry != AlternativeDisk)
3297 ListEntry = ListEntry->
Flink)
3303 if (PartEntry == ActivePartition)
3315 CandidatePartition = PartEntry;
3316 goto UseAlternativePartition;
3327 CandidatePartition = PartEntry;
3328 goto UseAlternativePartition;
3347 ListEntry = ListEntry->
Flink)
3353 if (PartEntry == ActivePartition)
3362 CandidatePartition = PartEntry;
3363 goto UseAlternativePartition;
3375 if (!AlternativeDisk || (!ForceSelect && (DiskEntry != AlternativeDisk)))
3376 goto NoSystemPartition;
3380 DPRINT1(
"Alternative disk -- GPT-partitioned disk detected, not currently supported by SETUP!\n");
3381 goto NoSystemPartition;
3384 if (DiskEntry != AlternativeDisk)
3387 DiskEntry = AlternativeDisk;
3393 CandidatePartition = ActivePartition;
3394 goto UseAlternativePartition;
3413 CandidatePartition = PartEntry;
3427 DPRINT1(
"Use new first active system partition %lu in disk %lu, drive letter %C\n",
3429 CandidatePartition->
DiskEntry->DiskNumber,
3433 return CandidatePartition;
3437 DPRINT1(
"NewDisk TRUE but first partition is used?\n");
3446 ListEntry = ListEntry->
Flink)
3467 DPRINT1(
"Use first active system partition %lu in disk %lu, drive letter %C\n",
3469 CandidatePartition->
DiskEntry->DiskNumber,
3473 return CandidatePartition;
3481 if (AlternativePart)
3483 DPRINT1(
"No valid or supported system partition has been found, use the alternative partition!\n");
3484 CandidatePartition = AlternativePart;
3485 goto UseAlternativePartition;
3490 DPRINT1(
"No valid or supported system partition has been found on this system!\n");
3494UseAlternativePartition:
3503 ASSERT(CandidatePartition);
3505 DPRINT1(
"Use alternative active system partition %lu in disk %lu, drive letter %C\n",
3507 CandidatePartition->
DiskEntry->DiskNumber,
3511 return CandidatePartition;
3533 if ((PartEntry ==
List->SystemPartition) ||
3539 ASSERT(PartEntry->DiskEntry);
3542 ASSERT(PartEntry->DiskEntry->PartList ==
List);
3550 if (!(OldActivePart &&
IsPartitionActive(OldActivePart) && (OldActivePart->DiskEntry == PartEntry->DiskEntry)))
3559 OldActivePart->BootIndicator =
FALSE;
3560 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].BootIndicator =
FALSE;
3561 OldActivePart->DiskEntry->LayoutBuffer->PartitionEntry[OldActivePart->PartitionIndex].RewritePartition =
TRUE;
3562 OldActivePart->DiskEntry->Dirty =
TRUE;
3567 List->SystemPartition = PartEntry;
3570 PartEntry->BootIndicator =
TRUE;
3571 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].BootIndicator =
TRUE;
3572 PartEntry->DiskEntry->LayoutBuffer->PartitionEntry[PartEntry->PartitionIndex].RewritePartition =
TRUE;
3573 PartEntry->DiskEntry->Dirty =
TRUE;
3589 ULONG PartitionCount;
3594 DPRINT(
"WritePartitions() Disk: %lu\n", DiskEntry->DiskNumber);
3597 if (!DiskEntry->Dirty)
3601 L"\\Device\\Harddisk%lu\\Partition0",
3602 DiskEntry->DiskNumber);
3623#ifdef DUMP_PARTITION_TABLE
3624 DumpPartitionTable(DiskEntry);
3634 PartitionCount = DiskEntry->LayoutBuffer->PartitionCount;
3645 DiskEntry->LayoutBuffer,
3647 DiskEntry->LayoutBuffer,
3658 DiskEntry->LayoutBuffer->PartitionCount = PartitionCount;
3663 DPRINT1(
"IOCTL_DISK_SET_DRIVE_LAYOUT failed (Status 0x%08lx)\n",
Status);
3667#ifdef DUMP_PARTITION_TABLE
3668 DumpPartitionTable(DiskEntry);
3674 for (ListEntry = DiskEntry->PrimaryPartListHead.
Flink;
3675 ListEntry != &DiskEntry->PrimaryPartListHead;
3676 ListEntry = ListEntry->
Flink)
3689 for (ListEntry = DiskEntry->LogicalPartListHead.
Flink;
3690 ListEntry != &DiskEntry->LogicalPartListHead;
3691 ListEntry = ListEntry->
Flink)
3717 DiskEntry->Dirty =
FALSE;
3741 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3750 DPRINT1(
"WritePartitionsToDisk() failed to update disk %lu, Status 0x%08lx\n",
3769 WCHAR ValueNameBuffer[16];
3774 L"\\DosDevices\\%c:",
Letter);
3833 Entry1 != &
List->DiskListHead;
3834 Entry1 = Entry1->
Flink)
3842 DPRINT(
"GPT-partitioned disk detected, not currently supported by SETUP!\n");
3848 Entry2 = Entry2->
Flink)
3871 Entry2 = Entry2->
Flink)
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 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)
ULONGLONG AlignUp(IN ULONGLONG Value, IN ULONG Alignment)
static PPARTENTRY 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 UpdateDiskLayout(IN PDISKENTRY DiskEntry)
BOOLEAN WritePartitionsToDisk(IN PPARTLIST List)
ULONGLONG RoundingDivide(IN ULONGLONG Dividend, IN ULONGLONG Divisor)
VOID SetMBRPartitionType(IN PPARTENTRY PartEntry, IN UCHAR PartitionType)
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.
BOOLEAN CreatePartition(_In_ PPARTLIST List, _Inout_ PPARTENTRY PartEntry, _In_opt_ ULONGLONG SizeBytes, _In_opt_ ULONG_PTR PartitionInfo)
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 IsSuperFloppy(IN PDISKENTRY DiskEntry)
static VOID SetDiskSignature(IN PPARTLIST List, IN PDISKENTRY DiskEntry)
BOOLEAN DeletePartition(_In_ PPARTLIST List, _In_ PPARTENTRY PartEntry, _Out_opt_ PPARTENTRY *FreeRegion)
PDISKENTRY GetDiskByBiosNumber(_In_ PPARTLIST List, _In_ ULONG HwDiskNumber)
PDISKENTRY GetDiskBySCSI(_In_ PPARTLIST List, _In_ USHORT Port, _In_ USHORT Bus, _In_ USHORT Id)
PDISKENTRY GetDiskBySignature(_In_ PPARTLIST List, _In_ ULONG Signature)
static NTSTATUS NTAPI DiskConfigurationDataQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
PPARTLIST CreatePartitionList(VOID)
PPARTENTRY GetPartition(_In_ PDISKENTRY DiskEntry, _In_ ULONG PartitionNumber)
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)
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)
struct _REG_DISK_MOUNT_INFO REG_DISK_MOUNT_INFO
PPARTENTRY SelectPartition(_In_ PPARTLIST List, _In_ ULONG DiskNumber, _In_ ULONG PartitionNumber)
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)
BOOLEAN SetMountedDeviceValue(IN WCHAR Letter, IN ULONG Signature, IN LARGE_INTEGER StartingOffset)
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)
NTSTATUS DismountVolume(IN PPARTENTRY PartEntry)
static NTSTATUS NTAPI DiskIdentifierQueryRoutine(PWSTR ValueName, ULONG ValueType, PVOID ValueData, ULONG ValueLength, PVOID Context, PVOID EntryContext)
NTSTATUS WritePartitions(IN PDISKENTRY DiskEntry)
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::@389 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@389::@398 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
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
#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