Author: ion
Date: Mon Jun 12 02:26:54 2006
New Revision: 22317
URL:
http://svn.reactos.ru/svn/reactos?rev=22317&view=rev
Log:
- Bring out the champagne... one of my first-ever and most ancient ReactOS TODOs: the
IopCreateFile hack has been totally removed and we now have a file/device parse routine.
It's still nothing like NT's but it's not a hack anymore, and actually works
like it should.
Modified:
trunk/reactos/ntoskrnl/include/internal/io.h
trunk/reactos/ntoskrnl/io/file.c
trunk/reactos/ntoskrnl/io/iomgr.c
trunk/reactos/ntoskrnl/ob/obname.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i…
==============================================================================
--- trunk/reactos/ntoskrnl/include/internal/io.h (original)
+++ trunk/reactos/ntoskrnl/include/internal/io.h Mon Jun 12 02:26:54 2006
@@ -486,12 +486,33 @@
/* file.c */
NTSTATUS
-STDCALL
-IopCreateFile(
- PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_CREATE_INFORMATION ObjectAttributes
+NTAPI
+IopParseDevice(
+ IN PVOID ParseObject,
+ IN POBJECT_TYPE ObjectType,
+ IN OUT PACCESS_STATE AccessState,
+ IN KPROCESSOR_MODE AccessMode,
+ IN ULONG Attributes,
+ IN OUT PUNICODE_STRING CompleteName,
+ IN OUT PUNICODE_STRING RemainingName,
+ IN OUT PVOID Context OPTIONAL,
+ IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
+ OUT PVOID *Object
+);
+
+NTSTATUS
+NTAPI
+IopParseFile(
+ IN PVOID ParseObject,
+ IN POBJECT_TYPE ObjectType,
+ IN OUT PACCESS_STATE AccessState,
+ IN KPROCESSOR_MODE AccessMode,
+ IN ULONG Attributes,
+ IN OUT PUNICODE_STRING CompleteName,
+ IN OUT PUNICODE_STRING RemainingName,
+ IN OUT PVOID Context OPTIONAL,
+ IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
+ OUT PVOID *Object
);
VOID
Modified: trunk/reactos/ntoskrnl/io/file.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/io/file.c?rev=2231…
==============================================================================
--- trunk/reactos/ntoskrnl/io/file.c (original)
+++ trunk/reactos/ntoskrnl/io/file.c Mon Jun 12 02:26:54 2006
@@ -39,6 +39,10 @@
IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
OUT PVOID *Object)
{
+ POPEN_PACKET OpenPacket = (POPEN_PACKET)Context;
+ PDEVICE_OBJECT DeviceObject;
+ NTSTATUS Status;
+ PFILE_OBJECT FileObject;
DPRINT("IopParseDevice:\n"
"DeviceObject : %p, Type : %p, TypeName : %wZ\n"
"FileObject : %p, Type : %p, TypeName : %wZ\n"
@@ -52,11 +56,61 @@
CompleteName,
RemainingName);
- /*
- * Just clear the object and return success, and ObFindObject will behave
- * just as if we had no parse procedure, so we can debug in peace.
- */
- *Object = NULL;
+ if (!RemainingName || !RemainingName->Buffer)
+ {
+ DeviceObject = ParseObject;
+
+ Status = ObCreateObject(AccessMode,
+ IoFileObjectType,
+ NULL,
+ AccessMode,
+ NULL,
+ sizeof(FILE_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&FileObject);
+ /* Set File Object Data */
+ FileObject->DeviceObject = IoGetAttachedDevice(DeviceObject);
+
+ /* HACK */
+ FileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
+ *Object = FileObject;
+ return STATUS_SUCCESS;
+ }
+
+ Status = ObCreateObject(AccessMode,
+ IoFileObjectType,
+ NULL,
+ AccessMode,
+ NULL,
+ sizeof(FILE_OBJECT),
+ 0,
+ 0,
+ (PVOID*)&FileObject);
+
+ if (ObjectType == IoDeviceObjectType)
+ {
+ /* Parent is a device object */
+ DeviceObject = IoGetAttachedDevice((PDEVICE_OBJECT)ParseObject);
+ if (DeviceObject->Vpb)
+ {
+ if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
+ {
+ Status = IoMountVolume(DeviceObject, FALSE);
+ }
+ DeviceObject = DeviceObject->Vpb->DeviceObject;
+ }
+ }
+ else
+ {
+ FileObject->RelatedFileObject = OpenPacket->RelatedFileObject;
+ DeviceObject = OpenPacket->RelatedFileObject->DeviceObject;
+ }
+
+ RtlCreateUnicodeString(&FileObject->FileName, RemainingName->Buffer);
+ FileObject->DeviceObject = DeviceObject;
+ *Object = FileObject;
+ RemainingName->Buffer = NULL; // ros hack
return STATUS_SUCCESS;
}
@@ -74,23 +128,11 @@
OUT PVOID *Object)
{
PVOID DeviceObject;
+ OPEN_PACKET OpenPacket;
/* Get the device object */
DeviceObject = IoGetRelatedDeviceObject(ParseObject);
- Context = ParseObject;
-
- DPRINT("IopParseFile:\n"
- "DeviceObject : %p, Type : %p, TypeName : %wZ\n"
- "FileObject : %p, Type : %p, TypeName : %wZ\n"
- "CompleteName : %wZ, RemainingName : %wZ\n",
- DeviceObject,
- OBJECT_TO_OBJECT_HEADER(DeviceObject)->Type,
- &OBJECT_TO_OBJECT_HEADER(DeviceObject)->Type->Name,
- ParseObject,
- ObjectType,
- &ObjectType->Name,
- CompleteName,
- RemainingName);
+ OpenPacket.RelatedFileObject = ParseObject;
/* Call the main routine */
return IopParseDevice(DeviceObject,
@@ -100,76 +142,9 @@
Attributes,
CompleteName,
RemainingName,
- Context,
+ &OpenPacket,
SecurityQos,
Object);
-
-}
-
-/*
- * NAME INTERNAL
- * IopCreateFile
- *
- * DESCRIPTION
- *
- * ARGUMENTS
- *
- * RETURN VALUE
- *
- * REVISIONS
- */
-NTSTATUS
-STDCALL
-IopCreateFile(PVOID ObjectBody,
- PVOID Parent,
- PWSTR RemainingPath,
- POBJECT_CREATE_INFORMATION ObjectCreateInfo)
-{
- PDEVICE_OBJECT DeviceObject;
- PFILE_OBJECT FileObject = (PFILE_OBJECT) ObjectBody;
- POBJECT_TYPE ParentObjectType;
- NTSTATUS Status;
-
- ParentObjectType = OBJECT_TO_OBJECT_HEADER(Parent)->Type;
- if (ParentObjectType == IoDeviceObjectType)
- {
- /* Parent is a device object */
- DeviceObject = IoGetAttachedDevice((PDEVICE_OBJECT)Parent);
- if (DeviceObject->Vpb)
- {
- if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
- {
- DPRINT("Mount the logical volume\n");
- Status = IoMountVolume(DeviceObject, FALSE);
- DPRINT("Status %x\n", Status);
- }
- DeviceObject = DeviceObject->Vpb->DeviceObject;
- }
- }
- else
- {
- DeviceObject = ((PFILE_OBJECT)Parent)->DeviceObject;
- FileObject->RelatedFileObject = (PFILE_OBJECT)Parent;
- }
-
-#if 0
- DbgPrint("--------------------- Creating File ---------------------\n");
- DbgPrint("Parent ObjectType: %wZ\n"
- "Device Object: %p\n"
- "File Object: %p\n"
- "Device Name: %wZ\n"
- "Remaining Path: %S\n",
- &ParentObjectType->Name,
- DeviceObject,
- FileObject,
- &DeviceObject->DriverObject->DriverName,
- RemainingPath);
- DbgPrint("--------------------- Created File ----------------------\n");
-#endif
-
- RtlCreateUnicodeString(&FileObject->FileName, RemainingPath);
- FileObject->DeviceObject = DeviceObject;
- return STATUS_SUCCESS;
}
VOID
@@ -847,7 +822,7 @@
IN ULONG Options)
{
PFILE_OBJECT FileObject = NULL;
- PDEVICE_OBJECT DeviceObject;
+ //PDEVICE_OBJECT DeviceObject;
PIRP Irp;
PEXTENDED_IO_STACK_LOCATION StackLoc;
IO_SECURITY_CONTEXT SecurityContext;
@@ -940,6 +915,8 @@
DPRINT1("FIXME: IO_CHECK_CREATE_PARAMETERS not yet supported!\n");
}
+ RtlMapGenericMask(&DesiredAccess,
&IoFileObjectType->TypeInfo.GenericMapping);
+
/* First try to open an existing named object */
Status = ObOpenObjectByName(ObjectAttributes,
NULL,
@@ -949,69 +926,14 @@
NULL,
&LocalHandle);
- //
- // start stuff that should be in IopParseDevice
- //
- if (NT_SUCCESS(Status))
- {
- Status = ObReferenceObjectByHandle(LocalHandle,
- DesiredAccess,
- NULL,
- KernelMode,
- (PVOID*)&DeviceObject,
- NULL);
- DPRINT("FileExisted: %wZ %lx %p\n", ObjectAttributes->ObjectName,
LocalHandle, DeviceObject);
- ZwClose(LocalHandle);
-
- /* FIXME: wt... */
- Status = ObCreateObject(KernelMode,
- IoFileObjectType,
- NULL,
- KernelMode,
- NULL,
- sizeof(FILE_OBJECT),
- 0,
- 0,
- (PVOID*)&FileObject);
-
- /* Set File Object Data */
- FileObject->DeviceObject = IoGetAttachedDevice(DeviceObject);
-
- /* HACK */
- FileObject->Flags |= FO_DIRECT_DEVICE_OPEN;
- DPRINT("%p\n", FileObject->DeviceObject);
- ObDereferenceObject (DeviceObject);
- }
-
- if (FileObject == NULL)
- {
- Status = ObCreateObject(AccessMode,
- IoFileObjectType,
- ObjectAttributes,
- AccessMode,
- NULL,
- sizeof(FILE_OBJECT),
- 0,
- 0,
- (PVOID*)&FileObject);
- }
-
- RtlMapGenericMask(&DesiredAccess,
-
&OBJECT_TO_OBJECT_HEADER(FileObject)->Type->TypeInfo.GenericMapping);
-
- Status = ObInsertObject ((PVOID)FileObject,
- NULL,
- DesiredAccess,
- 0,
- NULL,
- &LocalHandle);
- if (!NT_SUCCESS(Status))
- {
- DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
- ObMakeTemporaryObject(FileObject);
- ObDereferenceObject (FileObject);
- return Status;
- }
+ ObReferenceObjectByHandle(LocalHandle,
+ DesiredAccess,
+ NULL,
+ KernelMode,
+ (PVOID*)&FileObject,
+ NULL);
+ if (!NT_SUCCESS(Status)) return Status;
+
//
// stop stuff that should be in IopParseDevice
//
Modified: trunk/reactos/ntoskrnl/io/iomgr.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/io/iomgr.c?rev=223…
==============================================================================
--- trunk/reactos/ntoskrnl/io/iomgr.c (original)
+++ trunk/reactos/ntoskrnl/io/iomgr.c Mon Jun 12 02:26:54 2006
@@ -51,31 +51,6 @@
#pragma alloc_text(INIT, IoInit3)
#endif
-NTSTATUS
-NTAPI
-IopParseFile(IN PVOID ParseObject,
- IN PVOID ObjectType,
- IN OUT PACCESS_STATE AccessState,
- IN KPROCESSOR_MODE AccessMode,
- IN ULONG Attributes,
- IN OUT PUNICODE_STRING CompleteName,
- IN OUT PUNICODE_STRING RemainingName,
- IN OUT PVOID Context OPTIONAL,
- IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
- OUT PVOID *Object);
-
-NTSTATUS
-NTAPI
-IopParseDevice(IN PVOID ParseObject,
- IN PVOID ObjectType,
- IN OUT PACCESS_STATE AccessState,
- IN KPROCESSOR_MODE AccessMode,
- IN ULONG Attributes,
- IN OUT PUNICODE_STRING CompleteName,
- IN OUT PUNICODE_STRING RemainingName,
- IN OUT PVOID Context OPTIONAL,
- IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL,
- OUT PVOID *Object);
/* INIT FUNCTIONS ************************************************************/
VOID
Modified: trunk/reactos/ntoskrnl/ob/obname.c
URL:
http://svn.reactos.ru/svn/reactos/trunk/reactos/ntoskrnl/ob/obname.c?rev=22…
==============================================================================
--- trunk/reactos/ntoskrnl/ob/obname.c (original)
+++ trunk/reactos/ntoskrnl/ob/obname.c Mon Jun 12 02:26:54 2006
@@ -338,14 +338,6 @@
*ReturnedObject = NULL;
return STATUS_OBJECT_PATH_NOT_FOUND;
}
- else if (Header->Type == IoFileObjectType)
- {
- /* Otherwise, call the hacked parse routine which will go away soon */
- Status = IopCreateFile(&Header->Body,
- FoundObject,
- RemainingPath->Buffer,
- NULL);
- }
if (FoundHeader && FoundHeader->Type == ObDirectoryType &&
RemainingPath->Buffer)