00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
#include "FsRtlP.h"
00028
00029
#ifndef FAR
00030
#define FAR
00031
#endif
00032
#include <IoEvent.h>
00033
00034
#ifdef ALLOC_PRAGMA
00035
#pragma alloc_text(PAGE, FsRtlNotifyVolumeEvent)
00036
#endif
00037
00038
00039
NTKERNELAPI
00040
NTSTATUS
00041 FsRtlNotifyVolumeEvent (
00042 IN
PFILE_OBJECT FileObject,
00043 IN ULONG EventCode
00044 )
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 {
00067
NTSTATUS Status = STATUS_SUCCESS;
00068
00069
TARGET_DEVICE_CUSTOM_NOTIFICATION Event;
00070
PDEVICE_OBJECT Pdo;
00071
00072
00073
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
00113
00114
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 }
00140
00141