2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fstub/disksup.c
5 * PURPOSE: I/O HAL Routines for Disk Access
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 * Eric Kohl (ekohl@rz-online.de)
8 * Casper S. Hornstrup (chorns@users.sourceforge.net)
11 /* INCLUDES ******************************************************************/
16 #include <internal/hal.h>
18 /* DEPRECATED FUNCTIONS ******************************************************/
21 const WCHAR DiskMountString
[] = L
"\\DosDevices\\%C:";
23 #define AUTO_DRIVE ((ULONG)-1)
25 #define PARTITION_MAGIC 0xaa55
29 typedef struct _REG_DISK_MOUNT_INFO
32 LARGE_INTEGER StartingOffset
;
33 } REG_DISK_MOUNT_INFO
, *PREG_DISK_MOUNT_INFO
;
37 typedef enum _DISK_MANAGER
45 HalpAssignDrive(IN PUNICODE_STRING PartitionName
,
49 IN LARGE_INTEGER StartingOffset
,
51 IN PUNICODE_STRING BootDevice
,
52 OUT PUCHAR NtSystemPath
)
54 WCHAR DriveNameBuffer
[16];
55 UNICODE_STRING DriveName
;
58 REG_DISK_MOUNT_INFO DiskMountInfo
;
60 DPRINT("HalpAssignDrive()\n");
62 if ((DriveNumber
!= AUTO_DRIVE
) && (DriveNumber
< 26))
64 /* Force assignment */
65 if ((ObSystemDeviceMap
->DriveMap
& (1 << DriveNumber
)) != 0)
67 DbgPrint("Drive letter already used!\n");
73 /* Automatic assignment */
74 DriveNumber
= AUTO_DRIVE
;
76 for (i
= 2; i
< 26; i
++)
78 if ((ObSystemDeviceMap
->DriveMap
& (1 << i
)) == 0)
85 if (DriveNumber
== AUTO_DRIVE
)
87 DbgPrint("No drive letter available!\n");
92 DPRINT("DriveNumber %d\n", DriveNumber
);
94 /* Update the System Device Map */
95 ObSystemDeviceMap
->DriveMap
|= (1 << DriveNumber
);
96 ObSystemDeviceMap
->DriveType
[DriveNumber
] = DriveType
;
98 /* Build drive name */
99 swprintf(DriveNameBuffer
,
102 RtlInitUnicodeString(&DriveName
,
105 DPRINT(" %wZ ==> %wZ\n",
109 /* Create symbolic link */
110 Status
= IoCreateSymbolicLink(&DriveName
,
114 DriveType
== DOSDEVICE_DRIVE_FIXED
&&
117 DiskMountInfo
.Signature
= Signature
;
118 DiskMountInfo
.StartingOffset
= StartingOffset
;
119 swprintf(DriveNameBuffer
, DiskMountString
, L
'A' + DriveNumber
);
120 RtlInitUnicodeString(&DriveName
, DriveNameBuffer
);
122 Status
= ZwSetValueKey(hKey
,
127 sizeof(DiskMountInfo
));
128 if (!NT_SUCCESS(Status
))
130 DPRINT1("ZwCreateValueKey failed for %wZ, status=%x\n", &DriveName
, Status
);
134 /* Check if this is a boot partition */
135 if (RtlCompareUnicodeString(PartitionName
, BootDevice
, FALSE
) == 0)
137 /* Set NtSystemPath to that partition's disk letter */
138 *NtSystemPath
= 'A' + DriveNumber
;
145 xHalpGetRDiskCount(VOID
)
148 UNICODE_STRING ArcName
;
149 PWCHAR ArcNameBuffer
;
150 OBJECT_ATTRIBUTES ObjectAttributes
;
151 HANDLE DirectoryHandle
;
152 POBJECT_DIRECTORY_INFORMATION DirectoryInfo
;
157 BOOLEAN First
= TRUE
;
160 DirectoryInfo
= ExAllocatePool(PagedPool
, 2 * PAGE_SIZE
);
161 if (DirectoryInfo
== NULL
)
166 RtlInitUnicodeString(&ArcName
, L
"\\ArcName");
167 InitializeObjectAttributes(&ObjectAttributes
,
173 Status
= ZwOpenDirectoryObject (&DirectoryHandle
,
174 SYMBOLIC_LINK_ALL_ACCESS
,
176 if (!NT_SUCCESS(Status
))
178 DPRINT1("ZwOpenDirectoryObject for %wZ failed, status=%lx\n", &ArcName
, Status
);
179 ExFreePool(DirectoryInfo
);
185 while (NT_SUCCESS(Status
))
187 Status
= NtQueryDirectoryObject (DirectoryHandle
,
195 if (NT_SUCCESS(Status
))
198 while (DirectoryInfo
[Count
].Name
.Buffer
)
200 DPRINT("Count %x\n", Count
);
201 DirectoryInfo
[Count
].Name
.Buffer
[DirectoryInfo
[Count
].Name
.Length
/ sizeof(WCHAR
)] = 0;
202 ArcNameBuffer
= DirectoryInfo
[Count
].Name
.Buffer
;
203 if (DirectoryInfo
[Count
].Name
.Length
>= sizeof(L
"multi(0)disk(0)rdisk(0)") - sizeof(WCHAR
) &&
204 !_wcsnicmp(ArcNameBuffer
, L
"multi(0)disk(0)rdisk(", (sizeof(L
"multi(0)disk(0)rdisk(") - sizeof(WCHAR
)) / sizeof(WCHAR
)))
206 DPRINT("%S\n", ArcNameBuffer
);
207 ArcNameBuffer
+= (sizeof(L
"multi(0)disk(0)rdisk(") - sizeof(WCHAR
)) / sizeof(WCHAR
);
209 while (iswdigit(*ArcNameBuffer
))
211 CurrentRDisk
= CurrentRDisk
* 10 + *ArcNameBuffer
- L
'0';
214 if (!_wcsicmp(ArcNameBuffer
, L
")") &&
215 CurrentRDisk
>= RDiskCount
)
217 RDiskCount
= CurrentRDisk
+ 1;
224 ExFreePool(DirectoryInfo
);
229 xHalpGetDiskNumberFromRDisk(ULONG RDisk
, PULONG DiskNumber
)
231 WCHAR NameBuffer
[80];
232 UNICODE_STRING ArcName
;
233 UNICODE_STRING LinkName
;
234 OBJECT_ATTRIBUTES ObjectAttributes
;
239 L
"\\ArcName\\multi(0)disk(0)rdisk(%lu)",
242 RtlInitUnicodeString(&ArcName
, NameBuffer
);
243 InitializeObjectAttributes(&ObjectAttributes
,
248 Status
= ZwOpenSymbolicLinkObject(&LinkHandle
,
249 SYMBOLIC_LINK_ALL_ACCESS
,
251 if (!NT_SUCCESS(Status
))
253 DPRINT1("ZwOpenSymbolicLinkObject failed for %wZ, status=%lx\n", &ArcName
, Status
);
257 LinkName
.Buffer
= NameBuffer
;
259 LinkName
.MaximumLength
= sizeof(NameBuffer
);
260 Status
= ZwQuerySymbolicLinkObject(LinkHandle
,
264 if (!NT_SUCCESS(Status
))
266 DPRINT1("ZwQuerySymbolicLinkObject failed, status=%lx\n", Status
);
269 if (LinkName
.Length
< sizeof(L
"\\Device\\Harddisk0\\Partition0") - sizeof(WCHAR
) ||
270 LinkName
.Length
>= sizeof(NameBuffer
))
272 return STATUS_UNSUCCESSFUL
;
275 NameBuffer
[LinkName
.Length
/ sizeof(WCHAR
)] = 0;
276 if (_wcsnicmp(NameBuffer
, L
"\\Device\\Harddisk", (sizeof(L
"\\Device\\Harddisk") - sizeof(WCHAR
)) / sizeof(WCHAR
)))
278 return STATUS_UNSUCCESSFUL
;
280 LinkName
.Buffer
+= (sizeof(L
"\\Device\\Harddisk") - sizeof(WCHAR
)) / sizeof(WCHAR
);
282 if (!iswdigit(*LinkName
.Buffer
))
284 return STATUS_UNSUCCESSFUL
;
287 while (iswdigit(*LinkName
.Buffer
))
289 *DiskNumber
= *DiskNumber
* 10 + *LinkName
.Buffer
- L
'0';
292 if (_wcsicmp(LinkName
.Buffer
, L
"\\Partition0"))
294 return STATUS_UNSUCCESSFUL
;
296 return STATUS_SUCCESS
;
301 xHalQueryDriveLayout(IN PUNICODE_STRING DeviceName
,
302 OUT PDRIVE_LAYOUT_INFORMATION
*LayoutInfo
)
304 IO_STATUS_BLOCK StatusBlock
;
305 DISK_GEOMETRY DiskGeometry
;
306 PDEVICE_OBJECT DeviceObject
= NULL
;
307 PFILE_OBJECT FileObject
;
312 DPRINT("xHalpQueryDriveLayout %wZ %p\n",
316 /* Get the drives sector size */
317 Status
= IoGetDeviceObjectPointer(DeviceName
,
318 FILE_READ_ATTRIBUTES
,
321 if (!NT_SUCCESS(Status
))
323 DPRINT("Status %x\n", Status
);
327 KeInitializeEvent(&Event
,
331 Irp
= IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_DRIVE_GEOMETRY
,
336 sizeof(DISK_GEOMETRY
),
342 ObDereferenceObject(FileObject
);
343 return(STATUS_INSUFFICIENT_RESOURCES
);
346 Status
= IoCallDriver(DeviceObject
,
348 if (Status
== STATUS_PENDING
)
350 KeWaitForSingleObject(&Event
,
355 Status
= StatusBlock
.Status
;
357 if (!NT_SUCCESS(Status
))
359 if (DeviceObject
->Characteristics
& FILE_REMOVABLE_MEDIA
)
361 DiskGeometry
.BytesPerSector
= 512;
365 ObDereferenceObject(FileObject
);
370 DPRINT("DiskGeometry.BytesPerSector: %d\n",
371 DiskGeometry
.BytesPerSector
);
373 if (DeviceObject
->Characteristics
& FILE_REMOVABLE_MEDIA
)
375 PDRIVE_LAYOUT_INFORMATION Buffer
;
377 /* Allocate a partition list for a single entry. */
378 Buffer
= ExAllocatePool(NonPagedPool
,
379 sizeof(DRIVE_LAYOUT_INFORMATION
));
382 RtlZeroMemory(Buffer
,
383 sizeof(DRIVE_LAYOUT_INFORMATION
));
384 Buffer
->PartitionCount
= 1;
385 *LayoutInfo
= Buffer
;
387 Status
= STATUS_SUCCESS
;
391 Status
= STATUS_UNSUCCESSFUL
;
396 /* Read the partition table */
397 Status
= IoReadPartitionTable(DeviceObject
,
398 DiskGeometry
.BytesPerSector
,
403 ObDereferenceObject(FileObject
);
410 xHalIoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
,
411 IN PSTRING NtDeviceName
,
412 OUT PUCHAR NtSystemPath
,
413 OUT PSTRING NtSystemPathString
)
415 PDRIVE_LAYOUT_INFORMATION
*LayoutArray
;
416 PCONFIGURATION_INFORMATION ConfigInfo
;
417 OBJECT_ATTRIBUTES ObjectAttributes
;
418 IO_STATUS_BLOCK StatusBlock
;
419 UNICODE_STRING UnicodeString1
;
420 UNICODE_STRING UnicodeString2
;
430 PKEY_VALUE_PARTIAL_INFORMATION PartialInformation
;
431 PREG_DISK_MOUNT_INFO DiskMountInfo
;
433 UNICODE_STRING BootDevice
;
435 Status
= RtlAnsiStringToUnicodeString(&BootDevice
,
439 DPRINT("xHalIoAssignDriveLetters()\n");
441 ConfigInfo
= IoGetConfigurationInformation();
443 RDiskCount
= xHalpGetRDiskCount();
445 DPRINT("RDiskCount %d\n", RDiskCount
);
447 Buffer1
= (PWSTR
)ExAllocatePool(PagedPool
,
449 Buffer2
= (PWSTR
)ExAllocatePool(PagedPool
,
452 PartialInformation
= (PKEY_VALUE_PARTIAL_INFORMATION
)ExAllocatePool(PagedPool
,
453 sizeof(KEY_VALUE_PARTIAL_INFORMATION
) + sizeof(REG_DISK_MOUNT_INFO
));
455 DiskMountInfo
= (PREG_DISK_MOUNT_INFO
) PartialInformation
->Data
;
457 /* Open or Create the 'MountedDevices' key */
458 RtlInitUnicodeString(&UnicodeString1
, L
"\\Registry\\Machine\\SYSTEM\\MountedDevices");
459 InitializeObjectAttributes(&ObjectAttributes
,
461 OBJ_CASE_INSENSITIVE
,
464 Status
= ZwOpenKey(&hKey
,
467 if (!NT_SUCCESS(Status
))
469 Status
= ZwCreateKey(&hKey
,
474 REG_OPTION_NON_VOLATILE
,
477 if (!NT_SUCCESS(Status
))
480 DPRINT("ZwCreateKey failed for %wZ, status=%x\n", &UnicodeString1
, Status
);
483 /* Create PhysicalDrive links */
484 DPRINT("Physical disk drives: %d\n", ConfigInfo
->DiskCount
);
485 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
488 L
"\\Device\\Harddisk%d\\Partition0",
490 RtlInitUnicodeString(&UnicodeString1
,
493 InitializeObjectAttributes(&ObjectAttributes
,
499 Status
= ZwOpenFile(&FileHandle
,
500 FILE_READ_DATA
| SYNCHRONIZE
,
504 FILE_SYNCHRONOUS_IO_NONALERT
);
505 if (NT_SUCCESS(Status
))
510 L
"\\??\\PhysicalDrive%d",
512 RtlInitUnicodeString(&UnicodeString2
,
515 DPRINT("Creating link: %S ==> %S\n",
519 IoCreateSymbolicLink(&UnicodeString2
,
524 /* Initialize layout array */
525 if (ConfigInfo
->DiskCount
== 0)
526 goto end_assign_disks
;
527 LayoutArray
= ExAllocatePool(NonPagedPool
,
528 ConfigInfo
->DiskCount
* sizeof(PDRIVE_LAYOUT_INFORMATION
));
529 RtlZeroMemory(LayoutArray
,
530 ConfigInfo
->DiskCount
* sizeof(PDRIVE_LAYOUT_INFORMATION
));
531 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
534 L
"\\Device\\Harddisk%d\\Partition0",
536 RtlInitUnicodeString(&UnicodeString1
,
539 Status
= xHalQueryDriveLayout(&UnicodeString1
,
541 if (!NT_SUCCESS(Status
))
543 DbgPrint("xHalQueryDriveLayout() failed (Status = 0x%lx)\n",
545 LayoutArray
[i
] = NULL
;
548 /* We don't use the RewritePartition value while mounting the disks.
549 * We use this value for marking pre-assigned (registry) partitions.
551 for (j
= 0; j
< LayoutArray
[i
]->PartitionCount
; j
++)
553 LayoutArray
[i
]->PartitionEntry
[j
].RewritePartition
= FALSE
;
558 /* Dump layout array */
559 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
561 DPRINT("Harddisk %d:\n",
564 if (LayoutArray
[i
] == NULL
)
567 DPRINT("Logical partitions: %d\n",
568 LayoutArray
[i
]->PartitionCount
);
570 for (j
= 0; j
< LayoutArray
[i
]->PartitionCount
; j
++)
572 DPRINT(" %d: nr:%x boot:%x type:%x startblock:%I64u count:%I64u\n",
574 LayoutArray
[i
]->PartitionEntry
[j
].PartitionNumber
,
575 LayoutArray
[i
]->PartitionEntry
[j
].BootIndicator
,
576 LayoutArray
[i
]->PartitionEntry
[j
].PartitionType
,
577 LayoutArray
[i
]->PartitionEntry
[j
].StartingOffset
.QuadPart
,
578 LayoutArray
[i
]->PartitionEntry
[j
].PartitionLength
.QuadPart
);
583 /* Assign pre-assigned (registry) partitions */
586 for (k
= 2; k
< 26; k
++)
588 swprintf(Buffer1
, DiskMountString
, L
'A' + k
);
589 RtlInitUnicodeString(&UnicodeString1
, Buffer1
);
590 Status
= ZwQueryValueKey(hKey
,
592 KeyValuePartialInformation
,
594 sizeof(KEY_VALUE_PARTIAL_INFORMATION
) + sizeof(REG_DISK_MOUNT_INFO
),
596 if (NT_SUCCESS(Status
) &&
597 PartialInformation
->Type
== REG_BINARY
&&
598 PartialInformation
->DataLength
== sizeof(REG_DISK_MOUNT_INFO
))
600 DPRINT("%wZ => %08x:%08x%08x\n", &UnicodeString1
, DiskMountInfo
->Signature
,
601 DiskMountInfo
->StartingOffset
.u
.HighPart
, DiskMountInfo
->StartingOffset
.u
.LowPart
);
603 BOOLEAN Found
= FALSE
;
604 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
606 DPRINT("%x\n", LayoutArray
[i
]->Signature
);
607 if (LayoutArray
[i
] &&
608 LayoutArray
[i
]->Signature
&&
609 LayoutArray
[i
]->Signature
== DiskMountInfo
->Signature
)
611 for (j
= 0; j
< LayoutArray
[i
]->PartitionCount
; j
++)
613 if (LayoutArray
[i
]->PartitionEntry
[j
].StartingOffset
.QuadPart
== DiskMountInfo
->StartingOffset
.QuadPart
)
615 if (IsRecognizedPartition(LayoutArray
[i
]->PartitionEntry
[j
].PartitionType
) &&
616 LayoutArray
[i
]->PartitionEntry
[j
].RewritePartition
== FALSE
)
619 L
"\\Device\\Harddisk%d\\Partition%d",
621 LayoutArray
[i
]->PartitionEntry
[j
].PartitionNumber
);
622 RtlInitUnicodeString(&UnicodeString2
,
626 DPRINT(" %wZ\n", &UnicodeString2
);
627 Found
= HalpAssignDrive(&UnicodeString2
,
629 DOSDEVICE_DRIVE_FIXED
,
630 DiskMountInfo
->Signature
,
631 DiskMountInfo
->StartingOffset
,
635 /* Mark the partition as assigned */
636 LayoutArray
[i
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
645 /* We didn't find a partition for this entry, remove them. */
646 Status
= ZwDeleteValueKey(hKey
, &UnicodeString1
);
653 /* Assign bootable partition on first harddisk */
654 DPRINT("Assigning bootable primary partition on first harddisk:\n");
657 Status
= xHalpGetDiskNumberFromRDisk(0, &DiskNumber
);
658 if (NT_SUCCESS(Status
) &&
659 DiskNumber
< ConfigInfo
->DiskCount
&&
660 LayoutArray
[DiskNumber
])
662 /* Search for bootable partition */
663 for (j
= 0; j
< NUM_PARTITION_TABLE_ENTRIES
&& j
< LayoutArray
[DiskNumber
]->PartitionCount
; j
++)
665 if ((LayoutArray
[DiskNumber
]->PartitionEntry
[j
].BootIndicator
== TRUE
) &&
666 IsRecognizedPartition(LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionType
))
668 if (LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
== FALSE
)
671 L
"\\Device\\Harddisk%lu\\Partition%d",
673 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
);
674 RtlInitUnicodeString(&UnicodeString2
,
678 DPRINT(" %wZ\n", &UnicodeString2
);
679 HalpAssignDrive(&UnicodeString2
,
681 DOSDEVICE_DRIVE_FIXED
,
682 LayoutArray
[DiskNumber
]->Signature
,
683 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].StartingOffset
,
687 /* Mark the partition as assigned */
688 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
696 /* Assign remaining primary partitions */
697 DPRINT("Assigning remaining primary partitions:\n");
698 for (RDisk
= 0; RDisk
< RDiskCount
; RDisk
++)
700 Status
= xHalpGetDiskNumberFromRDisk(RDisk
, &DiskNumber
);
701 if (NT_SUCCESS(Status
) &&
702 DiskNumber
< ConfigInfo
->DiskCount
&&
703 LayoutArray
[DiskNumber
])
705 /* Search for primary partitions */
706 for (j
= 0; (j
< NUM_PARTITION_TABLE_ENTRIES
) && (j
< LayoutArray
[DiskNumber
]->PartitionCount
); j
++)
708 if (LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
== FALSE
&&
709 IsRecognizedPartition(LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionType
))
712 L
"\\Device\\Harddisk%d\\Partition%d",
714 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
);
715 RtlInitUnicodeString(&UnicodeString2
,
721 HalpAssignDrive(&UnicodeString2
,
723 DOSDEVICE_DRIVE_FIXED
,
724 LayoutArray
[DiskNumber
]->Signature
,
725 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].StartingOffset
,
729 /* Mark the partition as assigned */
730 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
736 /* Assign extended (logical) partitions */
737 DPRINT("Assigning extended (logical) partitions:\n");
738 for (RDisk
= 0; RDisk
< RDiskCount
; RDisk
++)
740 Status
= xHalpGetDiskNumberFromRDisk(RDisk
, &DiskNumber
);
741 if (NT_SUCCESS(Status
) &&
742 DiskNumber
< ConfigInfo
->DiskCount
&&
743 LayoutArray
[DiskNumber
])
745 /* Search for extended partitions */
746 for (j
= NUM_PARTITION_TABLE_ENTRIES
; j
< LayoutArray
[DiskNumber
]->PartitionCount
; j
++)
748 if (IsRecognizedPartition(LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionType
) &&
749 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
== FALSE
&&
750 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
!= 0)
753 L
"\\Device\\Harddisk%d\\Partition%d",
755 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
);
756 RtlInitUnicodeString(&UnicodeString2
,
762 HalpAssignDrive(&UnicodeString2
,
764 DOSDEVICE_DRIVE_FIXED
,
765 LayoutArray
[DiskNumber
]->Signature
,
766 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].StartingOffset
,
770 /* Mark the partition as assigned */
771 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
777 /* Assign remaining primary partitions without an arc-name */
778 DPRINT("Assigning remaining primary partitions:\n");
779 for (DiskNumber
= 0; DiskNumber
< ConfigInfo
->DiskCount
; DiskNumber
++)
781 if (LayoutArray
[DiskNumber
])
783 /* Search for primary partitions */
784 for (j
= 0; (j
< NUM_PARTITION_TABLE_ENTRIES
) && (j
< LayoutArray
[DiskNumber
]->PartitionCount
); j
++)
786 if (LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
== FALSE
&&
787 IsRecognizedPartition(LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionType
))
790 L
"\\Device\\Harddisk%d\\Partition%d",
792 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
);
793 RtlInitUnicodeString(&UnicodeString2
,
799 HalpAssignDrive(&UnicodeString2
,
801 DOSDEVICE_DRIVE_FIXED
,
802 LayoutArray
[DiskNumber
]->Signature
,
803 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].StartingOffset
,
807 /* Mark the partition as assigned */
808 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
814 /* Assign extended (logical) partitions without an arc-name */
815 DPRINT("Assigning extended (logical) partitions:\n");
816 for (DiskNumber
= 0; DiskNumber
< ConfigInfo
->DiskCount
; DiskNumber
++)
818 if (LayoutArray
[DiskNumber
])
820 /* Search for extended partitions */
821 for (j
= NUM_PARTITION_TABLE_ENTRIES
; j
< LayoutArray
[DiskNumber
]->PartitionCount
; j
++)
823 if (IsRecognizedPartition(LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionType
) &&
824 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
== FALSE
&&
825 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
!= 0)
828 L
"\\Device\\Harddisk%d\\Partition%d",
830 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].PartitionNumber
);
831 RtlInitUnicodeString(&UnicodeString2
,
837 HalpAssignDrive(&UnicodeString2
,
839 DOSDEVICE_DRIVE_FIXED
,
840 LayoutArray
[DiskNumber
]->Signature
,
841 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].StartingOffset
,
845 /* Mark the partition as assigned */
846 LayoutArray
[DiskNumber
]->PartitionEntry
[j
].RewritePartition
= TRUE
;
852 /* Assign removable disk drives */
853 DPRINT("Assigning removable disk drives:\n");
854 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
858 /* Search for virtual partitions */
859 if (LayoutArray
[i
]->PartitionCount
== 1 &&
860 LayoutArray
[i
]->PartitionEntry
[0].PartitionType
== 0)
863 L
"\\Device\\Harddisk%d\\Partition1",
865 RtlInitUnicodeString(&UnicodeString2
,
871 HalpAssignDrive(&UnicodeString2
,
873 DOSDEVICE_DRIVE_REMOVABLE
,
875 RtlConvertLongToLargeInteger(0),
883 /* Free layout array */
884 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
886 if (LayoutArray
[i
] != NULL
)
887 ExFreePool(LayoutArray
[i
]);
889 ExFreePool(LayoutArray
);
892 /* Assign floppy drives */
893 DPRINT("Floppy drives: %d\n", ConfigInfo
->FloppyCount
);
894 for (i
= 0; i
< ConfigInfo
->FloppyCount
; i
++)
897 L
"\\Device\\Floppy%d",
899 RtlInitUnicodeString(&UnicodeString1
,
902 /* Assign drive letters A: or B: or first free drive letter */
905 HalpAssignDrive(&UnicodeString1
,
906 (i
< 2) ? i
: AUTO_DRIVE
,
907 DOSDEVICE_DRIVE_REMOVABLE
,
909 RtlConvertLongToLargeInteger(0),
915 /* Assign cdrom drives */
916 DPRINT("CD-Rom drives: %d\n", ConfigInfo
->CdRomCount
);
917 for (i
= 0; i
< ConfigInfo
->CdRomCount
; i
++)
920 L
"\\Device\\CdRom%d",
922 RtlInitUnicodeString(&UnicodeString1
,
925 /* Assign first free drive letter */
926 DPRINT(" %wZ\n", &UnicodeString1
);
927 HalpAssignDrive(&UnicodeString1
,
929 DOSDEVICE_DRIVE_CDROM
,
931 RtlConvertLongToLargeInteger(0),
937 /* Anything else to do? */
939 ExFreePool(PartialInformation
);
950 /* PRIVATE FUNCTIONS *********************************************************/
954 HalpGetFullGeometry(IN PDEVICE_OBJECT DeviceObject
,
955 IN PDISK_GEOMETRY Geometry
,
956 OUT PULONGLONG RealSectorCount
)
959 IO_STATUS_BLOCK IoStatusBlock
;
962 PARTITION_INFORMATION PartitionInfo
;
965 /* Allocate a non-paged event */
966 Event
= ExAllocatePoolWithTag(NonPagedPool
,
969 if (!Event
) return STATUS_INSUFFICIENT_RESOURCES
;
972 KeInitializeEvent(Event
, NotificationEvent
, FALSE
);
975 Irp
= IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_DRIVE_GEOMETRY
,
980 sizeof(DISK_GEOMETRY
),
986 /* Fail, free the event */
987 ExFreePoolWithTag(Event
, TAG_FILE_SYSTEM
);
988 return STATUS_INSUFFICIENT_RESOURCES
;
991 /* Call the driver and check if it's pending */
992 Status
= IoCallDriver(DeviceObject
, Irp
);
993 if (Status
== STATUS_PENDING
)
995 /* Wait on the driver */
996 KeWaitForSingleObject(Event
, Executive
, KernelMode
, FALSE
, NULL
);
997 Status
= IoStatusBlock
.Status
;
1000 /* Check if the driver returned success */
1001 if(NT_SUCCESS(Status
))
1003 /* Build another IRP */
1004 Irp
= IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_PARTITION_INFO
,
1009 sizeof(PARTITION_INFORMATION
),
1015 /* Fail, free the event */
1016 ExFreePoolWithTag(Event
, TAG_FILE_SYSTEM
);
1017 return STATUS_INSUFFICIENT_RESOURCES
;
1020 /* Call the driver and check if it's pending */
1021 Status
= IoCallDriver(DeviceObject
, Irp
);
1022 if (Status
== STATUS_PENDING
)
1024 /* Wait on the driver */
1025 KeWaitForSingleObject(Event
, Executive
, KernelMode
, FALSE
, NULL
);
1026 Status
= IoStatusBlock
.Status
;
1029 /* Check if the driver returned success */
1030 if(NT_SUCCESS(Status
))
1032 /* Get the number of sectors */
1033 *RealSectorCount
= (PartitionInfo
.PartitionLength
.QuadPart
/
1034 Geometry
->BytesPerSector
);
1038 /* Free the event and return the Status */
1039 ExFreePoolWithTag(Event
, TAG_FILE_SYSTEM
);
1045 HalpIsValidPartitionEntry(IN PPARTITION_DESCRIPTOR Entry
,
1046 IN ULONGLONG MaxOffset
,
1047 IN ULONGLONG MaxSector
)
1049 ULONGLONG EndingSector
;
1052 /* Unused partitions are considered valid */
1053 if (Entry
->PartitionType
== PARTITION_ENTRY_UNUSED
) return TRUE
;
1055 /* Get the last sector of the partition */
1056 EndingSector
= GET_STARTING_SECTOR(Entry
) + GET_PARTITION_LENGTH(Entry
);
1058 /* Check if it's more then the maximum sector */
1059 if (EndingSector
> MaxSector
)
1061 /* Invalid partition */
1062 DPRINT1("FSTUB: entry is invalid\n");
1063 DPRINT1("FSTUB: offset %#08lx\n", GET_STARTING_SECTOR(Entry
));
1064 DPRINT1("FSTUB: length %#08lx\n", GET_PARTITION_LENGTH(Entry
));
1065 DPRINT1("FSTUB: end %#I64x\n", EndingSector
);
1066 DPRINT1("FSTUB: max %#I64x\n", MaxSector
);
1069 else if(GET_STARTING_SECTOR(Entry
) > MaxOffset
)
1071 /* Invalid partition */
1072 DPRINT1("FSTUB: entry is invalid\n");
1073 DPRINT1("FSTUB: offset %#08lx\n", GET_STARTING_SECTOR(Entry
));
1074 DPRINT1("FSTUB: length %#08lx\n", GET_PARTITION_LENGTH(Entry
));
1075 DPRINT1("FSTUB: end %#I64x\n", EndingSector
);
1076 DPRINT1("FSTUB: maxOffset %#I64x\n", MaxOffset
);
1080 /* It's fine, return success */
1086 HalpCalculateChsValues(IN PLARGE_INTEGER PartitionOffset
,
1087 IN PLARGE_INTEGER PartitionLength
,
1088 IN CCHAR ShiftCount
,
1089 IN ULONG SectorsPerTrack
,
1090 IN ULONG NumberOfTracks
,
1091 IN ULONG ConventionalCylinders
,
1092 OUT PPARTITION_DESCRIPTOR PartitionDescriptor
)
1094 LARGE_INTEGER FirstSector
, SectorCount
;
1095 ULONG LastSector
, Remainder
, SectorsPerCylinder
;
1096 ULONG StartingCylinder
, EndingCylinder
;
1097 ULONG StartingTrack
, EndingTrack
;
1098 ULONG StartingSector
, EndingSector
;
1101 /* Calculate the number of sectors for each cylinder */
1102 SectorsPerCylinder
= SectorsPerTrack
* NumberOfTracks
;
1104 /* Calculate the first sector, and the sector count */
1105 FirstSector
.QuadPart
= PartitionOffset
->QuadPart
>> ShiftCount
;
1106 SectorCount
.QuadPart
= PartitionLength
->QuadPart
>> ShiftCount
;
1108 /* Now calculate the last sector */
1109 LastSector
= FirstSector
.LowPart
+ SectorCount
.LowPart
- 1;
1111 /* Calculate the first and last cylinders */
1112 StartingCylinder
= FirstSector
.LowPart
/ SectorsPerCylinder
;
1113 EndingCylinder
= LastSector
/ SectorsPerCylinder
;
1115 /* Set the default number of cylinders */
1116 if (!ConventionalCylinders
) ConventionalCylinders
= 1024;
1118 /* Normalize the values */
1119 if (StartingCylinder
>= ConventionalCylinders
)
1121 /* Set the maximum to 1023 */
1122 StartingCylinder
= ConventionalCylinders
- 1;
1124 if (EndingCylinder
>= ConventionalCylinders
)
1126 /* Set the maximum to 1023 */
1127 EndingCylinder
= ConventionalCylinders
- 1;
1130 /* Calculate the starting head and sector that still remain */
1131 Remainder
= FirstSector
.LowPart
% SectorsPerCylinder
;
1132 StartingTrack
= Remainder
/ SectorsPerTrack
;
1133 StartingSector
= Remainder
% SectorsPerTrack
;
1135 /* Calculate the ending head and sector that still remain */
1136 Remainder
= LastSector
% SectorsPerCylinder
;
1137 EndingTrack
= Remainder
/ SectorsPerTrack
;
1138 EndingSector
= Remainder
% SectorsPerTrack
;
1140 /* Set cylinder data for the MSB */
1141 PartitionDescriptor
->StartingCylinderMsb
= (UCHAR
)StartingCylinder
;
1142 PartitionDescriptor
->EndingCylinderMsb
= (UCHAR
)EndingCylinder
;
1144 /* Set the track data */
1145 PartitionDescriptor
->StartingTrack
= (UCHAR
)StartingTrack
;
1146 PartitionDescriptor
->EndingTrack
= (UCHAR
)EndingTrack
;
1148 /* Update cylinder data for the LSB */
1149 StartingCylinder
= ((StartingSector
+ 1) & 0x3F) |
1150 ((StartingCylinder
>> 2) & 0xC0);
1151 EndingCylinder
= ((EndingSector
+ 1) & 0x3F) |
1152 ((EndingCylinder
>> 2) & 0xC0);
1154 /* Set the cylinder data for the LSB */
1155 PartitionDescriptor
->StartingCylinderLsb
= (UCHAR
)StartingCylinder
;
1156 PartitionDescriptor
->EndingCylinderLsb
= (UCHAR
)EndingCylinder
;
1161 xHalGetPartialGeometry(IN PDEVICE_OBJECT DeviceObject
,
1162 IN PULONG ConventionalCylinders
,
1163 IN PLONGLONG DiskSize
)
1165 PDISK_GEOMETRY DiskGeometry
= NULL
;
1166 PIO_STATUS_BLOCK IoStatusBlock
= NULL
;
1167 PKEVENT Event
= NULL
;
1172 *ConventionalCylinders
= 0;
1175 /* Allocate the structure in nonpaged pool */
1176 DiskGeometry
= ExAllocatePoolWithTag(NonPagedPool
,
1177 sizeof(DISK_GEOMETRY
),
1179 if (!DiskGeometry
) goto Cleanup
;
1181 /* Allocate the status block in nonpaged pool */
1182 IoStatusBlock
= ExAllocatePoolWithTag(NonPagedPool
,
1183 sizeof(IO_STATUS_BLOCK
),
1185 if (!IoStatusBlock
) goto Cleanup
;
1187 /* Allocate the event in nonpaged pool too */
1188 Event
= ExAllocatePoolWithTag(NonPagedPool
,
1191 if (!Event
) goto Cleanup
;
1193 /* Initialize the event */
1194 KeInitializeEvent(Event
, NotificationEvent
, FALSE
);
1197 Irp
= IoBuildDeviceIoControlRequest(IOCTL_DISK_GET_DRIVE_GEOMETRY
,
1202 sizeof(DISK_GEOMETRY
),
1206 if (!Irp
) goto Cleanup
;
1208 /* Now call the driver */
1209 Status
= IoCallDriver(DeviceObject
, Irp
);
1210 if (Status
== STATUS_PENDING
)
1212 /* Wait for it to complete */
1213 KeWaitForSingleObject(Event
, Executive
, KernelMode
, FALSE
, NULL
);
1214 Status
= IoStatusBlock
->Status
;
1217 /* Check driver status */
1218 if (NT_SUCCESS(Status
))
1220 /* Return the cylinder count */
1221 *ConventionalCylinders
= DiskGeometry
->Cylinders
.LowPart
;
1223 /* Make sure it's not larger then 1024 */
1224 if (DiskGeometry
->Cylinders
.LowPart
>= 1024)
1226 /* Otherwise, normalize the value */
1227 *ConventionalCylinders
= 1024;
1230 /* Calculate the disk size */
1231 *DiskSize
= DiskGeometry
->Cylinders
.QuadPart
*
1232 DiskGeometry
->TracksPerCylinder
*
1233 DiskGeometry
->SectorsPerTrack
*
1234 DiskGeometry
->BytesPerSector
;
1238 /* Free all the pointers */
1239 if (Event
) ExFreePoolWithTag(Event
, TAG_FILE_SYSTEM
);
1240 if (IoStatusBlock
) ExFreePool(IoStatusBlock
);
1241 if (DiskGeometry
) ExFreePool(DiskGeometry
);
1247 xHalExamineMBR(IN PDEVICE_OBJECT DeviceObject
,
1248 IN ULONG SectorSize
,
1249 IN ULONG MbrTypeIdentifier
,
1250 OUT PVOID
*MbrBuffer
)
1252 LARGE_INTEGER Offset
;
1256 IO_STATUS_BLOCK IoStatusBlock
;
1258 PPARTITION_DESCRIPTOR PartitionDescriptor
;
1260 PIO_STACK_LOCATION IoStackLocation
;
1261 Offset
.QuadPart
= 0;
1263 /* Assume failure */
1266 /* Normalize the buffer size */
1267 BufferSize
= max(SectorSize
, 512);
1269 /* Allocate the buffer */
1270 Buffer
= ExAllocatePoolWithTag(NonPagedPool
,
1271 PAGE_SIZE
> BufferSize
?
1272 PAGE_SIZE
: BufferSize
,
1274 if (!Buffer
) return;
1276 /* Initialize the Event */
1277 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
1280 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
1290 ExFreePoolWithTag(Buffer
, TAG_FILE_SYSTEM
);
1294 /* Make sure to override volume verification */
1295 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
1296 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
1298 /* Call the driver */
1299 Status
= IoCallDriver(DeviceObject
, Irp
);
1300 if (Status
== STATUS_PENDING
)
1302 /* Wait for completion */
1303 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
1304 Status
= IoStatusBlock
.Status
;
1307 /* Check driver Status */
1308 if (NT_SUCCESS(Status
))
1310 /* Validate the MBR Signature */
1311 if (((PUSHORT
)Buffer
)[BOOT_SIGNATURE_OFFSET
] != BOOT_RECORD_SIGNATURE
)
1314 ExFreePoolWithTag(Buffer
, TAG_FILE_SYSTEM
);
1318 /* Get the partition entry */
1319 PartitionDescriptor
= (PPARTITION_DESCRIPTOR
)
1320 &(((PUSHORT
)Buffer
)[PARTITION_TABLE_OFFSET
]);
1322 /* Make sure it's what the caller wanted */
1323 if (PartitionDescriptor
->PartitionType
!= MbrTypeIdentifier
)
1325 /* It's not, free our buffer */
1326 ExFreePoolWithTag(Buffer
, TAG_FILE_SYSTEM
);
1330 /* Check if this is a secondary entry */
1331 if (PartitionDescriptor
->PartitionType
== 0x54)
1333 /* Return our buffer, but at sector 63 */
1334 *(PULONG
)Buffer
= 63;
1335 *MbrBuffer
= Buffer
;
1337 else if (PartitionDescriptor
->PartitionType
== 0x55)
1339 /* EZ Drive, return the buffer directly */
1340 *MbrBuffer
= Buffer
;
1344 /* Otherwise crash on debug builds */
1345 ASSERT(PartitionDescriptor
->PartitionType
== 0x55);
1353 xHalIoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject
,
1354 IN ULONG SectorSize
,
1355 IN BOOLEAN ReturnRecognizedPartitions
,
1356 IN OUT PDRIVE_LAYOUT_INFORMATION
*PartitionBuffer
)
1359 IO_STATUS_BLOCK IoStatusBlock
;
1361 PPARTITION_DESCRIPTOR PartitionDescriptor
;
1364 PPARTITION_INFORMATION PartitionInfo
;
1365 PUCHAR Buffer
= NULL
;
1366 ULONG BufferSize
= 2048, InputSize
;
1367 PDRIVE_LAYOUT_INFORMATION DriveLayoutInfo
= NULL
;
1368 LONG j
= -1, i
= -1, k
;
1369 DISK_GEOMETRY DiskGeometry
;
1370 LONGLONG EndSector
, MaxSector
, StartOffset
;
1371 ULONGLONG MaxOffset
;
1372 LARGE_INTEGER Offset
, VolumeOffset
;
1373 BOOLEAN IsPrimary
= TRUE
, IsEzDrive
= FALSE
, MbrFound
= FALSE
;
1374 BOOLEAN IsValid
, IsEmpty
= TRUE
;
1376 PIO_STACK_LOCATION IoStackLocation
;
1377 PBOOT_SECTOR_INFO BootSectorInfo
= (PBOOT_SECTOR_INFO
)Buffer
;
1378 UCHAR PartitionType
;
1379 LARGE_INTEGER HiddenSectors64
;
1380 VolumeOffset
.QuadPart
= Offset
.QuadPart
= 0;
1383 /* Allocate the buffer */
1384 *PartitionBuffer
= ExAllocatePoolWithTag(NonPagedPool
,
1387 if (!(*PartitionBuffer
)) return STATUS_INSUFFICIENT_RESOURCES
;
1389 /* Normalize the buffer size */
1390 InputSize
= max(512, SectorSize
);
1392 /* Check for EZ Drive */
1393 HalExamineMBR(DeviceObject
, InputSize
, 0x55, &MbrBuffer
);
1396 /* EZ Drive found, bias the offset */
1398 ExFreePool(MbrBuffer
);
1399 Offset
.QuadPart
= 512;
1402 /* Get drive geometry */
1403 Status
= HalpGetFullGeometry(DeviceObject
, &DiskGeometry
, &MaxOffset
);
1404 if (!NT_SUCCESS(Status
))
1406 ExFreePoolWithTag(*PartitionBuffer
, TAG_FILE_SYSTEM
);
1407 *PartitionBuffer
= NULL
;
1411 /* Get the end and maximum sector */
1412 EndSector
= MaxOffset
;
1413 MaxSector
= MaxOffset
<< 1;
1414 DPRINT("FSTUB: MaxOffset = %#I64x, MaxSector = %#I64x\n",
1415 MaxOffset
, MaxSector
);
1417 /* Allocate our buffer */
1418 Buffer
= ExAllocatePoolWithTag(NonPagedPool
, PAGE_SIZE
, TAG_FILE_SYSTEM
);
1421 /* Fail, free the input buffer */
1422 ExFreePoolWithTag(*PartitionBuffer
, TAG_FILE_SYSTEM
);
1423 *PartitionBuffer
= NULL
;
1424 return STATUS_INSUFFICIENT_RESOURCES
;
1427 /* Start partition loop */
1430 /* Assume the partition is valid */
1433 /* Initialize the event */
1434 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
1436 /* Clear the buffer and build the IRP */
1437 RtlZeroMemory(Buffer
, InputSize
);
1438 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
1448 Status
= STATUS_INSUFFICIENT_RESOURCES
;
1452 /* Make sure to disable volume verification */
1453 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
1454 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
1456 /* Call the driver */
1457 Status
= IoCallDriver(DeviceObject
, Irp
);
1458 if (Status
== STATUS_PENDING
)
1460 /* Wait for completion */
1461 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
1462 Status
= IoStatusBlock
.Status
;
1465 /* Normalize status code and check for failure */
1466 if (Status
== STATUS_NO_DATA_DETECTED
) Status
= STATUS_SUCCESS
;
1467 if (!NT_SUCCESS(Status
)) break;
1469 /* If we biased for EZ-Drive, unbias now */
1470 if (IsEzDrive
&& (Offset
.QuadPart
== 512)) Offset
.QuadPart
= 0;
1472 /* Make sure this is a valid MBR */
1473 if (((PUSHORT
)Buffer
)[BOOT_SIGNATURE_OFFSET
] != BOOT_RECORD_SIGNATURE
)
1475 /* It's not, fail */
1476 DPRINT1("FSTUB: (IoReadPartitionTable) No 0xaa55 found in "
1477 "partition table %d\n", j
+ 1);
1481 /* At this point we have a valid MBR */
1484 /* Check if we weren't given an offset */
1485 if (!Offset
.QuadPart
)
1487 /* Then read the signature off the disk */
1488 (*PartitionBuffer
)->Signature
= ((PULONG
)Buffer
)
1489 [PARTITION_TABLE_OFFSET
/ 2 - 1];
1492 /* Get the partition descriptor array */
1493 PartitionDescriptor
= (PPARTITION_DESCRIPTOR
)
1494 &(((PUSHORT
)Buffer
)[PARTITION_TABLE_OFFSET
]);
1496 /* Get the partition type */
1497 PartitionType
= PartitionDescriptor
->PartitionType
;
1499 /* Start looping partitions */
1501 DPRINT("FSTUB: Partition Table %d:\n", j
);
1502 for (Entry
= 1, k
= 0; Entry
<= 4; Entry
++, PartitionDescriptor
++)
1504 /* Get the partition type */
1505 PartitionType
= PartitionDescriptor
->PartitionType
;
1507 /* Print debug messages */
1508 DPRINT("Partition Entry %d,%d: type %#x %s\n",
1512 (PartitionDescriptor
->ActiveFlag
) ? "Active" : "");
1513 DPRINT("\tOffset %#08lx for %#08lx Sectors\n",
1514 GET_STARTING_SECTOR(PartitionDescriptor
),
1515 GET_PARTITION_LENGTH(PartitionDescriptor
));
1517 /* Make sure that the partition is valid, unless it's the first */
1518 if (!(HalpIsValidPartitionEntry(PartitionDescriptor
,
1520 MaxSector
)) && !(j
))
1522 /* It's invalid, so fail */
1527 /* Check if it's a container */
1528 if (IsContainerPartition(PartitionType
))
1530 /* Increase the count of containers */
1533 /* More then one table is invalid */
1534 DPRINT1("FSTUB: Multiple container partitions found in "
1535 "partition table %d\n - table is invalid\n",
1542 /* Check if the partition is supposedly empty */
1545 /* But check if it actually has a start and/or length */
1546 if ((GET_STARTING_SECTOR(PartitionDescriptor
)) ||
1547 (GET_PARTITION_LENGTH(PartitionDescriptor
)))
1549 /* So then it's not really empty */
1554 /* Check if the caller wanted only recognized partitions */
1555 if (ReturnRecognizedPartitions
)
1557 /* Then check if this one is unused, or a container */
1558 if ((PartitionType
== PARTITION_ENTRY_UNUSED
) ||
1559 IsContainerPartition(PartitionType
))
1561 /* Skip it, since the caller doesn't want it */
1566 /* Increase the structure count and check if they can fit */
1567 if ((sizeof(DRIVE_LAYOUT_INFORMATION
) +
1568 (++i
* sizeof(PARTITION_INFORMATION
))) >
1571 /* Allocate a new buffer that's twice as big */
1572 DriveLayoutInfo
= ExAllocatePoolWithTag(NonPagedPool
,
1575 if (!DriveLayoutInfo
)
1577 /* Out of memory, unto this extra structure */
1579 Status
= STATUS_INSUFFICIENT_RESOURCES
;
1583 /* Copy the contents of the old buffer */
1584 RtlMoveMemory(DriveLayoutInfo
,
1588 /* Free the old buffer and set this one as the new one */
1589 ExFreePoolWithTag(*PartitionBuffer
, TAG_FILE_SYSTEM
);
1590 *PartitionBuffer
= DriveLayoutInfo
;
1592 /* Double the size */
1596 /* Now get the current structure being filled and initialize it */
1597 PartitionInfo
= &(*PartitionBuffer
)->PartitionEntry
[i
];
1598 PartitionInfo
->PartitionType
= PartitionType
;
1599 PartitionInfo
->RewritePartition
= FALSE
;
1601 /* Check if we're dealing with a partition that's in use */
1602 if (PartitionType
!= PARTITION_ENTRY_UNUSED
)
1604 /* Check if it's bootable */
1605 PartitionInfo
->BootIndicator
= PartitionDescriptor
->
1609 /* Check if its' a container */
1610 if (IsContainerPartition(PartitionType
))
1612 /* Then don't recognize it and use the volume offset */
1613 PartitionInfo
->RecognizedPartition
= FALSE
;
1614 StartOffset
= VolumeOffset
.QuadPart
;
1618 /* Then recognize it and use the partition offset */
1619 PartitionInfo
->RecognizedPartition
= TRUE
;
1620 StartOffset
= Offset
.QuadPart
;
1623 /* Get the starting offset */
1624 PartitionInfo
->StartingOffset
.QuadPart
=
1626 UInt32x32To64(GET_STARTING_SECTOR(PartitionDescriptor
),
1629 /* Calculate the number of hidden sectors */
1630 HiddenSectors64
.QuadPart
= (PartitionInfo
->
1631 StartingOffset
.QuadPart
-
1634 PartitionInfo
->HiddenSectors
= HiddenSectors64
.LowPart
;
1636 /* Get the partition length */
1637 PartitionInfo
->PartitionLength
.QuadPart
=
1638 UInt32x32To64(GET_PARTITION_LENGTH(PartitionDescriptor
),
1641 /* FIXME: REACTOS HACK */
1642 PartitionInfo
->PartitionNumber
= i
+ 1;
1646 /* Otherwise, clear all the relevant fields */
1647 PartitionInfo
->BootIndicator
= FALSE
;
1648 PartitionInfo
->RecognizedPartition
= FALSE
;
1649 PartitionInfo
->StartingOffset
.QuadPart
= 0;
1650 PartitionInfo
->PartitionLength
.QuadPart
= 0;
1651 PartitionInfo
->HiddenSectors
= 0;
1653 /* FIXME: REACTOS HACK */
1654 PartitionInfo
->PartitionNumber
= 0;
1658 /* Finish debug log, and check for failure */
1660 if (!NT_SUCCESS(Status
)) break;
1662 /* Also check if we hit an invalid entry here */
1665 /* We did, so break out of the loop minus one entry */
1670 /* Reset the offset */
1671 Offset
.QuadPart
= 0;
1673 /* Go back to the descriptor array and loop it */
1674 PartitionDescriptor
= (PPARTITION_DESCRIPTOR
)
1675 &(((PUSHORT
)Buffer
)[PARTITION_TABLE_OFFSET
]);
1676 for (Entry
= 1; Entry
<= 4; Entry
++, PartitionDescriptor
++)
1678 /* Check if this is a container partition, since we skipped them */
1679 if (IsContainerPartition(PartitionType
))
1681 /* Get its offset */
1682 Offset
.QuadPart
= VolumeOffset
.QuadPart
+
1684 GET_STARTING_SECTOR(PartitionDescriptor
),
1687 /* If this is a primary partition, this is the volume offset */
1688 if (IsPrimary
) VolumeOffset
= Offset
;
1690 /* Also update the maximum sector */
1691 MaxSector
= GET_PARTITION_LENGTH(PartitionDescriptor
);
1692 DPRINT1("FSTUB: MaxSector now = %#08lx\n", MaxSector
);
1697 /* Loop the next partitions, which are not primary anymore */
1699 } while (Offset
.HighPart
| Offset
.LowPart
);
1701 /* Check if this is a removable device that's probably a super-floppy */
1702 if ((DiskGeometry
.MediaType
== RemovableMedia
) &&
1707 /* Read the jump bytes to detect super-floppy */
1708 if ((BootSectorInfo
->JumpByte
[0] == 0xeb) ||
1709 (BootSectorInfo
->JumpByte
[0] == 0xe9))
1711 /* Super floppes don't have typical MBRs, so skip them */
1712 DPRINT1("FSTUB: Jump byte %#x found along with empty partition "
1713 "table - disk is a super floppy and has no valid MBR\n",
1714 BootSectorInfo
->JumpByte
);
1719 /* Check if we're still at partition -1 */
1722 /* The likely cause is the super floppy detection above */
1723 if ((MbrFound
) || (DiskGeometry
.MediaType
== RemovableMedia
))
1725 /* Print out debugging information */
1726 DPRINT1("FSTUB: Drive %#p has no valid MBR. Make it into a "
1729 DPRINT1("FSTUB: Drive has %#08lx sectors and is %#016I64x "
1731 EndSector
, EndSector
* DiskGeometry
.BytesPerSector
);
1733 /* We should at least have some sectors */
1736 /* Get the entry we'll use */
1737 PartitionInfo
= &(*PartitionBuffer
)->PartitionEntry
[0];
1739 /* Fill it out with data for a super-floppy */
1740 PartitionInfo
->RewritePartition
= FALSE
;
1741 PartitionInfo
->RecognizedPartition
= TRUE
;
1742 PartitionInfo
->PartitionType
= PARTITION_FAT_16
;
1743 PartitionInfo
->BootIndicator
= FALSE
;
1744 PartitionInfo
->HiddenSectors
= 0;
1745 PartitionInfo
->StartingOffset
.QuadPart
= 0;
1746 PartitionInfo
->PartitionLength
.QuadPart
= (EndSector
*
1750 /* FIXME: REACTOS HACK */
1751 PartitionInfo
->PartitionNumber
= 0;
1753 /* Set the signature and set the count back to 0 */
1754 (*PartitionBuffer
)->Signature
= 1;
1760 /* Otherwise, this isn't a super floppy, so set an invalid count */
1765 /* Set the partition count */
1766 (*PartitionBuffer
)->PartitionCount
= ++i
;
1768 /* If we have no count, delete the signature */
1769 if (!i
) (*PartitionBuffer
)->Signature
= 0;
1771 /* Free the buffer and check for success */
1772 if (Buffer
) ExFreePoolWithTag(Buffer
, TAG_FILE_SYSTEM
);
1773 if (!NT_SUCCESS(Status
)) ExFreePoolWithTag(*PartitionBuffer
, TAG_FILE_SYSTEM
);
1781 xHalIoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject
,
1782 IN ULONG SectorSize
,
1783 IN ULONG PartitionNumber
,
1784 IN ULONG PartitionType
)
1788 IO_STATUS_BLOCK IoStatusBlock
;
1790 LARGE_INTEGER Offset
, VolumeOffset
;
1791 PUCHAR Buffer
= NULL
;
1795 PPARTITION_DESCRIPTOR PartitionDescriptor
;
1796 BOOLEAN IsPrimary
= TRUE
, IsEzDrive
= FALSE
;
1798 PIO_STACK_LOCATION IoStackLocation
;
1799 VolumeOffset
.QuadPart
= Offset
.QuadPart
= 0;
1802 /* Normalize the buffer size */
1803 BufferSize
= max(512, SectorSize
);
1805 /* Check for EZ Drive */
1806 HalExamineMBR(DeviceObject
, BufferSize
, 0x55, &MbrBuffer
);
1809 /* EZ Drive found, bias the offset */
1811 ExFreePool(MbrBuffer
);
1812 Offset
.QuadPart
= 512;
1815 /* Allocate our partition buffer */
1816 Buffer
= ExAllocatePoolWithTag(NonPagedPool
, PAGE_SIZE
, TAG_FILE_SYSTEM
);
1817 if (!Buffer
) return STATUS_INSUFFICIENT_RESOURCES
;
1819 /* Initialize the event we'll use and loop partitions */
1820 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
1823 /* Reset the event since we reuse it */
1824 KeResetEvent(&Event
);
1826 /* Build the read IRP */
1827 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
1837 Status
= STATUS_INSUFFICIENT_RESOURCES
;
1841 /* Make sure to disable volume verification */
1842 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
1843 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
1845 /* Call the driver */
1846 Status
= IoCallDriver(DeviceObject
, Irp
);
1847 if (Status
== STATUS_PENDING
)
1849 /* Wait for completion */
1850 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
1851 Status
= IoStatusBlock
.Status
;
1854 /* Check for failure */
1855 if (!NT_SUCCESS(Status
)) break;
1857 /* If we biased for EZ-Drive, unbias now */
1858 if (IsEzDrive
&& (Offset
.QuadPart
== 512)) Offset
.QuadPart
= 0;
1860 /* Make sure this is a valid MBR */
1861 if (((PUSHORT
)Buffer
)[BOOT_SIGNATURE_OFFSET
] != BOOT_RECORD_SIGNATURE
)
1863 /* It's not, fail */
1864 Status
= STATUS_BAD_MASTER_BOOT_RECORD
;
1868 /* Get the partition descriptors and loop them */
1869 PartitionDescriptor
= (PPARTITION_DESCRIPTOR
)
1870 &(((PUSHORT
)Buffer
)[PARTITION_TABLE_OFFSET
]);
1871 for (Entry
= 1; Entry
<= 4; Entry
++, PartitionDescriptor
++)
1873 /* Check if it's unused or a container partition */
1874 if ((PartitionDescriptor
->PartitionType
==
1875 PARTITION_ENTRY_UNUSED
) ||
1876 (IsContainerPartition(PartitionDescriptor
->PartitionType
)))
1878 /* Go to the next one */
1882 /* It's a valid partition, so increase the partition count */
1883 if (++i
== PartitionNumber
)
1885 /* We found a match, set the type */
1886 PartitionDescriptor
->PartitionType
= (UCHAR
)PartitionType
;
1888 /* Reset the reusable event */
1889 KeResetEvent(&Event
);
1891 /* Build the write IRP */
1892 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_WRITE
,
1902 Status
= STATUS_INSUFFICIENT_RESOURCES
;
1906 /* Disable volume verification */
1907 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
1908 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
1910 /* Call the driver */
1911 Status
= IoCallDriver(DeviceObject
, Irp
);
1912 if (Status
== STATUS_PENDING
)
1914 /* Wait for completion */
1915 KeWaitForSingleObject(&Event
,
1920 Status
= IoStatusBlock
.Status
;
1923 /* We're done, break out of the loop */
1928 /* If we looped all the partitions, break out */
1929 if (Entry
<= NUM_PARTITION_TABLE_ENTRIES
) break;
1931 /* Nothing found yet, get the partition array again */
1932 PartitionDescriptor
= (PPARTITION_DESCRIPTOR
)
1933 &(((PUSHORT
)Buffer
)[PARTITION_TABLE_OFFSET
]);
1934 for (Entry
= 1; Entry
<= 4; Entry
++, PartitionDescriptor
++)
1936 /* Check if this was a container partition (we skipped these) */
1937 if (IsContainerPartition(PartitionDescriptor
->PartitionType
))
1939 /* Update the partition offset */
1940 Offset
.QuadPart
= VolumeOffset
.QuadPart
+
1941 GET_STARTING_SECTOR(PartitionDescriptor
) *
1944 /* If this was the primary partition, update the volume too */
1945 if (IsPrimary
) VolumeOffset
= Offset
;
1950 /* Check if we already searched all the partitions */
1951 if (Entry
> NUM_PARTITION_TABLE_ENTRIES
)
1953 /* Then we failed to find a good MBR */
1954 Status
= STATUS_BAD_MASTER_BOOT_RECORD
;
1958 /* Loop the next partitions, which are not primary anymore */
1960 } while (i
< PartitionNumber
);
1962 /* Everything done, cleanup */
1963 if (Buffer
) ExFreePool(Buffer
);
1969 xHalIoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject
,
1970 IN ULONG SectorSize
,
1971 IN ULONG SectorsPerTrack
,
1972 IN ULONG NumberOfHeads
,
1973 IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer
)
1976 IO_STATUS_BLOCK IoStatusBlock
;
1978 NTSTATUS Status
= STATUS_SUCCESS
;
1982 PPARTITION_TABLE PartitionTable
;
1983 LARGE_INTEGER Offset
, NextOffset
, ExtendedOffset
, SectorOffset
;
1984 LARGE_INTEGER StartOffset
, PartitionLength
;
1987 BOOLEAN IsEzDrive
= FALSE
, IsSuperFloppy
= FALSE
, DoRewrite
= FALSE
, IsMbr
;
1988 ULONG ConventionalCylinders
;
1990 PDISK_LAYOUT DiskLayout
= (PDISK_LAYOUT
)PartitionBuffer
;
1992 UCHAR PartitionType
;
1993 PIO_STACK_LOCATION IoStackLocation
;
1994 PPARTITION_INFORMATION PartitionInfo
= PartitionBuffer
->PartitionEntry
;
1995 PPARTITION_INFORMATION TableEntry
;
1996 ExtendedOffset
.QuadPart
= NextOffset
.QuadPart
= Offset
.QuadPart
= 0;
1999 /* Normalize the buffer size */
2000 BufferSize
= max(512, SectorSize
);
2002 /* Get the partial drive geometry */
2003 xHalGetPartialGeometry(DeviceObject
, &ConventionalCylinders
, &DiskSize
);
2005 /* Check for EZ Drive */
2006 HalExamineMBR(DeviceObject
, BufferSize
, 0x55, &MbrBuffer
);
2009 /* EZ Drive found, bias the offset */
2011 ExFreePool(MbrBuffer
);
2012 Offset
.QuadPart
= 512;
2015 /* Get the number of bits to shift to multiply by the sector size */
2016 for (k
= 0; k
< 32; k
++) if ((SectorSize
>> k
) == 1) break;
2018 /* Check if there's only one partition */
2019 if (PartitionBuffer
->PartitionCount
== 1)
2021 /* Check if it has no starting offset or hidden sectors */
2022 if (!(PartitionInfo
->StartingOffset
.QuadPart
) &&
2023 !(PartitionInfo
->HiddenSectors
))
2025 /* Then it's a super floppy */
2026 IsSuperFloppy
= TRUE
;
2028 /* Which also means it must be non-bootable FAT-16 */
2029 if ((PartitionInfo
->PartitionNumber
) ||
2030 (PartitionInfo
->PartitionType
!= PARTITION_FAT_16
) ||
2031 (PartitionInfo
->BootIndicator
))
2033 /* It's not, so we fail */
2034 return STATUS_INVALID_PARAMETER
;
2037 /* Check if it needs a rewrite, and disable EZ drive for sure */
2038 if (PartitionInfo
->RewritePartition
) DoRewrite
= TRUE
;
2043 /* Count the number of partition tables */
2044 DiskLayout
->TableCount
= (PartitionBuffer
->PartitionCount
+ 4 - 1) / 4;
2046 /* Allocate our partition buffer */
2047 Buffer
= ExAllocatePoolWithTag(NonPagedPool
, PAGE_SIZE
, TAG_FILE_SYSTEM
);
2048 if (!Buffer
) return STATUS_INSUFFICIENT_RESOURCES
;
2050 /* Loop the entries */
2051 Entry
= (PPTE
)&Buffer
[PARTITION_TABLE_OFFSET
];
2052 for (i
= 0; i
< DiskLayout
->TableCount
; i
++)
2054 /* Set if this is the MBR partition */
2057 /* Initialize th event */
2058 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
2060 /* Build the read IRP */
2061 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_READ
,
2071 Status
= STATUS_INSUFFICIENT_RESOURCES
;
2075 /* Make sure to disable volume verification */
2076 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
2077 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
2079 /* Call the driver */
2080 Status
= IoCallDriver(DeviceObject
, Irp
);
2081 if (Status
== STATUS_PENDING
)
2083 /* Wait for completion */
2084 KeWaitForSingleObject(&Event
, Executive
, KernelMode
, FALSE
, NULL
);
2085 Status
= IoStatusBlock
.Status
;
2088 /* Check for failure */
2089 if (!NT_SUCCESS(Status
)) break;
2091 /* If we biased for EZ-Drive, unbias now */
2092 if (IsEzDrive
&& (Offset
.QuadPart
== 512)) Offset
.QuadPart
= 0;
2094 /* Check if this is a normal disk */
2097 /* Set the boot record signature */
2098 Buffer
[BOOT_SIGNATURE_OFFSET
] = BOOT_RECORD_SIGNATURE
;
2100 /* By default, don't require a rewrite */
2103 /* Check if we don't have an offset */
2104 if (!Offset
.QuadPart
)
2106 /* Check if the signature doesn't match */
2107 if (((PULONG
)Buffer
)[PARTITION_TABLE_OFFSET
/ 2 - 1] !=
2108 PartitionBuffer
->Signature
)
2110 /* Then write the signature and now w need a rewrite */
2111 ((PULONG
)Buffer
)[PARTITION_TABLE_OFFSET
/ 2 - 1] =
2112 PartitionBuffer
->Signature
;
2117 /* Loop the partition table entries */
2118 PartitionTable
= &DiskLayout
->PartitionTable
[i
];
2119 for (j
= 0; j
< 4; j
++)
2121 /* Get the current entry and type */
2122 TableEntry
= &PartitionTable
->PartitionEntry
[j
];
2123 PartitionType
= TableEntry
->PartitionType
;
2125 /* Check if the entry needs a rewrite */
2126 if (TableEntry
->RewritePartition
)
2128 /* Then we need one too */
2131 /* Save the type and if it's a bootable partition */
2132 Entry
[j
].PartitionType
= TableEntry
->PartitionType
;
2133 Entry
[j
].ActiveFlag
= TableEntry
->BootIndicator
? 0x80 : 0;
2135 /* Make sure it's used */
2136 if (PartitionType
!= PARTITION_ENTRY_UNUSED
)
2138 /* Make sure it's not a container (unless primary) */
2139 if ((IsMbr
) || !(IsContainerPartition(PartitionType
)))
2141 /* Use the partition offset */
2142 StartOffset
.QuadPart
= Offset
.QuadPart
;
2146 /* Use the extended logical partition offset */
2147 StartOffset
.QuadPart
= ExtendedOffset
.QuadPart
;
2150 /* Set the sector offset */
2151 SectorOffset
.QuadPart
= TableEntry
->
2152 StartingOffset
.QuadPart
-
2153 StartOffset
.QuadPart
;
2155 /* Now calculate the starting sector */
2156 StartOffset
.QuadPart
= SectorOffset
.QuadPart
>> k
;
2157 Entry
[j
].StartingSector
= StartOffset
.LowPart
;
2159 /* As well as the length */
2160 PartitionLength
.QuadPart
= TableEntry
->PartitionLength
.
2162 Entry
[j
].PartitionLength
= PartitionLength
.LowPart
;
2164 /* Calculate the CHS values */
2165 HalpCalculateChsValues(&TableEntry
->StartingOffset
,
2166 &TableEntry
->PartitionLength
,
2170 ConventionalCylinders
,
2171 (PPARTITION_DESCRIPTOR
)
2176 /* Otherwise set up an empty entry */
2177 Entry
[j
].StartingSector
= 0;
2178 Entry
[j
].PartitionLength
= 0;
2179 Entry
[j
].StartingTrack
= 0;
2180 Entry
[j
].EndingTrack
= 0;
2181 Entry
[j
].StartingCylinder
= 0;
2182 Entry
[j
].EndingCylinder
= 0;
2186 /* Check if this is a container partition */
2187 if (IsContainerPartition(PartitionType
))
2189 /* Then update the offset to use */
2190 NextOffset
= TableEntry
->StartingOffset
;
2195 /* Check if we need to write back the buffer */
2198 /* We don't need to do this again */
2201 /* Initialize the event */
2202 KeInitializeEvent(&Event
, NotificationEvent
, FALSE
);
2204 /* If we unbiased for EZ-Drive, rebias now */
2205 if ((IsEzDrive
) && !(Offset
.QuadPart
)) Offset
.QuadPart
= 512;
2207 /* Build the write IRP */
2208 Irp
= IoBuildSynchronousFsdRequest(IRP_MJ_WRITE
,
2218 Status
= STATUS_INSUFFICIENT_RESOURCES
;
2222 /* Make sure to disable volume verification */
2223 IoStackLocation
= IoGetNextIrpStackLocation(Irp
);
2224 IoStackLocation
->Flags
|= SL_OVERRIDE_VERIFY_VOLUME
;
2226 /* Call the driver */
2227 Status
= IoCallDriver(DeviceObject
, Irp
);
2228 if (Status
== STATUS_PENDING
)
2230 /* Wait for completion */
2231 KeWaitForSingleObject(&Event
,
2236 Status
= IoStatusBlock
.Status
;
2239 /* Check for failure */
2240 if (!NT_SUCCESS(Status
)) break;
2242 /* If we biased for EZ-Drive, unbias now */
2243 if (IsEzDrive
&& (Offset
.QuadPart
== 512)) Offset
.QuadPart
= 0;
2246 /* Update the partition offset and set the extended offset if needed */
2247 Offset
= NextOffset
;
2248 if (IsMbr
) ExtendedOffset
= NextOffset
;
2251 /* If we had a buffer, free it, then return status */
2252 if (Buffer
) ExFreePoolWithTag(Buffer
, TAG_FILE_SYSTEM
);
2256 /* PUBLIC FUNCTIONS **********************************************************/
2263 HalExamineMBR(IN PDEVICE_OBJECT DeviceObject
,
2264 IN ULONG SectorSize
,
2265 IN ULONG MbrTypeIdentifier
,
2266 OUT PVOID
*MbrBuffer
)
2268 HALDISPATCH
->HalExamineMBR(DeviceObject
,
2279 IoReadPartitionTable(IN PDEVICE_OBJECT DeviceObject
,
2280 IN ULONG SectorSize
,
2281 IN BOOLEAN ReturnRecognizedPartitions
,
2282 IN OUT PDRIVE_LAYOUT_INFORMATION
*PartitionBuffer
)
2284 return HALDISPATCH
->HalIoReadPartitionTable(DeviceObject
,
2286 ReturnRecognizedPartitions
,
2295 IoSetPartitionInformation(IN PDEVICE_OBJECT DeviceObject
,
2296 IN ULONG SectorSize
,
2297 IN ULONG PartitionNumber
,
2298 IN ULONG PartitionType
)
2300 return HALDISPATCH
->HalIoSetPartitionInformation(DeviceObject
,
2311 IoWritePartitionTable(IN PDEVICE_OBJECT DeviceObject
,
2312 IN ULONG SectorSize
,
2313 IN ULONG SectorsPerTrack
,
2314 IN ULONG NumberOfHeads
,
2315 IN PDRIVE_LAYOUT_INFORMATION PartitionBuffer
)
2317 return HALDISPATCH
->HalIoWritePartitionTable(DeviceObject
,
2329 IoAssignDriveLetters(IN PLOADER_PARAMETER_BLOCK LoaderBlock
,
2330 IN PSTRING NtDeviceName
,
2331 OUT PUCHAR NtSystemPath
,
2332 OUT PSTRING NtSystemPathString
)
2334 HALDISPATCH
->HalIoAssignDriveLetters(LoaderBlock
,
2337 NtSystemPathString
);