From 19f47fc57cfb76f9d3248394b7527a069b457e3b Mon Sep 17 00:00:00 2001 From: Hartmut Birr Date: Tue, 9 Aug 2005 19:12:46 +0000 Subject: [PATCH] If the file object is for a device, we must gather some information from the object attribute (at least the OBJ_INHERIT flag). We cannot use IoCreateStreamFileObject because a handle from such a file object is never inheritable. svn path=/trunk/; revision=17248 --- reactos/ntoskrnl/io/file.c | 44 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 42 insertions(+), 2 deletions(-) diff --git a/reactos/ntoskrnl/io/file.c b/reactos/ntoskrnl/io/file.c index 17bfea8fec2..2821d922f43 100644 --- a/reactos/ntoskrnl/io/file.c +++ b/reactos/ntoskrnl/io/file.c @@ -857,6 +857,10 @@ IoCreateFile(OUT PHANDLE FileHandle, if (NT_SUCCESS(Status)) { + OBJECT_CREATE_INFORMATION ObjectCreateInfo; + OBJECT_ATTRIBUTES tmpObjectAttributes; + UNICODE_STRING ObjectName; + Status = ObReferenceObjectByHandle(LocalHandle, DesiredAccess, NULL, @@ -873,11 +877,47 @@ IoCreateFile(OUT PHANDLE FileHandle, ObDereferenceObject (DeviceObject); return STATUS_OBJECT_NAME_COLLISION; } + + Status = ObpCaptureObjectAttributes(ObjectAttributes, + AccessMode, + NULL, + &ObjectCreateInfo, + &ObjectName); + if (!NT_SUCCESS(Status)) + { + ObDereferenceObject (DeviceObject); + return Status; + } + + InitializeObjectAttributes(&tmpObjectAttributes, + NULL, + ObjectCreateInfo.Attributes & OBJ_INHERIT, + 0, + NULL); + ObpReleaseCapturedAttributes(&ObjectCreateInfo); + if (ObjectName.Buffer) ExFreePool(ObjectName.Buffer); + + /* FIXME: wt... */ - FileObject = IoCreateStreamFileObject(NULL, DeviceObject); + Status = ObCreateObject(KernelMode, + IoFileObjectType, + &tmpObjectAttributes, + KernelMode, + NULL, + sizeof(FILE_OBJECT), + 0, + 0, + (PVOID*)&FileObject); + + + /* Set File Object Data */ + FileObject->DeviceObject = IoGetAttachedDevice(DeviceObject); + FileObject->Vpb = FileObject->DeviceObject->Vpb; + /* HACK */ FileObject->Flags |= FO_DIRECT_DEVICE_OPEN; - DPRINT("%wZ\n", ObjectAttributes->ObjectName); + + DPRINT1("%wZ\n", ObjectAttributes->ObjectName); ObDereferenceObject (DeviceObject); }