From 02fd65a6dcb63232ff18c8ecf1c432153b514cc7 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Thu, 23 May 2002 09:53:26 +0000 Subject: [PATCH] Use NT-compatible (VPB-based) mounting mechanism. svn path=/trunk/; revision=2974 --- reactos/drivers/fs/cdfs/fsctl.c | 23 +- reactos/drivers/fs/ext2/super.c | 10 +- reactos/drivers/fs/minix/mount.c | 43 ++-- reactos/drivers/fs/template/template.c | 285 ++++++++++++++----------- reactos/drivers/fs/vfat/fsctl.c | 32 ++- reactos/ntoskrnl/io/create.c | 19 +- 6 files changed, 237 insertions(+), 175 deletions(-) diff --git a/reactos/drivers/fs/cdfs/fsctl.c b/reactos/drivers/fs/cdfs/fsctl.c index 16ed6cc343c..646e597dcf2 100644 --- a/reactos/drivers/fs/cdfs/fsctl.c +++ b/reactos/drivers/fs/cdfs/fsctl.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: fsctl.c,v 1.6 2002/05/15 18:01:30 ekohl Exp $ +/* $Id: fsctl.c,v 1.7 2002/05/23 09:52:00 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -35,7 +35,6 @@ #include "cdfs.h" - /* FUNCTIONS ****************************************************************/ static VOID @@ -295,19 +294,15 @@ CdfsMountVolume(PDEVICE_OBJECT DeviceObject, if (!NT_SUCCESS(Status)) goto ByeBye; - - -#if 0 - NewDeviceObject->StackSize = DeviceToMount->StackSize; - Vpb->DeviceObject = NewDeviceObject; - DeviceExt->Vpb = Vpb; - DeviceExt->StorageDevice = DeviceToMount; -#endif - NewDeviceObject->Vpb = DeviceToMount->Vpb; - NewDeviceObject->Vpb->Flags |= VPB_MOUNTED; - DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(NewDeviceObject, - DeviceToMount); + + DeviceExt->StorageDevice = DeviceToMount; + DeviceExt->StorageDevice->Vpb->DeviceObject = NewDeviceObject; + DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; + DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; + DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + DeviceExt->StreamFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice); diff --git a/reactos/drivers/fs/ext2/super.c b/reactos/drivers/fs/ext2/super.c index 9c147542150..38059489fed 100644 --- a/reactos/drivers/fs/ext2/super.c +++ b/reactos/drivers/fs/ext2/super.c @@ -104,8 +104,14 @@ NTSTATUS Ext2Mount(PDEVICE_OBJECT DeviceToMount) DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO; DeviceExt = (PVOID)DeviceObject->DeviceExtension; DPRINT("DeviceExt %x\n",DeviceExt); - DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject, - DeviceToMount); + + DeviceExt->StorageDevice = DeviceToMount; + DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject; + DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; + DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; + DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + DPRINT("DeviceExt->StorageDevice %x\n", DeviceExt->StorageDevice); DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject); DeviceExt->superblock = superblock; diff --git a/reactos/drivers/fs/minix/mount.c b/reactos/drivers/fs/minix/mount.c index c709a465b3e..e78bbf3c144 100644 --- a/reactos/drivers/fs/minix/mount.c +++ b/reactos/drivers/fs/minix/mount.c @@ -42,25 +42,30 @@ static PDRIVER_OBJECT DriverObject; VOID MinixMount(PDEVICE_OBJECT DeviceToMount) { - PDEVICE_OBJECT DeviceObject; - MINIX_DEVICE_EXTENSION* DeviceExt; - - IoCreateDevice(DriverObject, - sizeof(MINIX_DEVICE_EXTENSION), - NULL, - FILE_DEVICE_FILE_SYSTEM, - 0, - FALSE, - &DeviceObject); - DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO; - DeviceExt = DeviceObject->DeviceExtension; - - MinixReadSector(DeviceToMount,1,DeviceExt->superblock_buf); - DeviceExt->sb = (struct minix_super_block *)(DeviceExt->superblock_buf); - - DeviceExt->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject, - DeviceToMount); - DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject); + PDEVICE_OBJECT DeviceObject; + MINIX_DEVICE_EXTENSION* DeviceExt; + + IoCreateDevice(DriverObject, + sizeof(MINIX_DEVICE_EXTENSION), + NULL, + FILE_DEVICE_FILE_SYSTEM, + 0, + FALSE, + &DeviceObject); + DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO; + DeviceExt = DeviceObject->DeviceExtension; + + MinixReadSector(DeviceToMount,1,DeviceExt->superblock_buf); + DeviceExt->sb = (struct minix_super_block *)(DeviceExt->superblock_buf); + + DeviceExt->StorageDevice = DeviceToMount; + DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject; + DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; + DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; + DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject); } NTSTATUS STDCALL diff --git a/reactos/drivers/fs/template/template.c b/reactos/drivers/fs/template/template.c index 8a2690d90b2..93676cb085c 100644 --- a/reactos/drivers/fs/template/template.c +++ b/reactos/drivers/fs/template/template.c @@ -1,4 +1,23 @@ /* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: template.c,v 1.3 2002/05/23 09:52:56 ekohl Exp $ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel * FILE: services/fs/template/template.c @@ -19,7 +38,7 @@ typedef struct PDEVICE_OBJECT StorageDevice; } DEVICE_EXTENSION, *PDEVICE_EXTENSION; -/* GLOBALS *****************************************************************/ +/* GLOBALS ******************************************************************/ static PDRIVER_OBJECT DriverObject; @@ -32,9 +51,10 @@ FsdCloseFile(PDEVICE_EXTENSION DeviceExt, * FUNCTION: Closes a file */ { - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } + NTSTATUS FsdOpenFile(PDEVICE_EXTENSION DeviceExt, PFILE_OBJECT FileObject, @@ -43,9 +63,10 @@ FsdOpenFile(PDEVICE_EXTENSION DeviceExt, * FUNCTION: Opens a file */ { - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } + BOOLEAN FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount) /* @@ -53,9 +74,10 @@ FsdHasFileSystem(PDEVICE_OBJECT DeviceToMount) * by this fsd */ { - return(TRUE); + return(TRUE); } + NTSTATUS FsdMountDevice(PDEVICE_EXTENSION DeviceExt, PDEVICE_OBJECT DeviceToMount) @@ -63,7 +85,7 @@ FsdMountDevice(PDEVICE_EXTENSION DeviceExt, * FUNCTION: Mounts the device */ { - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } @@ -77,7 +99,7 @@ FsdReadFile(PDEVICE_EXTENSION DeviceExt, * FUNCTION: Reads data from a file */ { - return(STATUS_SUCCESS); + return(STATUS_SUCCESS); } @@ -85,37 +107,38 @@ NTSTATUS STDCALL FsdClose(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); - PFILE_OBJECT FileObject = Stack->FileObject; - PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; - NTSTATUS Status; - - Status = FsdCloseFile(DeviceExtension,FileObject); + PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); + PFILE_OBJECT FileObject = Stack->FileObject; + PDEVICE_EXTENSION DeviceExtension = DeviceObject->DeviceExtension; + NTSTATUS Status; - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = 0; - - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return(Status); + Status = FsdCloseFile(DeviceExtension,FileObject); + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return(Status); } + NTSTATUS STDCALL FsdCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); - PFILE_OBJECT FileObject = Stack->FileObject; - NTSTATUS Status; - PDEVICE_EXTENSION DeviceExt; - - DeviceExt = DeviceObject->DeviceExtension; - Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer); - - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = 0; - - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return(Status); + PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); + PFILE_OBJECT FileObject = Stack->FileObject; + NTSTATUS Status; + PDEVICE_EXTENSION DeviceExt; + + DeviceExt = DeviceObject->DeviceExtension; + Status = FsdOpenFile(DeviceExt,FileObject,FileObject->FileName.Buffer); + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return(Status); } @@ -123,89 +146,96 @@ NTSTATUS STDCALL FsdWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp); - - Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; - Irp->IoStatus.Information = 0; - return(STATUS_UNSUCCESSFUL); + DPRINT("FsdWrite(DeviceObject %x Irp %x)\n",DeviceObject,Irp); + + Irp->IoStatus.Status = STATUS_UNSUCCESSFUL; + Irp->IoStatus.Information = 0; + return(STATUS_UNSUCCESSFUL); } NTSTATUS STDCALL FsdRead(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - ULONG Length; - PVOID Buffer; - ULONG Offset; - PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); - PFILE_OBJECT FileObject = Stack->FileObject; - PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; - NTSTATUS Status; - - DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); - - Length = Stack->Parameters.Read.Length; - Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); - Offset = Stack->Parameters.Read.ByteOffset.LowPart; - - Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset); - - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = Length; - IoCompleteRequest(Irp,IO_NO_INCREMENT); - return(Status); + ULONG Length; + PVOID Buffer; + ULONG Offset; + PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); + PFILE_OBJECT FileObject = Stack->FileObject; + PDEVICE_EXTENSION DeviceExt = DeviceObject->DeviceExtension; + NTSTATUS Status; + + DPRINT("FsdRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp); + + Length = Stack->Parameters.Read.Length; + Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress); + Offset = Stack->Parameters.Read.ByteOffset.LowPart; + + Status = FsdReadFile(DeviceExt,FileObject,Buffer,Length,Offset); + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = Length; + IoCompleteRequest(Irp,IO_NO_INCREMENT); + return(Status); } NTSTATUS FsdMount(PDEVICE_OBJECT DeviceToMount) { - PDEVICE_OBJECT DeviceObject; - PDEVICE_EXTENSION DeviceExt; - - IoCreateDevice(DriverObject, - sizeof(DEVICE_EXTENSION), - NULL, - FILE_DEVICE_FILE_SYSTEM, - 0, - FALSE, - &DeviceObject); - DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO; - DeviceExt = (PVOID)DeviceObject->DeviceExtension; - - FsdMountDevice(DeviceExt, - DeviceToMount); - - DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject, - DeviceToMount); - return(STATUS_SUCCESS); + PDEVICE_OBJECT DeviceObject; + PDEVICE_EXTENSION DeviceExt; + + IoCreateDevice(DriverObject, + sizeof(DEVICE_EXTENSION), + NULL, + FILE_DEVICE_FILE_SYSTEM, + 0, + FALSE, + &DeviceObject); + DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO; + DeviceExt = (PVOID)DeviceObject->DeviceExtension; + + FsdMountDevice(DeviceExt, + DeviceToMount); + + DeviceExt->StorageDevice = DeviceToMount; + DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject; + DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; + DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; + DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + return(STATUS_SUCCESS); } + NTSTATUS STDCALL FsdFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp) { - PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); - PVPB vpb = Stack->Parameters.Mount.Vpb; - PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject; - NTSTATUS Status; - - if (FsdHasFileSystem(DeviceToMount)) - { - Status = FsdMount(DeviceToMount); - } - else - { - Status = STATUS_UNRECOGNIZED_VOLUME; - } - - Irp->IoStatus.Status = Status; - Irp->IoStatus.Information = 0; - - IoCompleteRequest(Irp, IO_NO_INCREMENT); - return(Status); + PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp); + PVPB vpb = Stack->Parameters.Mount.Vpb; + PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject; + NTSTATUS Status; + + if (FsdHasFileSystem(DeviceToMount)) + { + Status = FsdMount(DeviceToMount); + } + else + { + Status = STATUS_UNRECOGNIZED_VOLUME; + } + + Irp->IoStatus.Status = Status; + Irp->IoStatus.Information = 0; + + IoCompleteRequest(Irp, IO_NO_INCREMENT); + return(Status); } + NTSTATUS STDCALL DriverEntry(PDRIVER_OBJECT _DriverObject, PUNICODE_STRING RegistryPath) @@ -217,39 +247,40 @@ DriverEntry(PDRIVER_OBJECT _DriverObject, * RETURNS: Success or failure */ { - PDEVICE_OBJECT DeviceObject; - NTSTATUS Status; - UNICODE_STRING DeviceName; - - DbgPrint("Bare FSD Template 0.0.1\n"); - - DriverObject = _DriverObject; - - RtlInitUnicodeString(&DeviceName, - L"\\Device\\BareFsd"); - Status = IoCreateDevice(DriverObject, - 0, - &DeviceName, - FILE_DEVICE_FILE_SYSTEM, - 0, - FALSE, - &DeviceObject); - if (!NT_SUCCESS(Status)) - { - return(ret); - } - - DeviceObject->Flags=0; - DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose; - DriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate; - DriverObject->MajorFunction[IRP_MJ_READ] = FsdRead; - DriverObject->MajorFunction[IRP_MJ_WRITE] = FsdWrite; - DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = - FsdFileSystemControl; - DriverObject->DriverUnload = NULL; - - IoRegisterFileSystem(DeviceObject); - - return(STATUS_SUCCESS); + PDEVICE_OBJECT DeviceObject; + NTSTATUS Status; + UNICODE_STRING DeviceName; + + DbgPrint("Bare FSD Template 0.0.1\n"); + + DriverObject = _DriverObject; + + RtlInitUnicodeString(&DeviceName, + L"\\Device\\BareFsd"); + Status = IoCreateDevice(DriverObject, + 0, + &DeviceName, + FILE_DEVICE_FILE_SYSTEM, + 0, + FALSE, + &DeviceObject); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + + DeviceObject->Flags=0; + DriverObject->MajorFunction[IRP_MJ_CLOSE] = FsdClose; + DriverObject->MajorFunction[IRP_MJ_CREATE] = FsdCreate; + DriverObject->MajorFunction[IRP_MJ_READ] = FsdRead; + DriverObject->MajorFunction[IRP_MJ_WRITE] = FsdWrite; + DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] = + FsdFileSystemControl; + DriverObject->DriverUnload = NULL; + + IoRegisterFileSystem(DeviceObject); + + return(STATUS_SUCCESS); } +/* EOF */ diff --git a/reactos/drivers/fs/vfat/fsctl.c b/reactos/drivers/fs/vfat/fsctl.c index 799cabce920..6c2a7d4d34c 100644 --- a/reactos/drivers/fs/vfat/fsctl.c +++ b/reactos/drivers/fs/vfat/fsctl.c @@ -1,4 +1,22 @@ -/* $Id: fsctl.c,v 1.3 2002/05/05 20:19:14 hbirr Exp $ +/* + * ReactOS kernel + * Copyright (C) 2002 ReactOS Team + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +/* $Id: fsctl.c,v 1.4 2002/05/23 09:53:26 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -254,8 +272,15 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext) DbgPrint("RootCluster: %d\n", DeviceExt->FatInfo.RootCluster); } #endif - DeviceObject->Vpb->Flags |= VPB_MOUNTED; - DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject, IrpContext->Stack->Parameters.MountVolume.DeviceObject); + + DeviceExt->StorageDevice = IrpContext->Stack->Parameters.MountVolume.DeviceObject; + DeviceExt->StorageDevice->Vpb->DeviceObject = DeviceObject; + DeviceExt->StorageDevice->Vpb->RealDevice = DeviceExt->StorageDevice; + DeviceExt->StorageDevice->Vpb->Flags |= VPB_MOUNTED; + DeviceObject->StackSize = DeviceExt->StorageDevice->StackSize + 1; + DeviceObject->Flags &= ~DO_DEVICE_INITIALIZING; + + DPRINT("FsDeviceObject %lx\n", DeviceObject); DeviceExt->FATFileObject = IoCreateStreamFileObject(NULL, DeviceExt->StorageDevice); Fcb = vfatNewFCB(NULL); @@ -334,7 +359,6 @@ VfatMount (PVFAT_IRP_CONTEXT IrpContext) ReadVolumeLabel(DeviceExt, DeviceObject->Vpb); Status = STATUS_SUCCESS; - ByeBye: if (!NT_SUCCESS(Status)) diff --git a/reactos/ntoskrnl/io/create.c b/reactos/ntoskrnl/io/create.c index 9616696cf83..a2f53ac7605 100644 --- a/reactos/ntoskrnl/io/create.c +++ b/reactos/ntoskrnl/io/create.c @@ -1,4 +1,4 @@ -/* $Id: create.c,v 1.57 2002/05/15 09:39:02 ekohl Exp $ +/* $Id: create.c,v 1.58 2002/05/23 09:51:11 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -139,8 +139,9 @@ IopCreateFile(PVOID ObjectBody, Status); return(Status); } - DeviceObject = IoGetAttachedDevice(DeviceObject); } + DeviceObject = DeviceObject->Vpb->DeviceObject; + DPRINT("FsDeviceObject %lx\n", DeviceObject); } RtlCreateUnicodeString(&(FileObject->FileName), RemainingPath); @@ -189,7 +190,7 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, DPRINT("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", FileObject, DeviceObject); - + assert_irql(PASSIVE_LEVEL); Status = ObCreateObject(&FileHandle, @@ -202,7 +203,7 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, DPRINT("Could not create FileObject\n"); return (NULL); } - + if (FileObject != NULL) { DeviceObject = FileObject->DeviceObject; @@ -211,16 +212,16 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject, DPRINT("DeviceObject %x\n", DeviceObject); - CreatedFileObject->DeviceObject = DeviceObject; + CreatedFileObject->DeviceObject = DeviceObject->Vpb->DeviceObject; CreatedFileObject->Vpb = DeviceObject->Vpb; CreatedFileObject->Type = InternalFileType; CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN; // shouldn't we initialize the lock event, and several other things here too? KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE); - + ZwClose(FileHandle); - + return(CreatedFileObject); } @@ -332,8 +333,8 @@ IoCreateFile(OUT PHANDLE FileHandle, (PVOID*)&FileObject); if (!NT_SUCCESS(Status)) { - DPRINT("ObCreateObject() failed!\n"); - return (Status); + DPRINT("ObCreateObject() failed! (Status %lx)\n", Status); + return(Status); } if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT) {