- Remove the permanent flag from an object if ObInserObject failed (in IoCreateFile).

- Bypass the driver for FilePositionInformation and FileAlignmentInformation in NtQueryInformationFile and NtSetInformationFile.

svn path=/trunk/; revision=16755
This commit is contained in:
Hartmut Birr 2005-07-26 19:31:41 +00:00
parent dd90242aa7
commit 1bae97d5ce

View file

@ -845,6 +845,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
DPRINT1("FIXME: IO_CHECK_CREATE_PARAMETERS not yet supported!\n"); DPRINT1("FIXME: IO_CHECK_CREATE_PARAMETERS not yet supported!\n");
} }
/* First try to open an existing named object */
Status = ObOpenObjectByName(ObjectAttributes, Status = ObOpenObjectByName(ObjectAttributes,
NULL, NULL,
NULL, NULL,
@ -910,6 +911,7 @@ IoCreateFile(OUT PHANDLE FileHandle,
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))
{ {
DPRINT("ObInsertObject() failed! (Status %lx)\n", Status); DPRINT("ObInsertObject() failed! (Status %lx)\n", Status);
ObMakeTemporaryObject(FileObject);
ObDereferenceObject (FileObject); ObDereferenceObject (FileObject);
return Status; return Status;
} }
@ -2429,11 +2431,6 @@ NtQueryInformationFile(HANDLE FileHandle,
Failed = TRUE; Failed = TRUE;
break; break;
case FileAlignmentInformation:
if (!(FileObject->Flags & FO_NO_INTERMEDIATE_BUFFERING))
Failed = TRUE;
break;
default: default:
break; break;
} }
@ -2445,6 +2442,30 @@ NtQueryInformationFile(HANDLE FileHandle,
return STATUS_ACCESS_DENIED; return STATUS_ACCESS_DENIED;
} }
if (FileInformationClass == FilePositionInformation)
{
if (Length < sizeof(FILE_POSITION_INFORMATION))
{
Status = STATUS_BUFFER_OVERFLOW;
}
else
{
_SEH_TRY
{
((PFILE_POSITION_INFORMATION)FileInformation)->CurrentByteOffset = FileObject->CurrentByteOffset;
IoStatusBlock->Information = sizeof(FILE_POSITION_INFORMATION);
Status = IoStatusBlock->Status = STATUS_SUCCESS;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
ObDereferenceObject(FileObject);
return Status;
}
DPRINT("FileObject 0x%p\n", FileObject); DPRINT("FileObject 0x%p\n", FileObject);
/* Check if this is a direct open or not */ /* Check if this is a direct open or not */
@ -2457,6 +2478,30 @@ NtQueryInformationFile(HANDLE FileHandle,
DeviceObject = IoGetRelatedDeviceObject(FileObject); DeviceObject = IoGetRelatedDeviceObject(FileObject);
} }
if (FileInformationClass == FileAlignmentInformation)
{
if (Length < sizeof(FILE_ALIGNMENT_INFORMATION))
{
Status = STATUS_BUFFER_OVERFLOW;
}
else
{
_SEH_TRY
{
((PFILE_ALIGNMENT_INFORMATION)FileInformation)->AlignmentRequirement = DeviceObject->AlignmentRequirement;
IoStatusBlock->Information = sizeof(FILE_ALIGNMENT_INFORMATION);
Status = IoStatusBlock->Status = STATUS_SUCCESS;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
ObDereferenceObject(FileObject);
return Status;
}
/* Check if we should use Sync IO or not */ /* Check if we should use Sync IO or not */
if (FileObject->Flags & FO_SYNCHRONOUS_IO) if (FileObject->Flags & FO_SYNCHRONOUS_IO)
{ {
@ -2895,6 +2940,30 @@ NtSetInformationFile(HANDLE FileHandle,
DPRINT("FileObject 0x%p\n", FileObject); DPRINT("FileObject 0x%p\n", FileObject);
if (FileInformationClass == FilePositionInformation)
{
if (Length < sizeof(FILE_POSITION_INFORMATION))
{
Status = STATUS_BUFFER_OVERFLOW;
}
else
{
_SEH_TRY
{
FileObject->CurrentByteOffset = ((PFILE_POSITION_INFORMATION)FileInformation)->CurrentByteOffset;
IoStatusBlock->Information = 0;
Status = IoStatusBlock->Status = STATUS_SUCCESS;
}
_SEH_HANDLE
{
Status = _SEH_GetExceptionCode();
}
_SEH_END;
}
ObDereferenceObject(FileObject);
return Status;
}
/* FIXME: Later, we can implement a lot of stuff here and avoid a driver call */ /* FIXME: Later, we can implement a lot of stuff here and avoid a driver call */
/* Handle IO Completion Port quickly */ /* Handle IO Completion Port quickly */
if (FileInformationClass == FileCompletionInformation) if (FileInformationClass == FileCompletionInformation)