test: fsrtl/pnp.c File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# pnp.c File Reference

`#include "FsRtlP.h"`
`#include <IoEvent.h>`

Go to the source code of this file.

## Functions

NTKERNELAPI NTSTATUS | FsRtlNotifyVolumeEvent (IN PFILE_OBJECT FileObject, IN ULONG EventCode)

## Function Documentation

NTKERNELAPI NTSTATUS FsRtlNotifyVolumeEvent | ( | IN PFILE_OBJECT | FileObject,
|  | IN ULONG | EventCode
| ) |

Definition at line 41 of file fsrtl/pnp.c.

References ASSERT, Event(), FSRTL_VOLUME_DISMOUNT, FSRTL_VOLUME_DISMOUNT_FAILED, FSRTL_VOLUME_LOCK, FSRTL_VOLUME_LOCK_FAILED, FSRTL_VOLUME_MOUNT, FSRTL_VOLUME_UNLOCK, IoGetRelatedTargetDevice(), IoReportTargetDeviceChange(), IoReportTargetDeviceChangeAsynchronous(), NT_SUCCESS, NTSTATUS(), NULL, ObDereferenceObject, Status, TARGET_DEVICE_CUSTOM_NOTIFICATION, and USHORT.

Referenced by UdfCommonCleanup(), UdfDismountVolume(), UdfLockVolume(), UdfMountVolume(), UdfUnlockVolume(), and UdfVerifyVolume().

    00048                    :
    00049
    00050     This routine notifies any registered applications that a
    00051     volume is being locked, unlocked, etc.
    00052
    00053 Arguments:
    00054
    00055     FileeObject - Supplies a file object for the volume being
    00056         locked.
    00057
    00058     EventCode - Which event is occuring -- e.g. FSRTL_VOLUME_LOCK
    00059
    00060 Return Value:
    00061
    00062     Status of the notification.
    00063
    00064 --*/
    00065
    00066 {
    00067     NTSTATUS Status = STATUS_SUCCESS;
    00068
    00069     TARGET_DEVICE_CUSTOM_NOTIFICATION Event;
    00070     PDEVICE_OBJECT Pdo;
    00071
    00072     //
    00073     //  Retrieve the device object associated with this file object.
    00074     //
    00075
    00076     Status = IoGetRelatedTargetDevice( FileObject, &Pdo );
    00077
    00078     if (NT_SUCCESS( Status )) {
    00079
    00080         ASSERT(Pdo != NULL);
    00081
    00082         Event.Version = 1;
    00083         Event.FileObject = NULL;
    00084         Event.NameBufferOffset = -1;
    00085         Event.Size = (USHORT)FIELD_OFFSET( TARGET_DEVICE_CUSTOM_NOTIFICATION, CustomDataBuffer );
    00086
    00087         switch (EventCode) {
    00088
    00089         case FSRTL_VOLUME_DISMOUNT:
    00090
    00091             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_DISMOUNT, sizeof( GUID ));
    00092             break;
    00093
    00094         case FSRTL_VOLUME_DISMOUNT_FAILED:
    00095
    00096             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_DISMOUNT_FAILED, sizeof( GUID ));
    00097             break;
    00098
    00099         case FSRTL_VOLUME_LOCK:
    00100
    00101             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_LOCK, sizeof( GUID ));
    00102             break;
    00103
    00104         case FSRTL_VOLUME_LOCK_FAILED:
    00105
    00106             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_LOCK_FAILED, sizeof( GUID ));
    00107             break;
    00108
    00109         case FSRTL_VOLUME_MOUNT:
    00110
    00111             //
    00112             //  Mount notification is asynchronous to avoid deadlocks when someone
    00113             //  unwittingly causes a mount in the course of handling some other
    00114             //  PnP notification, e.g. MountMgr's device arrival code.
    00115             //
    00116
    00117             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_MOUNT, sizeof( GUID ));
    00118             IoReportTargetDeviceChangeAsynchronous( Pdo, &Event, NULL, NULL );
    00119             ObDereferenceObject( Pdo );
    00120             return STATUS_SUCCESS;
    00121             break;
    00122
    00123         case FSRTL_VOLUME_UNLOCK:
    00124
    00125             RtlCopyMemory( &Event.Event, &GUID_IO_VOLUME_UNLOCK, sizeof( GUID ));
    00126             break;
    00127
    00128         default:
    00129
    00130             ObDereferenceObject( Pdo );
    00131             return STATUS_INVALID_PARAMETER;
    00132         }
    00133
    00134         IoReportTargetDeviceChange( Pdo, &Event );
    00135         ObDereferenceObject( Pdo );
    00136     }
    00137
    00138     return Status;
    00139 }