[NTOSKRNL] We don't need an event if we don't issue an IRP

This commit is contained in:
Pierre Schweitzer 2019-03-29 21:47:34 +01:00
parent 28ba29e457
commit ef8b1a1907
No known key found for this signature in database
GPG key ID: 7545556C3D585B0B

View file

@ -4164,18 +4164,6 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
return Status; return Status;
} }
} }
else
{
/* Use local event */
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
if (!Event)
{
ObDereferenceObject(FileObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
LocalEvent = TRUE;
}
/* /*
* Quick path for FileFsDeviceInformation - the kernel has enough * Quick path for FileFsDeviceInformation - the kernel has enough
@ -4203,18 +4191,29 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
} }
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{ {
/* Cleanup */ /* Check if we had a file lock */
IopCleanupAfterException(FileObject, NULL, NULL, Event); if (BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
{
/* Release it */
IopUnlockFileObject(FileObject);
}
/* Dereference the FO */
ObDereferenceObject(FileObject);
_SEH2_YIELD(return _SEH2_GetExceptionCode()); _SEH2_YIELD(return _SEH2_GetExceptionCode());
} }
_SEH2_END; _SEH2_END;
/* /* Check if we had a file lock */
* We didn't have an exception, but we didn't issue an IRP if (BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
* to complete either, so avoid duplicating code and {
* call appropriate helper /* Release it */
*/ IopUnlockFileObject(FileObject);
IopCleanupAfterException(FileObject, NULL, NULL, Event); }
/* Dereference the FO */
ObDereferenceObject(FileObject);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
@ -4258,16 +4257,32 @@ NtQueryVolumeInformationFile(IN HANDLE FileHandle,
ExFreePoolWithTag(DriverPathInfo, TAG_IO); ExFreePoolWithTag(DriverPathInfo, TAG_IO);
} }
/* /* Check if we had a file lock */
* We didn't have an exception, but we didn't issue an IRP if (BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
* to complete either, so avoid duplicating code and {
* call appropriate helper /* Release it */
*/ IopUnlockFileObject(FileObject);
IopCleanupAfterException(FileObject, NULL, NULL, Event); }
/* Dereference the FO */
ObDereferenceObject(FileObject);
return Status; return Status;
} }
if (!BooleanFlagOn(FileObject->Flags, FO_SYNCHRONOUS_IO))
{
/* Use local event */
Event = ExAllocatePoolWithTag(NonPagedPool, sizeof(KEVENT), TAG_IO);
if (!Event)
{
ObDereferenceObject(FileObject);
return STATUS_INSUFFICIENT_RESOURCES;
}
KeInitializeEvent(Event, SynchronizationEvent, FALSE);
LocalEvent = TRUE;
}
/* Get the device object */ /* Get the device object */
DeviceObject = IoGetRelatedDeviceObject(FileObject); DeviceObject = IoGetRelatedDeviceObject(FileObject);