Make the remaning code match the current formatting instead of being really ugly, and make some changes to IoCreateFileStreamObject (which is wrong anyways, since it's doing what *Lite should do)

svn path=/trunk/; revision=15178
This commit is contained in:
Alex Ionescu 2005-05-09 04:31:04 +00:00
parent 834acf81da
commit 37707ad1a6

View file

@ -4,7 +4,8 @@
* FILE: ntoskrnl/io/file.c * FILE: ntoskrnl/io/file.c
* PURPOSE: I/O File Object & NT File Handle Access/Managment of Files. * PURPOSE: I/O File Object & NT File Handle Access/Managment of Files.
* *
* PROGRAMMERS: David Welch (welch@mcmail.com) * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
* David Welch (welch@mcmail.com)
*/ */
/* INCLUDES *****************************************************************/ /* INCLUDES *****************************************************************/
@ -767,6 +768,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
ObDereferenceObject (DeviceObject); ObDereferenceObject (DeviceObject);
return STATUS_OBJECT_NAME_COLLISION; return STATUS_OBJECT_NAME_COLLISION;
} }
/* FIXME: wt... */
FileObject = IoCreateStreamFileObject(NULL, DeviceObject); FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
ObDereferenceObject (DeviceObject); ObDereferenceObject (DeviceObject);
} }
@ -1000,11 +1002,16 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject,
PFILE_OBJECT CreatedFileObject; PFILE_OBJECT CreatedFileObject;
NTSTATUS Status; NTSTATUS Status;
/* FIXME: This function should call ObInsertObject. The "Lite" version
doesnt. This function is also called from IoCreateFile for some
reason. These hacks need to be removed.
*/
DPRINT("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n", DPRINT("IoCreateStreamFileObject(FileObject %x, DeviceObject %x)\n",
FileObject, DeviceObject); FileObject, DeviceObject);
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Create the File Object */
Status = ObCreateObject(KernelMode, Status = ObCreateObject(KernelMode,
IoFileObjectType, IoFileObjectType,
NULL, NULL,
@ -1016,35 +1023,25 @@ IoCreateStreamFileObject(PFILE_OBJECT FileObject,
(PVOID*)&CreatedFileObject); (PVOID*)&CreatedFileObject);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("Could not create FileObject\n"); DPRINT1("Could not create FileObject\n");
return (NULL); return (NULL);
} }
if (FileObject != NULL) /* Choose Device Object */
{ if (FileObject) DeviceObject = FileObject->DeviceObject;
DeviceObject = FileObject->DeviceObject;
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
DPRINT("DeviceObject %x\n", DeviceObject); DPRINT("DeviceObject %x\n", DeviceObject);
if (DeviceObject->Vpb && /* Set File Object Data */
DeviceObject->Vpb->DeviceObject)
{
CreatedFileObject->DeviceObject = DeviceObject->Vpb->DeviceObject;
}
else
{
CreatedFileObject->DeviceObject = DeviceObject; CreatedFileObject->DeviceObject = DeviceObject;
}
CreatedFileObject->Vpb = DeviceObject->Vpb; CreatedFileObject->Vpb = DeviceObject->Vpb;
CreatedFileObject->Type = IO_TYPE_FILE; CreatedFileObject->Type = IO_TYPE_FILE;
CreatedFileObject->Flags |= FO_DIRECT_DEVICE_OPEN; CreatedFileObject->Flags = FO_STREAM_FILE;
// shouldn't we initialize the lock event, and several other things here too? /* Initialize Lock and Event */
KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE); KeInitializeEvent(&CreatedFileObject->Event, NotificationEvent, FALSE);
KeInitializeEvent(&CreatedFileObject->Lock, SynchronizationEvent, TRUE); KeInitializeEvent(&CreatedFileObject->Lock, SynchronizationEvent, TRUE);
/* Return file */
return CreatedFileObject; return CreatedFileObject;
} }
@ -1396,21 +1393,28 @@ NtCreateMailslotFile(OUT PHANDLE FileHandle,
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n", "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes, FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer); ObjectAttributes->ObjectName->Buffer);
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Check for Timeout */
if (TimeOut)
if (TimeOut != NULL)
{ {
Buffer.ReadTimeout.QuadPart = TimeOut->QuadPart; /* Enable it */
Buffer.TimeoutSpecified = TRUE; Buffer.TimeoutSpecified = TRUE;
/* FIXME: Add SEH */
Buffer.ReadTimeout = *TimeOut;
} }
else else
{ {
/* No timeout */
Buffer.TimeoutSpecified = FALSE; Buffer.TimeoutSpecified = FALSE;
} }
/* Set Settings */
Buffer.MailslotQuota = MailslotQuota; Buffer.MailslotQuota = MailslotQuota;
Buffer.MaximumMessageSize = MaxMessageSize; Buffer.MaximumMessageSize = MaxMessageSize;
/* Call I/O */
return IoCreateFile(FileHandle, return IoCreateFile(FileHandle,
DesiredAccess, DesiredAccess,
ObjectAttributes, ObjectAttributes,
@ -1450,18 +1454,24 @@ NtCreateNamedPipeFile(PHANDLE FileHandle,
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n", "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes, FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer); ObjectAttributes->ObjectName->Buffer);
PAGED_CODE();
ASSERT_IRQL(PASSIVE_LEVEL); /* Check for Timeout */
if (DefaultTimeout)
if (DefaultTimeout != NULL)
{ {
Buffer.DefaultTimeout.QuadPart = DefaultTimeout->QuadPart; /* Enable it */
Buffer.TimeoutSpecified = TRUE; Buffer.TimeoutSpecified = TRUE;
/* FIXME: Add SEH */
Buffer.DefaultTimeout = *DefaultTimeout;
} }
else else
{ {
/* No timeout */
Buffer.TimeoutSpecified = FALSE; Buffer.TimeoutSpecified = FALSE;
} }
/* Set Settings */
Buffer.NamedPipeType = NamedPipeType; Buffer.NamedPipeType = NamedPipeType;
Buffer.ReadMode = ReadMode; Buffer.ReadMode = ReadMode;
Buffer.CompletionMode = CompletionMode; Buffer.CompletionMode = CompletionMode;
@ -1469,6 +1479,7 @@ NtCreateNamedPipeFile(PHANDLE FileHandle,
Buffer.InboundQuota = InboundQuota; Buffer.InboundQuota = InboundQuota;
Buffer.OutboundQuota = OutboundQuota; Buffer.OutboundQuota = OutboundQuota;
/* Call I/O */
return IoCreateFile(FileHandle, return IoCreateFile(FileHandle,
DesiredAccess, DesiredAccess,
ObjectAttributes, ObjectAttributes,
@ -1983,12 +1994,12 @@ NtQueryAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
FileInformation, FileInformation,
sizeof(FILE_BASIC_INFORMATION), sizeof(FILE_BASIC_INFORMATION),
FileBasicInformation); FileBasicInformation);
ZwClose (FileHandle);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status); DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status);
} }
ZwClose(FileHandle);
return Status; return Status;
} }
@ -2207,12 +2218,12 @@ NtQueryFullAttributesFile(IN POBJECT_ATTRIBUTES ObjectAttributes,
FileInformation, FileInformation,
sizeof(FILE_NETWORK_OPEN_INFORMATION), sizeof(FILE_NETWORK_OPEN_INFORMATION),
FileNetworkOpenInformation); FileNetworkOpenInformation);
ZwClose (FileHandle);
if (!NT_SUCCESS (Status)) if (!NT_SUCCESS (Status))
{ {
DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status); DPRINT ("ZwQueryInformationFile() failed (Status %lx)\n", Status);
} }
ZwClose (FileHandle);
return Status; return Status;
} }