mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 21:11:54 +00:00
[MOUNTMGR] Introduce MountMgrSendSyncDeviceIoCtl() to replace repeated code (#6960)
See https://www.osr.com/blog/2018/02/14/beware-iobuilddeviceiocontrolrequest/ for some details about IRQL requirements.
This commit is contained in:
parent
50271949e7
commit
ab0e04c81d
5 changed files with 234 additions and 448 deletions
|
@ -37,13 +37,9 @@
|
|||
VOID
|
||||
SendOnlineNotification(IN PUNICODE_STRING SymbolicName)
|
||||
{
|
||||
PIRP Irp;
|
||||
KEVENT Event;
|
||||
NTSTATUS Status;
|
||||
PFILE_OBJECT FileObject;
|
||||
PIO_STACK_LOCATION Stack;
|
||||
PDEVICE_OBJECT DeviceObject;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
|
||||
/* Get device object */
|
||||
Status = IoGetDeviceObjectPointer(SymbolicName,
|
||||
|
@ -51,40 +47,21 @@ SendOnlineNotification(IN PUNICODE_STRING SymbolicName)
|
|||
&FileObject,
|
||||
&DeviceObject);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* And attached device object */
|
||||
DeviceObject = IoGetAttachedDeviceReference(FileObject->DeviceObject);
|
||||
|
||||
/* And send VOLUME_ONLINE */
|
||||
KeInitializeEvent(&Event, NotificationEvent, FALSE);
|
||||
Irp = IoBuildDeviceIoControlRequest(IOCTL_VOLUME_ONLINE,
|
||||
DeviceObject,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
FALSE,
|
||||
&Event,
|
||||
&IoStatusBlock);
|
||||
if (!Irp)
|
||||
{
|
||||
goto Cleanup;
|
||||
}
|
||||
Status = MountMgrSendSyncDeviceIoCtl(IOCTL_VOLUME_ONLINE,
|
||||
DeviceObject,
|
||||
NULL, 0,
|
||||
NULL, 0,
|
||||
FileObject);
|
||||
UNREFERENCED_PARAMETER(Status);
|
||||
|
||||
Stack = IoGetNextIrpStackLocation(Irp);
|
||||
Stack->FileObject = FileObject;
|
||||
|
||||
Status = IoCallDriver(DeviceObject, Irp);
|
||||
if (Status == STATUS_PENDING)
|
||||
{
|
||||
KeWaitForSingleObject(&Event, Executive, KernelMode, FALSE, NULL);
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
ObDereferenceObject(DeviceObject);
|
||||
ObDereferenceObject(FileObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue