1 /* $Id: xhaldrv.c,v 1.1 2000/06/30 22:52:49 ekohl Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/xhaldrv.c
6 * PURPOSE: Hal drive routines
7 * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/xhal.h>
18 #include <internal/debug.h>
20 /* FUNCTIONS *****************************************************************/
25 IN PDEVICE_OBJECT DeviceObject
,
27 IN ULONG MBRTypeIdentifier
,
32 IO_STATUS_BLOCK StatusBlock
;
38 DPRINT ("xHalExamineMBR()\n");
43 if (SectorSize
> 4096)
46 LocalBuffer
= (PUCHAR
)ExAllocatePool (PagedPool
,
48 if (LocalBuffer
== NULL
)
51 KeInitializeEvent (&Event
,
57 Irp
= IoBuildSynchronousFsdRequest (IRP_MJ_READ
,
65 Status
= IoCallDriver (DeviceObject
,
67 if (Status
== STATUS_PENDING
)
69 KeWaitForSingleObject (&Event
,
74 Status
= StatusBlock
.Status
;
77 if (!NT_SUCCESS(Status
))
79 DPRINT ("xHalExamineMBR failed (Status = 0x%08lx)\n",
81 ExFreePool (LocalBuffer
);
85 if (LocalBuffer
[0x1FE] != 0x55 || LocalBuffer
[0x1FF] != 0xAA)
87 DPRINT ("xHalExamineMBR: invalid MBR signature\n");
88 ExFreePool (LocalBuffer
);
92 if (LocalBuffer
[0x1C2] != MBRTypeIdentifier
)
94 DPRINT ("xHalExamineMBR: invalid MBRTypeIdentifier\n");
95 ExFreePool (LocalBuffer
);
99 *Buffer
= (PVOID
)LocalBuffer
;
104 xHalIoAssignDriveLetters (
105 IN PLOADER_PARAMETER_BLOCK LoaderBlock
,
106 IN PSTRING NtDeviceName
,
107 OUT PUCHAR NtSystemPath
,
108 OUT PSTRING NtSystemPathString
111 PCONFIGURATION_INFORMATION ConfigInfo
;
112 OBJECT_ATTRIBUTES ObjectAttributes
;
113 IO_STATUS_BLOCK StatusBlock
;
114 UNICODE_STRING UnicodeString1
;
115 UNICODE_STRING UnicodeString2
;
122 DPRINT ("xHalIoAssignDriveLetters()\n");
124 ConfigInfo
= IoGetConfigurationInformation ();
126 Buffer1
= (PWSTR
)ExAllocatePool (PagedPool
,
128 Buffer2
= (PWSTR
)ExAllocatePool (PagedPool
,
131 // Create PhysicalDrive links
132 DPRINT ("Physical disk drives: %d\n", ConfigInfo
->DiskCount
);
134 for (i
= 0; i
< ConfigInfo
->DiskCount
; i
++)
137 L
"\\Device\\Harddisk%d\\Partition0",
139 RtlInitUnicodeString (&UnicodeString1
,
142 InitializeObjectAttributes (&ObjectAttributes
,
148 Status
= NtOpenFile (&FileHandle
,
154 if (NT_SUCCESS(Status
))
157 L
"\\??\\PhysicalDrive%d",
159 RtlInitUnicodeString (&UnicodeString2
,
162 DPRINT ("Creating link: %S ==> %S\n",
166 IoCreateSymbolicLink (&UnicodeString2
,
169 NtClose (FileHandle
);
172 ExFreePool (Buffer2
);
173 ExFreePool (Buffer1
);
175 // Assign pre-assigned (registry) partitions
177 // Assign bootable partitions
179 // Assign remaining primary partitions
181 // Assign extended (logical) partitions
183 // Assign floppy drives
184 DPRINT("Floppy drives: %d\n", ConfigInfo
->FloppyCount
);
186 // Assign cdrom drives
187 DPRINT("CD-Rom drives: %d\n", ConfigInfo
->CDRomCount
);