diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index e1df92ebc57..90881f3cbdd 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -1,4 +1,4 @@ -/* $Id: ide.c,v 1.32 2000/08/22 21:09:25 ekohl Exp $ +/* $Id: ide.c,v 1.33 2000/08/24 19:15:20 ekohl Exp $ * * IDE.C - IDE Disk driver * written by Rex Jolliff @@ -64,12 +64,9 @@ * FIXME: add support for ATAPI tape drives */ -#include - // ------------------------------------------------------------------------- -#include "../../../ntoskrnl/include/internal/i386/io.h" -#include +#include #define NDEBUG #include @@ -153,10 +150,12 @@ static BOOLEAN IDEGetPartitionTable(IN int CommandPort, IN PIDE_DRIVE_IDENTIFY DrvParms, PARTITION *PartitionTable); static NTSTATUS IDECreateDevice(IN PDRIVER_OBJECT DriverObject, - IN PCHAR DeviceName, +// IN PCHAR DeviceName, OUT PDEVICE_OBJECT *DeviceObject, IN PCONTROLLER_OBJECT ControllerObject, IN int UnitNumber, + IN ULONG DiskNumber, + IN ULONG PartitionNumber, IN PIDE_DRIVE_IDENTIFY DrvParms, IN DWORD Offset, IN DWORD Size); @@ -186,7 +185,7 @@ static VOID IDEDpcForIsr(IN PKDPC Dpc, IN PVOID DpcContext); static VOID IDEFinishOperation(PIDE_CONTROLLER_EXTENSION ControllerExtension); static VOID IDEIoTimer(PDEVICE_OBJECT DeviceObject, PVOID Context); - + // ---------------------------------------------------------------- Inlines extern inline void @@ -468,8 +467,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, IN int HarddiskIdx) { BOOLEAN CreatedDevices; - char RawDeviceName[IDE_MAX_NAME_LENGTH]; - char PrimaryDeviceName[IDE_MAX_NAME_LENGTH]; + WCHAR NameBuffer[IDE_MAX_NAME_LENGTH]; int CommandPort, PartitionIdx, PartitionNum; NTSTATUS RC; IDE_DRIVE_IDENTIFY DrvParms; @@ -477,8 +475,6 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, PDEVICE_OBJECT PrimaryDeviceObject; PIDE_DEVICE_EXTENSION RawDeviceExtension; PARTITION PartitionTable[4], *p; - char DeviceDirName[IDE_MAX_NAME_LENGTH + 1]; - ANSI_STRING AnsiDeviceDirName; UNICODE_STRING UnicodeDeviceDirName; OBJECT_ATTRIBUTES DeviceDirAttributes; HANDLE Handle; @@ -506,23 +502,15 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, CreatedDevices = FALSE; // Create the harddisk device directory - strcpy(DeviceDirName, IDE_NT_ROOTDIR_NAME); - strcat(DeviceDirName, IDE_NT_DEVICE_NAME); - DeviceDirName[strlen(DeviceDirName) + 1] = '\0'; - DeviceDirName[strlen(DeviceDirName)] = '0' + HarddiskIdx; - RtlInitAnsiString(&AnsiDeviceDirName, DeviceDirName); - RC = RtlAnsiStringToUnicodeString(&UnicodeDeviceDirName, - &AnsiDeviceDirName, - TRUE); - if (!NT_SUCCESS(RC)) - { - DPRINT("Could not convert ansi to unicode for device dir\n", 0); - return FALSE; - } - InitializeObjectAttributes(&DeviceDirAttributes, - &UnicodeDeviceDirName, - 0, - NULL, + swprintf (NameBuffer, + L"\\Device\\Harddisk%d", + HarddiskIdx); + RtlInitUnicodeString(&UnicodeDeviceDirName, + NameBuffer); + InitializeObjectAttributes(&DeviceDirAttributes, + &UnicodeDeviceDirName, + 0, + NULL, NULL); RC = ZwCreateDirectoryObject(&Handle, 0, &DeviceDirAttributes); if (!NT_SUCCESS(RC)) @@ -530,17 +518,8 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, DPRINT("Could not create device dir object\n", 0); return FALSE; } - RtlFreeUnicodeString(&UnicodeDeviceDirName); // Create the raw device - strcpy(RawDeviceName, IDE_NT_ROOTDIR_NAME); - strcat(RawDeviceName, IDE_NT_DEVICE_NAME); - RawDeviceName[strlen(RawDeviceName) + 1] = '\0'; - RawDeviceName[strlen(RawDeviceName)] = '0' + HarddiskIdx; - strcat(RawDeviceName, IDE_NT_PARTITION_NAME); - RawDeviceName[strlen(RawDeviceName) + 1] = '\0'; - RawDeviceName[strlen(RawDeviceName)] = '0'; - if (DrvParms.Capabilities & IDE_DRID_LBA_SUPPORTED) { SectorCount = @@ -553,10 +532,11 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, } RC = IDECreateDevice(DriverObject, - RawDeviceName, &RawDeviceObject, ControllerObject, DriveIdx, + HarddiskIdx, + 0, &DrvParms, 0, SectorCount); @@ -620,19 +600,13 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, p->SectorCount); // Create Device for partition - strcpy(PrimaryDeviceName, IDE_NT_ROOTDIR_NAME); - strcat(PrimaryDeviceName, IDE_NT_DEVICE_NAME); - PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0'; - PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + HarddiskIdx; - strcat(PrimaryDeviceName, IDE_NT_PARTITION_NAME); - PrimaryDeviceName[strlen(PrimaryDeviceName) + 1] = '\0'; - PrimaryDeviceName[strlen(PrimaryDeviceName)] = '0' + PartitionNum++; TotalPartitions++; RC = IDECreateDevice(DriverObject, - PrimaryDeviceName, &PrimaryDeviceObject, ControllerObject, DriveIdx, + HarddiskIdx, + PartitionNum, &DrvParms, p->StartingBlock + PartitionOffset, p->SectorCount); @@ -642,6 +616,7 @@ IDECreateDevices(IN PDRIVER_OBJECT DriverObject, break; } PartitionOffset += (p->StartingBlock + p->SectorCount); + PartitionNum++; } else if (IsExtendedPartition(p->PartitionType)) { @@ -852,7 +827,6 @@ IDEGetPartitionTable(IN int CommandPort, // // ARGUMENTS: // IN PDRIVER_OBJECT DriverObject The system supplied driver object -// IN PCHAR DeviceName The name of the device // OUT PDEVICE_OBJECT *DeviceObject The created device object // IN PCONTROLLER_OBJECT ControllerObject The Controller for the device // IN BOOLEAN LBASupported Does the drive support LBA addressing? @@ -866,32 +840,36 @@ IDEGetPartitionTable(IN int CommandPort, // NTSTATUS // -NTSTATUS -IDECreateDevice(IN PDRIVER_OBJECT DriverObject, - IN PCHAR DeviceName, - OUT PDEVICE_OBJECT *DeviceObject, - IN PCONTROLLER_OBJECT ControllerObject, +NTSTATUS +IDECreateDevice(IN PDRIVER_OBJECT DriverObject, + OUT PDEVICE_OBJECT *DeviceObject, + IN PCONTROLLER_OBJECT ControllerObject, IN int UnitNumber, + IN ULONG DiskNumber, + IN ULONG PartitionNumber, IN PIDE_DRIVE_IDENTIFY DrvParms, - IN DWORD Offset, - IN DWORD Size) + IN DWORD Offset, + IN DWORD Size) { - WCHAR UnicodeBuffer[IDE_MAX_NAME_LENGTH]; + WCHAR NameBuffer[IDE_MAX_NAME_LENGTH]; + WCHAR ArcNameBuffer[IDE_MAX_NAME_LENGTH + 15]; + UNICODE_STRING DeviceName; + UNICODE_STRING ArcName; NTSTATUS RC; - ANSI_STRING AnsiName; - UNICODE_STRING UnicodeName; PIDE_DEVICE_EXTENSION DeviceExtension; // Create a unicode device name - RtlInitAnsiString(&AnsiName, DeviceName); - UnicodeName.MaximumLength = IDE_MAX_NAME_LENGTH * sizeof(WCHAR); - UnicodeName.Buffer = UnicodeBuffer; - RtlAnsiStringToUnicodeString(&UnicodeName, &AnsiName, FALSE); + swprintf(NameBuffer, + L"\\Device\\Harddisk%d\\Partition%d", + DiskNumber, + PartitionNumber); + RtlInitUnicodeString(&DeviceName, + NameBuffer); // Create the device - RC = IoCreateDevice(DriverObject, sizeof(IDE_DEVICE_EXTENSION), - &UnicodeName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject); - if (!NT_SUCCESS(RC)) + RC = IoCreateDevice(DriverObject, sizeof(IDE_DEVICE_EXTENSION), + &DeviceName, FILE_DEVICE_DISK, 0, TRUE, DeviceObject); + if (!NT_SUCCESS(RC)) { DPRINT("IoCreateDevice call failed\n",0); return RC; @@ -912,21 +890,50 @@ IDECreateDevice(IN PDRIVER_OBJECT DriverObject, (DrvParms->Capabilities & IDE_DRID_DMA_SUPPORTED) ? 1 : 0; // FIXME: deal with bizarre sector sizes DeviceExtension->BytesPerSector = 512 /* DrvParms->BytesPerSector */; - DeviceExtension->SectorsPerLogCyl = DrvParms->LogicalHeads * + DeviceExtension->SectorsPerLogCyl = DrvParms->LogicalHeads * DrvParms->SectorsPerTrack; DeviceExtension->SectorsPerLogTrk = DrvParms->SectorsPerTrack; DeviceExtension->LogicalHeads = DrvParms->LogicalHeads; DeviceExtension->Offset = Offset; DeviceExtension->Size = Size; - DPRINT("%s: offset %d size %d \n", - DeviceName, + DPRINT("%wZ: offset %d size %d \n", + &DeviceName, DeviceExtension->Offset, DeviceExtension->Size); // Initialize the DPC object here IoInitializeDpcRequest(*DeviceObject, IDEDpcForIsr); - DbgPrint("%s %dMB\n", DeviceName, Size / 2048); + if (PartitionNumber != 0) + { + DbgPrint("%wZ %dMB\n", &DeviceName, Size / 2048); + } + + /* assign arc name */ + if (PartitionNumber == 0) + { + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)rdisk(%d)", + DiskNumber); + } + else + { + swprintf(ArcNameBuffer, + L"\\ArcName\\multi(0)disk(0)rdisk(%d)partition(%d)", + DiskNumber, + PartitionNumber); + } + RtlInitUnicodeString (&ArcName, + ArcNameBuffer); + DPRINT1("%wZ ==> %wZ\n", &ArcName, &DeviceName); + RC = IoAssignArcName (&ArcName, + &DeviceName); + if (!NT_SUCCESS(RC)) + { + DPRINT1("IoAssignArcName (%wZ) failed (Status %x)\n", + &ArcName, RC); + } + return RC; } diff --git a/reactos/drivers/dd/ide/ide.h b/reactos/drivers/dd/ide/ide.h index 1f5d271376f..a96166017a7 100644 --- a/reactos/drivers/dd/ide/ide.h +++ b/reactos/drivers/dd/ide/ide.h @@ -12,11 +12,6 @@ extern "C" { #define IDE_MAXIMUM_DEVICES 8 #define IDE_MAX_NAME_LENGTH 50 -#define IDE_NT_ROOTDIR_NAME "\\Device" -#define IDE_NT_DEVICE_NAME "\\Harddisk" -#define IDE_NT_PARTITION_NAME "\\Partition" -#define IDE_WIN32_DEVICE_NAME "\\DosDevices\\IDE" -#define IDE_DRIVER_NAME "IDEDRIVER" #define IDE_SECTOR_BUF_SZ 512 #define IDE_MAX_SECTORS_PER_XFER 256 @@ -77,34 +72,50 @@ extern "C" { // Access macros for command registers // Each macro takes an address of the command port block, and data // -#define IDEReadError(Address) (inb_p((Address) + IDE_REG_ERROR)) -#define IDEWritePrecomp(Address, Data) (outb_p((Address) + IDE_REG_PRECOMP, (Data))) -#define IDEReadSectorCount(Address) (inb_p((Address) + IDE_REG_SECTOR_CNT)) -#define IDEWriteSectorCount(Address, Data) (outb_p((Address) + IDE_REG_SECTOR_CNT, (Data))) -#define IDEReadSectorNum(Address) (inb_p((Address) + IDE_REG_SECTOR_NUM)) -#define IDEWriteSectorNum(Address, Data) (outb_p((Address) + IDE_REG_SECTOR_NUM, (Data))) -#define IDEReadCylinderLow(Address) (inb_p((Address) + IDE_REG_CYL_LOW)) -#define IDEWriteCylinderLow(Address, Data) (outb_p((Address) + IDE_REG_CYL_LOW, (Data))) -#define IDEReadCylinderHigh(Address) (inb_p((Address) + IDE_REG_CYL_HIGH)) -#define IDEWriteCylinderHigh(Address, Data) (outb_p((Address) + IDE_REG_CYL_HIGH, (Data))) -#define IDEReadDriveHead(Address) (inb_p((Address) + IDE_REG_DRV_HEAD)) -#define IDEWriteDriveHead(Address, Data) (outb_p((Address) + IDE_REG_DRV_HEAD, (Data))) -#define IDEReadStatus(Address) (inb_p((Address) + IDE_REG_STATUS)) -#define IDEWriteCommand(Address, Data) (outb_p((Address) + IDE_REG_COMMAND, (Data))) +#define IDEReadError(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_ERROR))) +#define IDEWritePrecomp(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_PRECOMP), (Data))) +#define IDEReadSectorCount(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT))) +#define IDEWriteSectorCount(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_CNT), (Data))) +#define IDEReadSectorNum(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM))) +#define IDEWriteSectorNum(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_SECTOR_NUM), (Data))) +#define IDEReadCylinderLow(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW))) +#define IDEWriteCylinderLow(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_LOW), (Data))) +#define IDEReadCylinderHigh(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH))) +#define IDEWriteCylinderHigh(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_CYL_HIGH), (Data))) +#define IDEReadDriveHead(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD))) +#define IDEWriteDriveHead(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DRV_HEAD), (Data))) +#define IDEReadStatus(Address) \ + (READ_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_STATUS))) +#define IDEWriteCommand(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_COMMAND), (Data))) + // // Data block read and write commands // #define IDEReadBlock(Address, Buffer, Count) \ - (insw((Address) + IDE_REG_DATA_PORT, (Buffer), (Count) / 2)) + (READ_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2)) #define IDEWriteBlock(Address, Buffer, Count) \ - (outsw((Address) + IDE_REG_DATA_PORT, (Buffer), (Count) / 2)) + (WRITE_PORT_BUFFER_USHORT((PUSHORT)((Address) + IDE_REG_DATA_PORT), (PUSHORT)(Buffer), (Count) / 2)) // // Access macros for control registers // Each macro takes an address of the control port blank and data // -#define IDEWriteDriveControl(Address, Data) (outb_p((Address) + IDE_REG_DEV_CNTRL, (Data))) +#define IDEWriteDriveControl(Address, Data) \ + (WRITE_PORT_UCHAR((PUCHAR)((Address) + IDE_REG_DEV_CNTRL), (Data))) // IDE_DEVICE_EXTENSION // diff --git a/reactos/include/ddk/iofuncs.h b/reactos/include/ddk/iofuncs.h index 0962f677532..267abf6e4f7 100644 --- a/reactos/include/ddk/iofuncs.h +++ b/reactos/include/ddk/iofuncs.h @@ -1,6 +1,6 @@ #ifndef _INCLUDE_DDK_IOFUNCS_H #define _INCLUDE_DDK_IOFUNCS_H -/* $Id: iofuncs.h,v 1.19 2000/07/30 18:22:32 dwelch Exp $ */ +/* $Id: iofuncs.h,v 1.20 2000/08/24 19:06:29 ekohl Exp $ */ /* --- EXPORTED BY NTOSKRNL --- */ @@ -213,8 +213,8 @@ IoAllocateMdl ( * PUNICODE_STRING DeviceName * ); */ -#define IoAssignArcName (ArcName, DeviceName) \ - (IoCreateSymbolicLink ((ArcName), (DeviceName))) +#define IoAssignArcName(ArcName,DeviceName) \ + (IoCreateSymbolicLink((ArcName),(DeviceName))) /********************************************************************** * NAME EXPORTED @@ -695,7 +695,7 @@ IoGetTopLevelIrp ( VOID ); -#define IoInitializeDpcRequest(DeviceObject, DpcRoutine) \ +#define IoInitializeDpcRequest(DeviceObject,DpcRoutine) \ (KeInitializeDpc(&(DeviceObject)->Dpc, \ (PKDEFERRED_ROUTINE)(DpcRoutine), \ (DeviceObject))) @@ -894,10 +894,10 @@ IoReportResourceUsage ( PBOOLEAN ConflictDetected ); -#define IoRequestDpc(DeviceObject, Irp, Context) \ +#define IoRequestDpc(DeviceObject,Irp,Context) \ (KeInsertQueueDpc(&(DeviceObject)->Dpc,(Irp),(Context))) -#define IoSetCancelRoutine(Irp, NewCancelRoutine) \ +#define IoSetCancelRoutine(Irp,NewCancelRoutine) \ ((PDRIVER_CANCEL)InterlockedExchange((PULONG)&(Irp)->CancelRoutine, \ (ULONG)(NewCancelRoutine))); diff --git a/reactos/include/ddk/obtypes.h b/reactos/include/ddk/obtypes.h index 47c171ce3f2..30b4a6ad0a2 100644 --- a/reactos/include/ddk/obtypes.h +++ b/reactos/include/ddk/obtypes.h @@ -1,6 +1,6 @@ #ifndef _INCLUDE_DDK_OBTYPES_H #define _INCLUDE_DDK_OBTYPES_H -/* $Id: obtypes.h,v 1.8 2000/06/15 18:37:33 ekohl Exp $ */ +/* $Id: obtypes.h,v 1.9 2000/08/24 19:06:29 ekohl Exp $ */ struct _DIRECTORY_OBJECT; struct _OBJECT_ATTRIBUTES; @@ -90,7 +90,8 @@ typedef struct _OBJECT_TYPE NTSTATUS (*Parse)(PVOID ParsedObject, PVOID *NextObject, PUNICODE_STRING FullPath, - PWSTR *Path); + PWSTR *Path, + struct _OBJECT_TYPE* ObjectType); /* */ diff --git a/reactos/ntoskrnl/include/internal/io.h b/reactos/ntoskrnl/include/internal/io.h index f58efb6511c..5a16820a8f8 100644 --- a/reactos/ntoskrnl/include/internal/io.h +++ b/reactos/ntoskrnl/include/internal/io.h @@ -1,4 +1,4 @@ -/* $Id: io.h,v 1.3 2000/07/07 10:30:55 dwelch Exp $ +/* $Id: io.h,v 1.4 2000/08/24 19:07:49 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -15,7 +15,7 @@ #include #include -extern POBJECT_TYPE IoSymbolicLinkObjectType; +extern POBJECT_TYPE IoSymbolicLinkType; /* * FUNCTION: Called to initalize a loaded driver diff --git a/reactos/ntoskrnl/include/internal/ob.h b/reactos/ntoskrnl/include/internal/ob.h index 6c976abacc7..6f068540aaf 100644 --- a/reactos/ntoskrnl/include/internal/ob.h +++ b/reactos/ntoskrnl/include/internal/ob.h @@ -106,9 +106,8 @@ VOID ObCreateHandleTable(struct _EPROCESS* Parent, struct _EPROCESS* Process); NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes, PVOID* ReturnedObject, - PUNICODE_STRING RemainingPath); -// PWSTR* RemainingPath); - + PUNICODE_STRING RemainingPath, + POBJECT_TYPE ObjectType); ULONG ObGetReferenceCount(PVOID Object); ULONG ObGetHandleCount(PVOID Object); VOID ObCloseAllHandles(struct _EPROCESS* Process); diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index 2279cc954d4..8cc318190c3 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -1,4 +1,4 @@ -/* $Id: iomgr.c,v 1.13 2000/07/07 02:10:18 ekohl Exp $ +/* $Id: iomgr.c,v 1.14 2000/08/24 19:09:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -109,7 +109,6 @@ VOID IoInit (VOID) OBJECT_ATTRIBUTES attr; HANDLE handle; UNICODE_STRING UnicodeString; - ANSI_STRING AnsiString; UNICODE_STRING DeviceName; /* @@ -136,15 +135,11 @@ VOID IoInit (VOID) IoDeviceObjectType->OkayToClose = NULL; IoDeviceObjectType->Create = IopCreateDevice; - RtlInitAnsiString ( - & AnsiString, - "Device" - ); - RtlAnsiStringToUnicodeString ( + RtlInitUnicodeString ( & IoDeviceObjectType->TypeName, - & AnsiString, - TRUE + L"Device" ); + /* * Register iomgr types: FileObjectType * (alias DriverObjectType) @@ -170,27 +165,17 @@ VOID IoInit (VOID) IoFileObjectType->OkayToClose = NULL; IoFileObjectType->Create = IopCreateFile; - RtlInitAnsiString ( - & AnsiString, - "File" - ); - RtlAnsiStringToUnicodeString ( + RtlInitUnicodeString ( & IoFileObjectType->TypeName, - & AnsiString, - TRUE + L"File" ); /* - * Create the device directory + * Create the '\Device' directory */ - RtlInitAnsiString ( - & AnsiString, - "\\Device" - ); - RtlAnsiStringToUnicodeString ( + RtlInitUnicodeString ( & UnicodeString, - & AnsiString, - TRUE + L"\\Device" ); InitializeObjectAttributes ( & attr, @@ -206,16 +191,11 @@ VOID IoInit (VOID) ); /* - * Create the \?? directory + * Create the '\??' directory */ - RtlInitAnsiString ( - & AnsiString, - "\\??" - ); - RtlAnsiStringToUnicodeString ( + RtlInitUnicodeString ( & UnicodeString, - & AnsiString, - TRUE + L"\\??" ); InitializeObjectAttributes ( & attr, @@ -229,6 +209,26 @@ VOID IoInit (VOID) 0, & attr ); + + /* + * Create the '\ArcName' directory + */ + RtlInitUnicodeString ( + & UnicodeString, + L"\\ArcName"); + InitializeObjectAttributes ( + & attr, + & UnicodeString, + 0, + NULL, + NULL + ); + ZwCreateDirectoryObject ( + & handle, + 0, + & attr + ); + /* * Initialize remaining subsubsystem */ @@ -238,7 +238,7 @@ VOID IoInit (VOID) IoInitVpbImplementation (); /* - * Create link from \DosDevices to \?? directory + * Create link from '\DosDevices' to '\??' directory */ RtlInitUnicodeString (&UnicodeString, L"\\DosDevices"); diff --git a/reactos/ntoskrnl/io/symlink.c b/reactos/ntoskrnl/io/symlink.c index 55bf65b0454..443809d7502 100644 --- a/reactos/ntoskrnl/io/symlink.c +++ b/reactos/ntoskrnl/io/symlink.c @@ -1,4 +1,4 @@ -/* $Id: symlink.c,v 1.15 2000/06/29 23:35:38 dwelch Exp $ +/* $Id: symlink.c,v 1.16 2000/08/24 19:09:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -86,7 +86,8 @@ IopParseSymbolicLink ( PVOID Object, PVOID * NextObject, PUNICODE_STRING FullPath, - PWSTR * RemainingPath + PWSTR * RemainingPath, + POBJECT_TYPE ObjectType ) { NTSTATUS Status; @@ -94,6 +95,19 @@ IopParseSymbolicLink ( PVOID ReturnedObject; UNICODE_STRING TargetPath; + DPRINT("IopParseSymbolicLink (RemainingPath %S)\n", *RemainingPath); + /* + * Stop parsing if the entire path has been parsed and + * the desired object is a symbolic link object. + */ + if (((*RemainingPath == NULL) || (**RemainingPath == 0)) && + (ObjectType == IoSymbolicLinkType)) + { + DPRINT("Parsing stopped!\n"); + *NextObject = NULL; + return STATUS_SUCCESS; + } + Status = ObReferenceObjectByName( SymlinkObject->Target.ObjectName, 0, @@ -197,12 +211,15 @@ NtOpenSymbolicLinkObject ( NTSTATUS Status; PVOID Object; + DPRINT("NtOpenSymbolicLinkObject (Name %wZ)\n", + ObjectAttributes->ObjectName); + Status = ObReferenceObjectByName( ObjectAttributes->ObjectName, ObjectAttributes->Attributes, NULL, DesiredAccess, - NULL, + IoSymbolicLinkType, UserMode, NULL, & Object @@ -354,7 +371,6 @@ IoCreateSymbolicLink ( { return STATUS_UNSUCCESSFUL; } - SymbolicLink->TargetName.Length = 0; SymbolicLink->TargetName.MaximumLength = ((wcslen(DeviceName->Buffer) + 1) * sizeof(WCHAR)); diff --git a/reactos/ntoskrnl/io/xhaldrv.c b/reactos/ntoskrnl/io/xhaldrv.c index 491b742c9f5..350f11e5347 100644 --- a/reactos/ntoskrnl/io/xhaldrv.c +++ b/reactos/ntoskrnl/io/xhaldrv.c @@ -1,4 +1,4 @@ -/* $Id: xhaldrv.c,v 1.5 2000/08/22 21:10:28 ekohl Exp $ +/* $Id: xhaldrv.c,v 1.6 2000/08/24 19:09:12 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -34,18 +34,6 @@ #define PARTITION_OFFSET 0x01be #define PARTITION_TBL_SIZE 4 -/* -#define PTCHSToLBA(c, h, s, scnt, hcnt) ((s) & 0x3f) + \ - (scnt) * ( (h) + (hcnt) * ((c) | (((s) & 0xc0) << 2))) -#define PTLBAToCHS(lba, c, h, s, scnt, hcnt) ( \ - (s) = (lba) % (scnt) + 1, \ - (lba) /= (scnt), \ - (h) = (lba) % (hcnt), \ - (lba) /= (heads), \ - (c) = (lba) & 0xff, \ - (s) |= ((lba) >> 2) & 0xc0) -*/ - #define IsUsablePartition(P) \ ((P) != PTEmpty && \ (P) != PTDosExtended && \ @@ -286,9 +274,9 @@ HalpAssignDrive ( RtlInitUnicodeString (&DriveName, DriveNameBuffer); - DPRINT1(" %wZ ==> %wZ\n", - &DriveName, - PartitionName); + DPRINT(" %wZ ==> %wZ\n", + &DriveName, + PartitionName); /* create symbolic link */ IoCreateSymbolicLink (&DriveName, @@ -360,9 +348,9 @@ xHalIoAssignDriveLetters ( RtlInitUnicodeString (&UnicodeString2, Buffer2); - DPRINT1("Creating link: %S ==> %S\n", - Buffer2, - Buffer1); + DPRINT("Creating link: %S ==> %S\n", + Buffer2, + Buffer1); IoCreateSymbolicLink (&UnicodeString2, &UnicodeString1); @@ -385,8 +373,8 @@ xHalIoAssignDriveLetters ( &LayoutInfo); if (!NT_SUCCESS(Status)) { - DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", - Status); + DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", + Status); continue; } @@ -439,8 +427,8 @@ xHalIoAssignDriveLetters ( &LayoutInfo); if (!NT_SUCCESS(Status)) { - DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", - Status); + DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", + Status); continue; } @@ -491,8 +479,8 @@ xHalIoAssignDriveLetters ( &LayoutInfo); if (!NT_SUCCESS(Status)) { - DPRINT1("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", - Status); + DbgPrint("xHalpQueryDriveLayout() failed (Status = 0x%lx)\n", + Status); continue; } diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index 45595aafe50..ae56b7058c4 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.57 2000/08/15 12:44:47 ekohl Exp $ +/* $Id: main.c,v 1.58 2000/08/24 19:10:27 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -40,21 +41,140 @@ LOADER_PARAMETER_BLOCK EXPORTED KeLoaderBlock; /* FUNCTIONS ****************************************************************/ -static VOID CreateSystemRootLink (LPWSTR Device) +static VOID +CreateSystemRootLink (PCSZ ParameterLine) { UNICODE_STRING LinkName; UNICODE_STRING DeviceName; + UNICODE_STRING ArcName; + UNICODE_STRING BootPath; + PCHAR ParamBuffer; + PWCHAR ArcNameBuffer; + PCHAR p; + NTSTATUS Status; + ULONG Length; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Handle; + /* create local parameter line copy */ + ParamBuffer = ExAllocatePool (PagedPool, 256); + strcpy (ParamBuffer, (char *)ParameterLine); + + DPRINT("%s\n", ParamBuffer); + /* Format: \ [options...] */ + + /* 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 device name string */ + DeviceName.Length = 0; + DeviceName.MaximumLength = 256 * sizeof(WCHAR); + DeviceName.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 (&DeviceName); + DbgPrint("NtOpenSymbolicLinkObject() failed (Status %x)\n", + Status); + + KeBugCheck (0x0); + } + + Status = NtQuerySymbolicLinkObject (Handle, + &DeviceName, + &Length); + NtClose (Handle); + if (!NT_SUCCESS(Status)) + { + RtlFreeUnicodeString (&BootPath); + RtlFreeUnicodeString (&DeviceName); + DbgPrint("NtQuerySymbolicObject() failed (Status %x)\n", + Status); + + KeBugCheck (0x0); + } + DPRINT("Length: %lu DeviceName: %wZ\n", Length, &DeviceName); + + RtlAppendUnicodeStringToString (&DeviceName, + &BootPath); + + RtlFreeUnicodeString (&BootPath); + DPRINT("DeviceName: %wZ\n", &DeviceName); + + /* create the '\SystemRoot' link */ RtlInitUnicodeString (&LinkName, L"\\SystemRoot"); - RtlInitUnicodeString (&DeviceName, - Device); + Status = IoCreateSymbolicLink (&LinkName, + &DeviceName); + RtlFreeUnicodeString (&DeviceName); + if (!NT_SUCCESS(Status)) + { + DbgPrint("IoCreateSymbolicLink() failed (Status %x)\n", + Status); - IoCreateSymbolicLink (&LinkName, - &DeviceName); + KeBugCheck (0x0); + } + + /* + * FIXME: test if '\SystemRoot' (LinkName)can be opened, + * otherwise crash it! + */ } +static VOID +InitSystemSharedUserPage (VOID) +{ + PKUSER_SHARED_DATA SharedPage; + + SharedPage = (PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE; + + /* set system root in shared user page */ + wcscpy (SharedPage->NtSystemRoot, L"C:\\reactos"); + + SharedPage->NtProductType = NtProductWinNt; +} + + void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) /* * FUNCTION: Called by the boot loader to start the kernel @@ -78,7 +198,8 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) * Initializes the kernel parameter line. * This should be done by the boot loader. */ - strcpy (KeLoaderBlock.kernel_parameters, "/DEBUGPORT=SCREEN"); + strcpy (KeLoaderBlock.kernel_parameters, + "multi(0)disk(0)rdisk(0)partition(1)\\reactos /DEBUGPORT=SCREEN"); /* * Initialization phase 0 @@ -145,34 +266,33 @@ void _main (PLOADER_PARAMETER_BLOCK LoaderBlock) */ DPRINT1("%d files loaded\n",KeLoaderBlock.nr_files); - /* Pass 1: load registry chunks passed in */ - start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]); - for (i = 1; i < KeLoaderBlock.nr_files; i++) - { - if (!strcmp ((PCHAR) start, "REGEDIT4")) - { - DPRINT1("process registry chunk at %08lx\n", start); - CmImportHive((PCHAR) start); - } - start = start + KeLoaderBlock.module_length[i]; - } + /* Pass 1: load registry chunks passed in */ + start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]); + for (i = 1; i < KeLoaderBlock.nr_files; i++) + { + if (!strcmp ((PCHAR) start, "REGEDIT4")) + { + DPRINT1("process registry chunk at %08lx\n", start); + CmImportHive((PCHAR) start); + } + start = start + KeLoaderBlock.module_length[i]; + } - /* Pass 2: process boot loaded drivers */ - start = KERNEL_BASE + PAGE_ROUND_UP(KeLoaderBlock.module_length[0]); - start1 = start + KeLoaderBlock.module_length[1]; - for (i=1;iNtSystemRoot, - L"C:\\reactos"); - - ((PKUSER_SHARED_DATA)KERNEL_SHARED_DATA_BASE)->NtProductType = NtProductWinNt; - + /* initialize shared user page */ + InitSystemSharedUserPage (); /* * Launch initial process diff --git a/reactos/ntoskrnl/ldr/loader.c b/reactos/ntoskrnl/ldr/loader.c index 719edf0f5bf..8fae167e72c 100644 --- a/reactos/ntoskrnl/ldr/loader.c +++ b/reactos/ntoskrnl/ldr/loader.c @@ -1,4 +1,4 @@ -/* $Id: loader.c,v 1.60 2000/08/12 19:33:21 dwelch Exp $ +/* $Id: loader.c,v 1.61 2000/08/24 19:11:06 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -421,7 +421,8 @@ LdrOpenModule(PUNICODE_STRING Filename) Status = ObFindObject(&ObjectAttributes, (PVOID *) &ModuleObject, - &RemainingPath); + &RemainingPath, + NULL); CHECKPOINT; if (NT_SUCCESS(Status) && (RemainingPath.Buffer == NULL || *(RemainingPath.Buffer) == 0)) { diff --git a/reactos/ntoskrnl/ob/namespc.c b/reactos/ntoskrnl/ob/namespc.c index e2ca04fdb21..4e29b4d7359 100644 --- a/reactos/ntoskrnl/ob/namespc.c +++ b/reactos/ntoskrnl/ob/namespc.c @@ -37,20 +37,25 @@ NTSTATUS STDCALL ObReferenceObjectByName(PUNICODE_STRING ObjectPath, PVOID ParseContext, PVOID* ObjectPtr) { - PVOID Object; + PVOID Object = NULL; UNICODE_STRING RemainingPath; -// PWSTR RemainingPath; OBJECT_ATTRIBUTES ObjectAttributes; - + NTSTATUS Status; + InitializeObjectAttributes(&ObjectAttributes, ObjectPath, 0, NULL, NULL); - ObFindObject(&ObjectAttributes, - &Object, - &RemainingPath); - + Status = ObFindObject(&ObjectAttributes, + &Object, + &RemainingPath, + ObjectType); + if (!NT_SUCCESS(Status)) + { + return(STATUS_UNSUCCESSFUL); + } + if (RemainingPath.Buffer != NULL || Object == NULL) { @@ -138,7 +143,8 @@ ObpParseDirectory ( PVOID Object, PVOID * NextObject, PUNICODE_STRING FullPath, - PWSTR * Path + PWSTR * Path, + POBJECT_TYPE ObjectType ) { PWSTR end; diff --git a/reactos/ntoskrnl/ob/object.c b/reactos/ntoskrnl/ob/object.c index 56f93988e1b..7dd9aa4ce71 100644 --- a/reactos/ntoskrnl/ob/object.c +++ b/reactos/ntoskrnl/ob/object.c @@ -1,4 +1,4 @@ -/* $Id: object.c,v 1.25 2000/07/30 18:22:35 dwelch Exp $ +/* $Id: object.c,v 1.26 2000/08/24 19:12:16 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -66,7 +66,7 @@ VOID ObInitializeObject(POBJECT_HEADER ObjectHeader, /********************************************************************** * NAME PRIVATE - * ObFindObject@12 + * ObFindObject@16 * * DESCRIPTION * @@ -81,11 +81,16 @@ VOID ObInitializeObject(POBJECT_HEADER ObjectHeader, * The caller must free the buffer after use by calling * RtlFreeUnicodeString (). * + * ObjectType + * Optional pointer to an object type. This is used to + * descide if a symbolic link object will be parsed or not. + * * RETURN VALUE */ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes, PVOID* ReturnedObject, - PUNICODE_STRING RemainingPath) + PUNICODE_STRING RemainingPath, + POBJECT_TYPE ObjectType) { PVOID NextObject; PVOID CurrentObject; @@ -163,7 +168,8 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes, Status = CurrentHeader->ObjectType->Parse(CurrentObject, &NextObject, &PathString, - ¤t); + ¤t, + ObjectType); if (Status == STATUS_REPARSE) { /* reparse the object path */ @@ -228,7 +234,8 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle, { ObFindObject(ObjectAttributes, &Parent, - &RemainingPath); + &RemainingPath, + NULL); } else {