diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index 90881f3cbdd..d78586c0015 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -1,4 +1,4 @@ -/* $Id: ide.c,v 1.33 2000/08/24 19:15:20 ekohl Exp $ +/* $Id: ide.c,v 1.34 2000/08/25 15:56:24 ekohl Exp $ * * IDE.C - IDE Disk driver * written by Rex Jolliff @@ -925,13 +925,13 @@ IDECreateDevice(IN PDRIVER_OBJECT DriverObject, } RtlInitUnicodeString (&ArcName, ArcNameBuffer); - DPRINT1("%wZ ==> %wZ\n", &ArcName, &DeviceName); + DPRINT("%wZ ==> %wZ\n", &ArcName, &DeviceName); RC = IoAssignArcName (&ArcName, &DeviceName); if (!NT_SUCCESS(RC)) { - DPRINT1("IoAssignArcName (%wZ) failed (Status %x)\n", - &ArcName, RC); + DPRINT("IoAssignArcName (%wZ) failed (Status %x)\n", + &ArcName, RC); } diff --git a/reactos/lib/kernel32/file/volume.c b/reactos/lib/kernel32/file/volume.c index 129305012bb..74d88412a2a 100644 --- a/reactos/lib/kernel32/file/volume.c +++ b/reactos/lib/kernel32/file/volume.c @@ -1,4 +1,4 @@ -/* $Id: volume.c,v 1.17 2000/06/29 23:35:24 dwelch Exp $ +/* $Id: volume.c,v 1.18 2000/08/25 15:52:56 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries @@ -6,7 +6,7 @@ * PURPOSE: File volume functions * PROGRAMMER: Ariadne ( ariadne@xs4all.nl) * Erik Bos, Alexandre Julliard : - * DRIVE_IsValid, GetLogicalDriveStringsA, + * GetLogicalDriveStringsA, * GetLogicalDriveStringsW, GetLogicalDrives * UPDATE HISTORY: * Created 01/11/98 @@ -20,6 +20,7 @@ */ #include +#include #include #include @@ -31,68 +32,62 @@ #define MAX_DOS_DRIVES 26 -int DRIVE_IsValid( int drive ) -{ - char Drives[4]; - Drives[0] = 'A'; - Drives[1] = ':'; - Drives[2] = '\\'; - Drives[3] = 0; - - Drives[0] = 'A' + drive -1; - if ((drive < 0) || (drive >= MAX_DOS_DRIVES)) return 0; - if ( CreateFileA(Drives,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_FLAG_BACKUP_SEMANTICS|FILE_ATTRIBUTE_DIRECTORY,NULL) == INVALID_HANDLE_VALUE ) { - return 0; - } - return drive; - -} - - DWORD STDCALL -GetLogicalDriveStringsA( - DWORD nBufferLength, - LPSTR lpBuffer - ) +GetLogicalDriveStringsA(DWORD nBufferLength, + LPSTR lpBuffer) { - int drive, count; + DWORD drive, count; + DWORD dwDriveMap; - for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) - if (DRIVE_IsValid(drive)) count++; - if (count * 4 * sizeof(char) <= nBufferLength) - { - LPSTR p = lpBuffer; - for (drive = 0; drive < MAX_DOS_DRIVES; drive++) - if (DRIVE_IsValid(drive)) + dwDriveMap = ((PKUSER_SHARED_DATA)USER_SHARED_DATA_BASE)->DosDeviceMap; + + for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) + { + if (dwDriveMap & (1<DosDeviceMap; + + for (drive = count = 0; drive < MAX_DOS_DRIVES; drive++) + { + if (dwDriveMap & (1<DosDeviceMap); } diff --git a/reactos/ntoskrnl/io/xhaldrv.c b/reactos/ntoskrnl/io/xhaldrv.c index 350f11e5347..84ff7e5326b 100644 --- a/reactos/ntoskrnl/io/xhaldrv.c +++ b/reactos/ntoskrnl/io/xhaldrv.c @@ -1,4 +1,4 @@ -/* $Id: xhaldrv.c,v 1.6 2000/08/24 19:09:12 ekohl Exp $ +/* $Id: xhaldrv.c,v 1.7 2000/08/25 15:55:02 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -9,14 +9,6 @@ * Created 19/06/2000 */ -/* - * TODO: - * - Read disk signature in xHalIoReadPartitionTable(). - * - Build correct system path from nt device name or arc name. - * For example: \Device\Harddisk0\Partition1\reactos ==> C:\reactos - * Or: multi(0)disk(0)rdisk(0)partition(1)\reactos ==> C:\reactos - */ - /* INCLUDES *****************************************************************/ #include @@ -32,6 +24,7 @@ #define PARTITION_MAGIC 0xaa55 #define PART_MAGIC_OFFSET 0x01fe #define PARTITION_OFFSET 0x01be +#define SIGNATURE_OFFSET 0x01b8 #define PARTITION_TBL_SIZE 4 #define IsUsablePartition(P) \ @@ -676,10 +669,9 @@ xHalIoReadPartitionTable ( } #endif - /* FIXME: Set the correct value */ if (ExtendedFound == FALSE); { - LayoutBuffer->Signature = 0xdeadbeef; + LayoutBuffer->Signature = *((PULONG)(SectorBuffer + SIGNATURE_OFFSET)); } ExtendedFound = FALSE; diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index ae56b7058c4..390a4a27b07 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.58 2000/08/24 19:10:27 ekohl Exp $ +/* $Id: main.c,v 1.59 2000/08/25 15:54:11 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -29,7 +29,7 @@ #include #include -//#define NDEBUG +#define NDEBUG #include /* DATA *********************************************************************/ @@ -161,17 +161,188 @@ CreateSystemRootLink (PCSZ ParameterLine) */ } + static VOID -InitSystemSharedUserPage (VOID) +InitSystemSharedUserPage (PCSZ ParameterLine) { PKUSER_SHARED_DATA SharedPage; + UNICODE_STRING ArcDeviceName; + UNICODE_STRING ArcName; + UNICODE_STRING BootPath; + UNICODE_STRING DriveDeviceName; + UNICODE_STRING DriveName; + WCHAR DriveNameBuffer[20]; + PCHAR ParamBuffer; + PWCHAR ArcNameBuffer; + PCHAR p; + NTSTATUS Status; + ULONG Length; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + ULONG i; + BOOLEAN BootDriveFound; + SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE; - - /* set system root in shared user page */ - wcscpy (SharedPage->NtSystemRoot, L"C:\\reactos"); - + SharedPage->DosDeviceMap = 0; SharedPage->NtProductType = NtProductWinNt; + for (i = 0; i < 32; i++) + { + SharedPage->DosDeviceDriveType[i] = 0; + } + + BootDriveFound = FALSE; + + /* + * Retrieve the current dos system path + * (e.g.: C:\reactos) from the given arc path + * (e.g.: multi(0)disk(0)rdisk(0)partititon(1)\reactos) + * Format: "\ [options...]" + */ + + /* create local parameter line copy */ + ParamBuffer = ExAllocatePool (PagedPool, 256); + strcpy (ParamBuffer, (char *)ParameterLine); + DPRINT("%s\n", ParamBuffer); + + /* cut options off */ + p = strchr (ParamBuffer, ' '); + if (p) + { + *p = 0; + } + DPRINT("%s\n", ParamBuffer); + + /* extract path */ + p = strchr (ParamBuffer, '\\'); + if (p) + { + DPRINT("Boot path: %s\n", p); + RtlCreateUnicodeStringFromAsciiz (&BootPath, p); + *p = 0; + } + else + { + DPRINT("Boot path: %s\n", "\\"); + RtlCreateUnicodeStringFromAsciiz (&BootPath, "\\"); + } + DPRINT("Arc name: %s\n", ParamBuffer); + + /* Only arc name left - build full arc name */ + ArcNameBuffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR)); + swprintf (ArcNameBuffer, L"\\ArcName\\%S", ParamBuffer); + RtlInitUnicodeString (&ArcName, ArcNameBuffer); + DPRINT("Arc name: %wZ\n", &ArcName); + + /* free ParamBuffer */ + ExFreePool (ParamBuffer); + + /* allocate arc device name string */ + ArcDeviceName.Length = 0; + ArcDeviceName.MaximumLength = 256 * sizeof(WCHAR); + ArcDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR)); + + InitializeObjectAttributes (&ObjectAttributes, + &ArcName, + 0, + NULL, + NULL); + + Status = NtOpenSymbolicLinkObject (&Handle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes); + RtlFreeUnicodeString (&ArcName); + if (!NT_SUCCESS(Status)) + { + RtlFreeUnicodeString (&BootPath); + RtlFreeUnicodeString (&ArcDeviceName); + DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n", + Status); + + KeBugCheck (0x0); + } + + Status = NtQuerySymbolicLinkObject (Handle, + &ArcDeviceName, + &Length); + NtClose (Handle); + if (!NT_SUCCESS(Status)) + { + RtlFreeUnicodeString (&BootPath); + RtlFreeUnicodeString (&ArcDeviceName); + DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n", + Status); + + KeBugCheck (0x0); + } + DPRINT("Length: %lu ArcDeviceName: %wZ\n", Length, &ArcDeviceName); + + + /* allocate device name string */ + DriveDeviceName.Length = 0; + DriveDeviceName.MaximumLength = 256 * sizeof(WCHAR); + DriveDeviceName.Buffer = ExAllocatePool (PagedPool, 256 * sizeof(WCHAR)); + + for (i = 0; i < 26; i++) + { + swprintf (DriveNameBuffer, L"\\??\\%C:", 'A' + i); + RtlInitUnicodeString (&DriveName, + DriveNameBuffer); + + InitializeObjectAttributes (&ObjectAttributes, + &DriveName, + 0, + NULL, + NULL); + + Status = NtOpenSymbolicLinkObject (&Handle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed to open link %wZ\n", + &DriveName); + continue; + } + + Status = NtQuerySymbolicLinkObject (Handle, + &DriveDeviceName, + &Length); + if (!NT_SUCCESS(Status)) + { + DPRINT("Failed query open link %wZ\n", + &DriveName); + continue; + } + DPRINT("Opened link: %wZ ==> %wZ\n", + &DriveName, &DriveDeviceName); + + if (!RtlCompareUnicodeString (&ArcDeviceName, &DriveDeviceName, FALSE)) + { + DPRINT("DOS Boot path: %c:%wZ\n", 'A' + i, &BootPath); + swprintf (SharedPage->NtSystemRoot, + L"%C:%wZ", 'A' + i, &BootPath); + + BootDriveFound = TRUE; + } + + NtClose (Handle); + + /* set bit in dos drives bitmap (drive available) */ + SharedPage->DosDeviceMap |= (1<DosDeviceMap); + + if (BootDriveFound == FALSE) + { + DbgPrint("No system drive found!\n"); + KeBugCheck (0x0); + } } @@ -307,8 +478,11 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) NULL, NULL); - /* initialize shared user page */ - InitSystemSharedUserPage (); + /* + * Initialize shared user page: + * - set dos system path, dos device map, etc. + */ + InitSystemSharedUserPage (KeLoaderBlock.kernel_parameters); /* * Launch initial process