ReactOS 0.4.15-dev-7712-gbbbcd8e
pnp.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/fsrtl/pnp.c
5 * PURPOSE: Manages PnP support routines for file system drivers.
6 * PROGRAMMERS: Pierre Schweitzer
7 */
8
9/* INCLUDES ******************************************************************/
10
11#include <ntoskrnl.h>
12#include <ioevent.h>
13#define NDEBUG
14#include <debug.h>
15
16/* PUBLIC FUNCTIONS **********************************************************/
17
18/*++
19 * @name FsRtlNotifyVolumeEvent
20 * @implemented
21 *
22 * Notifies system (and applications) that something changed on volume.
23 * FSD should call it each time volume status changes.
24 *
25 * @param FileObject
26 * FileObject for the volume
27 *
28 * @param EventCode
29 * Event that occurs one the volume
30 *
31 * @return STATUS_SUCCESS if notification went well
32 *
33 * @remarks Only present in NT 5+.
34 *
35 *--*/
40{
45
47 if (!NT_SUCCESS(Status))
48 {
49 return Status;
50 }
51
53
54 Notification.Version = 1;
56 /* MSDN says that FileObject must be null
57 when calling IoReportTargetDeviceChangeAsynchronous */
58 Notification.FileObject = NULL;
59 Notification.NameBufferOffset = -1;
60 /* Find the good GUID associated with the event */
61 switch (EventCode)
62 {
64 {
65 Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT;
66 break;
67 }
69 {
70 Guid = (LPGUID)&GUID_IO_VOLUME_DISMOUNT_FAILED;
71 break;
72 }
74 {
75 Guid = (LPGUID)&GUID_IO_VOLUME_LOCK;
76 break;
77 }
79 {
80 Guid = (LPGUID)&GUID_IO_VOLUME_LOCK_FAILED;
81 break;
82 }
84 {
85 Guid = (LPGUID)&GUID_IO_VOLUME_MOUNT;
86 break;
87 }
89 {
90 Guid = (LPGUID)&GUID_IO_VOLUME_UNLOCK;
91 break;
92 }
93 }
94 if (Guid)
95 {
96 /* Copy GUID to notification structure and then report the change */
97 RtlCopyMemory(&(Notification.Event), Guid, sizeof(GUID));
98
100 {
103 NULL,
104 NULL);
105 }
106 else
107 {
109 &Notification);
110 }
111
113 }
115
116 return Status;
117}
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:25
_In_ NDIS_STATUS EventCode
Definition: ndis.h:4751
#define FSRTL_VOLUME_UNLOCK
Definition: ntifs_ex.h:443
#define FSRTL_VOLUME_LOCK
Definition: ntifs_ex.h:441
#define FSRTL_VOLUME_DISMOUNT_FAILED
Definition: ntifs_ex.h:440
#define FSRTL_VOLUME_DISMOUNT
Definition: ntifs_ex.h:439
#define FSRTL_VOLUME_MOUNT
Definition: ntifs_ex.h:444
#define FSRTL_VOLUME_LOCK_FAILED
Definition: ntifs_ex.h:442
NTSTATUS NTAPI FsRtlNotifyVolumeEvent(IN PFILE_OBJECT FileObject, IN ULONG EventCode)
Definition: pnp.c:38
NTSTATUS NTAPI IoGetRelatedTargetDevice(IN PFILE_OBJECT FileObject, OUT PDEVICE_OBJECT *DeviceObject)
Definition: device.c:1607
NTSTATUS NTAPI IoReportTargetDeviceChange(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure)
Definition: pnpreport.c:448
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
Definition: pnpreport.c:498
GUID * LPGUID
Definition: guiddef.h:81
#define STATUS_SUCCESS
Definition: shellext.h:65
#define NTAPI
Definition: typedefs.h:36
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_In_ PWDFDEVICE_INIT _In_ PFN_WDF_DEVICE_SHUTDOWN_NOTIFICATION Notification
Definition: wdfcontrol.h:115
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
Definition: wdfdevice.h:550
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
Definition: wdfobject.h:762
* PFILE_OBJECT
Definition: iotypes.h:1998
struct _TARGET_DEVICE_CUSTOM_NOTIFICATION TARGET_DEVICE_CUSTOM_NOTIFICATION
#define ObDereferenceObject
Definition: obfuncs.h:203