diff --git a/reactos/ntoskrnl/io/device.c b/reactos/ntoskrnl/io/device.c index 7717220379f..0eb791948bf 100644 --- a/reactos/ntoskrnl/io/device.c +++ b/reactos/ntoskrnl/io/device.c @@ -113,22 +113,6 @@ IopInitializeDevice( return STATUS_SUCCESS; } -NTSTATUS STDCALL -IopCreateDevice( - PVOID ObjectBody, - PVOID Parent, - PWSTR RemainingPath, - POBJECT_ATTRIBUTES ObjectAttributes) -{ - DPRINT("IopCreateDevice(ObjectBody %x, Parent %x, RemainingPath %S)\n", - ObjectBody, Parent, RemainingPath); - - if (RemainingPath != NULL && wcschr(RemainingPath + 1, '\\') != NULL) - return STATUS_OBJECT_PATH_NOT_FOUND; - - return STATUS_SUCCESS; -} - NTSTATUS STDCALL IopGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, @@ -237,6 +221,31 @@ IoAttachDevice(PDEVICE_OBJECT SourceDevice, return STATUS_SUCCESS; } +/* + * IoAttachDeviceByPointer + * + * Status + * @implemented + */ +NTSTATUS +STDCALL +IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, + IN PDEVICE_OBJECT TargetDevice) +{ + PDEVICE_OBJECT AttachedDevice; + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("IoAttachDeviceByPointer(SourceDevice %x, TargetDevice %x)\n", + SourceDevice, TargetDevice); + + /* Do the Attach */ + AttachedDevice = IoAttachDeviceToDeviceStack(SourceDevice, TargetDevice); + if (AttachedDevice == NULL) Status = STATUS_NO_SUCH_DEVICE; + + /* Return the status */ + return Status; +} + /* * IoAttachDeviceToDeviceStack * @@ -261,31 +270,6 @@ IoAttachDeviceToDeviceStack(PDEVICE_OBJECT SourceDevice, DPRINT("IoAttachDeviceToDeviceStack DONE: %x\n", LocalAttach); return LocalAttach; } -/* - * IoAttachDeviceByPointer - * - * Status - * @implemented - */ - -NTSTATUS -STDCALL -IoAttachDeviceByPointer(IN PDEVICE_OBJECT SourceDevice, - IN PDEVICE_OBJECT TargetDevice) -{ - PDEVICE_OBJECT AttachedDevice; - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("IoAttachDeviceByPointer(SourceDevice %x, TargetDevice %x)\n", - SourceDevice, TargetDevice); - - /* Do the Attach */ - AttachedDevice = IoAttachDeviceToDeviceStack(SourceDevice, TargetDevice); - if (AttachedDevice == NULL) Status = STATUS_NO_SUCH_DEVICE; - - /* Return the status */ - return Status; -} /* * @implemented @@ -333,288 +317,6 @@ IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice, return STATUS_SUCCESS; } -/* - * IoDeleteDevice - * - * Status - * @implemented - */ -VOID STDCALL -IoDeleteDevice(PDEVICE_OBJECT DeviceObject) -{ - PDEVICE_OBJECT Previous; - - if (DeviceObject->Flags & DO_SHUTDOWN_REGISTERED) - IoUnregisterShutdownNotification(DeviceObject); - - /* Remove the timer if it exists */ - if (DeviceObject->Timer) - { - IopRemoveTimerFromTimerList(DeviceObject->Timer); - ExFreePool(DeviceObject->Timer); - } - - /* Remove device from driver device list */ - Previous = DeviceObject->DriverObject->DeviceObject; - if (Previous == DeviceObject) - { - DeviceObject->DriverObject->DeviceObject = DeviceObject->NextDevice; - } - else - { - while (Previous->NextDevice != DeviceObject) - Previous = Previous->NextDevice; - Previous->NextDevice = DeviceObject->NextDevice; - } - - /* I guess this should be removed later... but it shouldn't cause problems */ - DeviceObject->DeviceObjectExtension->ExtensionFlags |= DOE_DELETE_PENDING; - ObDereferenceObject(DeviceObject); -} - -/* - * @implemented - */ -NTSTATUS -STDCALL -IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, - IN PDEVICE_OBJECT *DeviceObjectList, - IN ULONG DeviceObjectListSize, - OUT PULONG ActualNumberDeviceObjects) -{ - ULONG ActualDevices = 1; - PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject; - - DPRINT1("IoEnumerateDeviceObjectList\n"); - - /* Find out how many devices we'll enumerate */ - while ((CurrentDevice = CurrentDevice->NextDevice)) - { - ActualDevices++; - } - - /* Go back to the first */ - CurrentDevice = DriverObject->DeviceObject; - - /* Start by at least returning this */ - *ActualNumberDeviceObjects = ActualDevices; - - /* Check if we can support so many */ - if ((ActualDevices * 4) > DeviceObjectListSize) - { - /* Fail because the buffer was too small */ - return STATUS_BUFFER_TOO_SMALL; - } - - /* Check if the caller only wanted the size */ - if (DeviceObjectList) - { - /* Loop through all the devices */ - while (ActualDevices) - { - /* Reference each Device */ - ObReferenceObject(CurrentDevice); - - /* Add it to the list */ - *DeviceObjectList = CurrentDevice; - - /* Go to the next one */ - CurrentDevice = CurrentDevice->NextDevice; - ActualDevices--; - DeviceObjectList++; - } - } - - /* Return the status */ - return STATUS_SUCCESS; -} - -/* - * @implemented - */ -PDEVICE_OBJECT -STDCALL -IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject) -{ - /* Return the attached Device */ - return (DeviceObject->DeviceObjectExtension->AttachedTo); -} - -/* - * @implemented - */ -NTSTATUS -STDCALL -IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, - OUT PDEVICE_OBJECT *DiskDeviceObject) -{ - PDEVOBJ_EXTENSION DeviceExtension; - PVPB Vpb; - KIRQL OldIrql; - - /* Make sure there's a VPB */ - if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER; - - /* Acquire it */ - IoAcquireVpbSpinLock(&OldIrql); - - /* Get the Device Extension */ - DeviceExtension = FileSystemDeviceObject->DeviceObjectExtension; - - /* Make sure this one has a VPB too */ - Vpb = DeviceExtension->Vpb; - if (!Vpb) return STATUS_INVALID_PARAMETER; - - /* Make sure someone it's mounted */ - if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED)) return STATUS_VOLUME_DISMOUNTED; - - /* Return the Disk Device Object */ - *DiskDeviceObject = Vpb->RealDevice; - - /* Release the lock */ - IoReleaseVpbSpinLock(OldIrql); - return STATUS_SUCCESS; -} - -/* - * @implemented - */ -PDEVICE_OBJECT -STDCALL -IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject) -{ - PDEVOBJ_EXTENSION DeviceExtension = DeviceObject->DeviceObjectExtension; - PDEVICE_OBJECT LowerDeviceObject = NULL; - - /* Make sure it's not getting deleted */ - if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING | - DOE_DELETE_PENDING | - DOE_REMOVE_PENDING | - DOE_REMOVE_PROCESSED)) - { - /* Get the Lower Device Object */ - LowerDeviceObject = DeviceExtension->AttachedTo; - - /* Reference it */ - ObReferenceObject(LowerDeviceObject); - } - - /* Return it */ - return LowerDeviceObject; -} - -/* - * IoGetRelatedDeviceObject - * - * Remarks - * See "Windows NT File System Internals", page 633 - 634. - * - * Status - * @implemented - */ -PDEVICE_OBJECT -STDCALL -IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject) -{ - PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject; - - /* Get logical volume mounted on a physical/virtual/logical device */ - if (FileObject->Vpb && FileObject->Vpb->DeviceObject) - { - DeviceObject = FileObject->Vpb->DeviceObject; - } - - /* - * Check if file object has an associated device object mounted by some - * other file system. - */ - if (FileObject->DeviceObject->Vpb && - FileObject->DeviceObject->Vpb->DeviceObject) - { - DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject; - } - - /* Return the highest attached device */ - return IoGetAttachedDevice(DeviceObject); -} - -/* - * IoGetDeviceObjectPointer - * - * Status - * @implemented - */ -NTSTATUS -STDCALL -IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, - IN ACCESS_MASK DesiredAccess, - OUT PFILE_OBJECT *FileObject, - OUT PDEVICE_OBJECT *DeviceObject) -{ - /* Call the helper routine for a normal operation */ - return IopGetDeviceObjectPointer(ObjectName, - DesiredAccess, - FileObject, - DeviceObject, - 0); -} - -/* - * IoDetachDevice - * - * Status - * @implemented - */ -VOID -STDCALL -IoDetachDevice(PDEVICE_OBJECT TargetDevice) -{ - DPRINT("IoDetachDevice(TargetDevice %x)\n", TargetDevice); - - /* Remove the attachment */ - TargetDevice->AttachedDevice->DeviceObjectExtension->AttachedTo = NULL; - TargetDevice->AttachedDevice = NULL; -} - -/* - * IoGetAttachedDevice - * - * Status - * @implemented - */ -PDEVICE_OBJECT -STDCALL -IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject) -{ - PDEVICE_OBJECT Current = DeviceObject; - - /* Get the last attached device */ - while (Current->AttachedDevice) - { - Current = Current->AttachedDevice; - } - - /* Return it */ - return Current; -} - -/* - * IoGetAttachedDeviceReference - * - * Status - * @implemented - */ -PDEVICE_OBJECT -STDCALL -IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject) -{ - PDEVICE_OBJECT Current = IoGetAttachedDevice(DeviceObject); - - /* Reference the ATtached Device */ - ObReferenceObject(Current); - return Current; -} - /* * IoCreateDevice * @@ -812,6 +514,289 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject, return STATUS_SUCCESS; } +/* + * IoDeleteDevice + * + * Status + * @implemented + */ +VOID +STDCALL +IoDeleteDevice(PDEVICE_OBJECT DeviceObject) +{ + PDEVICE_OBJECT Previous; + + if (DeviceObject->Flags & DO_SHUTDOWN_REGISTERED) + IoUnregisterShutdownNotification(DeviceObject); + + /* Remove the timer if it exists */ + if (DeviceObject->Timer) + { + IopRemoveTimerFromTimerList(DeviceObject->Timer); + ExFreePool(DeviceObject->Timer); + } + + /* Remove device from driver device list */ + Previous = DeviceObject->DriverObject->DeviceObject; + if (Previous == DeviceObject) + { + DeviceObject->DriverObject->DeviceObject = DeviceObject->NextDevice; + } + else + { + while (Previous->NextDevice != DeviceObject) + Previous = Previous->NextDevice; + Previous->NextDevice = DeviceObject->NextDevice; + } + + /* I guess this should be removed later... but it shouldn't cause problems */ + DeviceObject->DeviceObjectExtension->ExtensionFlags |= DOE_DELETE_PENDING; + ObDereferenceObject(DeviceObject); +} + +/* + * IoDetachDevice + * + * Status + * @implemented + */ +VOID +STDCALL +IoDetachDevice(PDEVICE_OBJECT TargetDevice) +{ + DPRINT("IoDetachDevice(TargetDevice %x)\n", TargetDevice); + + /* Remove the attachment */ + TargetDevice->AttachedDevice->DeviceObjectExtension->AttachedTo = NULL; + TargetDevice->AttachedDevice = NULL; +} + +/* + * @implemented + */ +NTSTATUS +STDCALL +IoEnumerateDeviceObjectList(IN PDRIVER_OBJECT DriverObject, + IN PDEVICE_OBJECT *DeviceObjectList, + IN ULONG DeviceObjectListSize, + OUT PULONG ActualNumberDeviceObjects) +{ + ULONG ActualDevices = 1; + PDEVICE_OBJECT CurrentDevice = DriverObject->DeviceObject; + + DPRINT1("IoEnumerateDeviceObjectList\n"); + + /* Find out how many devices we'll enumerate */ + while ((CurrentDevice = CurrentDevice->NextDevice)) + { + ActualDevices++; + } + + /* Go back to the first */ + CurrentDevice = DriverObject->DeviceObject; + + /* Start by at least returning this */ + *ActualNumberDeviceObjects = ActualDevices; + + /* Check if we can support so many */ + if ((ActualDevices * 4) > DeviceObjectListSize) + { + /* Fail because the buffer was too small */ + return STATUS_BUFFER_TOO_SMALL; + } + + /* Check if the caller only wanted the size */ + if (DeviceObjectList) + { + /* Loop through all the devices */ + while (ActualDevices) + { + /* Reference each Device */ + ObReferenceObject(CurrentDevice); + + /* Add it to the list */ + *DeviceObjectList = CurrentDevice; + + /* Go to the next one */ + CurrentDevice = CurrentDevice->NextDevice; + ActualDevices--; + DeviceObjectList++; + } + } + + /* Return the status */ + return STATUS_SUCCESS; +} + +/* + * IoGetAttachedDevice + * + * Status + * @implemented + */ +PDEVICE_OBJECT +STDCALL +IoGetAttachedDevice(PDEVICE_OBJECT DeviceObject) +{ + PDEVICE_OBJECT Current = DeviceObject; + + /* Get the last attached device */ + while (Current->AttachedDevice) + { + Current = Current->AttachedDevice; + } + + /* Return it */ + return Current; +} + +/* + * IoGetAttachedDeviceReference + * + * Status + * @implemented + */ +PDEVICE_OBJECT +STDCALL +IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject) +{ + PDEVICE_OBJECT Current = IoGetAttachedDevice(DeviceObject); + + /* Reference the ATtached Device */ + ObReferenceObject(Current); + return Current; +} + +/* + * @implemented + */ +PDEVICE_OBJECT +STDCALL +IoGetDeviceAttachmentBaseRef(IN PDEVICE_OBJECT DeviceObject) +{ + /* Return the attached Device */ + return (DeviceObject->DeviceObjectExtension->AttachedTo); +} + +/* + * IoGetDeviceObjectPointer + * + * Status + * @implemented + */ +NTSTATUS +STDCALL +IoGetDeviceObjectPointer(IN PUNICODE_STRING ObjectName, + IN ACCESS_MASK DesiredAccess, + OUT PFILE_OBJECT *FileObject, + OUT PDEVICE_OBJECT *DeviceObject) +{ + /* Call the helper routine for a normal operation */ + return IopGetDeviceObjectPointer(ObjectName, + DesiredAccess, + FileObject, + DeviceObject, + 0); +} + +/* + * @implemented + */ +NTSTATUS +STDCALL +IoGetDiskDeviceObject(IN PDEVICE_OBJECT FileSystemDeviceObject, + OUT PDEVICE_OBJECT *DiskDeviceObject) +{ + PDEVOBJ_EXTENSION DeviceExtension; + PVPB Vpb; + KIRQL OldIrql; + + /* Make sure there's a VPB */ + if (!FileSystemDeviceObject->Vpb) return STATUS_INVALID_PARAMETER; + + /* Acquire it */ + IoAcquireVpbSpinLock(&OldIrql); + + /* Get the Device Extension */ + DeviceExtension = FileSystemDeviceObject->DeviceObjectExtension; + + /* Make sure this one has a VPB too */ + Vpb = DeviceExtension->Vpb; + if (!Vpb) return STATUS_INVALID_PARAMETER; + + /* Make sure someone it's mounted */ + if ((!Vpb->ReferenceCount) || (Vpb->Flags & VPB_MOUNTED)) return STATUS_VOLUME_DISMOUNTED; + + /* Return the Disk Device Object */ + *DiskDeviceObject = Vpb->RealDevice; + + /* Release the lock */ + IoReleaseVpbSpinLock(OldIrql); + return STATUS_SUCCESS; +} + +/* + * @implemented + */ +PDEVICE_OBJECT +STDCALL +IoGetLowerDeviceObject(IN PDEVICE_OBJECT DeviceObject) +{ + PDEVOBJ_EXTENSION DeviceExtension = DeviceObject->DeviceObjectExtension; + PDEVICE_OBJECT LowerDeviceObject = NULL; + + /* Make sure it's not getting deleted */ + if (DeviceExtension->ExtensionFlags & (DOE_UNLOAD_PENDING | + DOE_DELETE_PENDING | + DOE_REMOVE_PENDING | + DOE_REMOVE_PROCESSED)) + { + /* Get the Lower Device Object */ + LowerDeviceObject = DeviceExtension->AttachedTo; + + /* Reference it */ + ObReferenceObject(LowerDeviceObject); + } + + /* Return it */ + return LowerDeviceObject; +} + +/* + * IoGetRelatedDeviceObject + * + * Remarks + * See "Windows NT File System Internals", page 633 - 634. + * + * Status + * @implemented + */ +PDEVICE_OBJECT +STDCALL +IoGetRelatedDeviceObject(IN PFILE_OBJECT FileObject) +{ + PDEVICE_OBJECT DeviceObject = FileObject->DeviceObject; + + /* Get logical volume mounted on a physical/virtual/logical device */ + if (FileObject->Vpb && FileObject->Vpb->DeviceObject) + { + DeviceObject = FileObject->Vpb->DeviceObject; + } + + /* + * Check if file object has an associated device object mounted by some + * other file system. + */ + if (FileObject->DeviceObject->Vpb && + FileObject->DeviceObject->Vpb->DeviceObject) + { + DeviceObject = FileObject->DeviceObject->Vpb->DeviceObject; + } + + /* Return the highest attached device */ + return IoGetAttachedDevice(DeviceObject); +} + /* * @unimplemented */ @@ -852,7 +837,6 @@ IoSynchronousInvalidateDeviceRelations( UNIMPLEMENTED; } - /* * @unimplemented */ diff --git a/reactos/ntoskrnl/io/driver.c b/reactos/ntoskrnl/io/driver.c index 7293ead662e..b199b23584c 100644 --- a/reactos/ntoskrnl/io/driver.c +++ b/reactos/ntoskrnl/io/driver.c @@ -1649,6 +1649,7 @@ IoCreateDriver ( PDRIVER_OBJECT DriverObject; UNICODE_STRING ServiceKeyName; HANDLE hDriver; + ULONG i; /* First, create a unique name for the driver if we don't have one */ if (!DriverName) { @@ -1695,7 +1696,12 @@ IoCreateDriver ( DriverObject->DriverExtension = (PDRIVER_EXTENSION)(DriverObject + 1); DriverObject->DriverExtension->DriverObject = DriverObject; DriverObject->DriverInit = InitializationFunction; - /* FIXME: Invalidate all Major Functions b/c now they are NULL and might crash */ + + /* Invalidate all Major Functions */ + for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) + { + DriverObject->MajorFunction[i] = IopInvalidDeviceRequest; + } /* Set up the Service Key Name */ ServiceKeyName.Buffer = ExAllocatePool(PagedPool, LocalDriverName.Length + sizeof(WCHAR)); diff --git a/reactos/ntoskrnl/io/efi.c b/reactos/ntoskrnl/io/efi.c index f93fea0d784..a02a1d40bed 100644 --- a/reactos/ntoskrnl/io/efi.c +++ b/reactos/ntoskrnl/io/efi.c @@ -1,5 +1,4 @@ -/* $Id:$ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: ntoskrnl/io/efi.c @@ -15,9 +14,6 @@ /* FUNCTIONS *****************************************************************/ -/* - * @unimplemented - */ NTSTATUS STDCALL NtAddBootEntry( @@ -28,9 +24,7 @@ NtAddBootEntry( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } -/* - * @unimplemented - */ + NTSTATUS STDCALL NtDeleteBootEntry( @@ -41,9 +35,7 @@ NtDeleteBootEntry( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } -/* - * @unimplemented - */ + NTSTATUS STDCALL NtEnumerateBootEntries( @@ -54,9 +46,7 @@ NtEnumerateBootEntries( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } -/* - * @unimplemented - */ + NTSTATUS STDCALL NtQueryBootEntryOrder( @@ -67,9 +57,7 @@ NtQueryBootEntryOrder( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } -/* - * @unimplemented - */ + NTSTATUS STDCALL NtQueryBootOptions( @@ -80,9 +68,7 @@ NtQueryBootOptions( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } -/* - * @unimplemented - */ + NTSTATUS STDCALL NtSetBootEntryOrder( @@ -93,10 +79,7 @@ NtSetBootEntryOrder( UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; } - -/* - * @unimplemented - */ + NTSTATUS STDCALL NtSetBootOptions( @@ -106,12 +89,8 @@ NtSetBootOptions( { UNIMPLEMENTED; return STATUS_NOT_IMPLEMENTED; -} - - -/* - * @unimplemented - */ +} + NTSTATUS STDCALL NtTranslateFilePath( @@ -124,5 +103,4 @@ NtTranslateFilePath( return STATUS_NOT_IMPLEMENTED; } - /* EOF */ diff --git a/reactos/ntoskrnl/io/iomgr.c b/reactos/ntoskrnl/io/iomgr.c index 3c3553aa5f0..8614e6076b9 100644 --- a/reactos/ntoskrnl/io/iomgr.c +++ b/reactos/ntoskrnl/io/iomgr.c @@ -417,7 +417,7 @@ IoInit (VOID) IoDeviceObjectType->Security = NULL; IoDeviceObjectType->QueryName = NULL; IoDeviceObjectType->OkayToClose = NULL; - IoDeviceObjectType->Create = IopCreateDevice; + IoDeviceObjectType->Create = NULL; IoDeviceObjectType->DuplicationNotify = NULL; RtlInitUnicodeString(&IoDeviceObjectType->TypeName, L"Device");