ReactOS 0.4.16-dev-297-gc569aee
pnp.c File Reference
#include "cdprocs.h"
Include dependency graph for pnp.c:

Go to the source code of this file.

Macros

#define BugCheckFileId   (CDFS_BUG_CHECK_PNP)
 

Functions

 _Requires_lock_held_ (_Global_critical_region_)
 
NTSTATUS NTAPI CdPnpCompletionRoutine (_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_reads_opt_(_Inexpressible_("varies")) PVOID Contxt)
 

Macro Definition Documentation

◆ BugCheckFileId

#define BugCheckFileId   (CDFS_BUG_CHECK_PNP)

Definition at line 23 of file pnp.c.

Function Documentation

◆ _Requires_lock_held_()

_Requires_lock_held_ ( _Global_critical_region_  )

Definition at line 25 of file pnp.c.

104{
106 BOOLEAN PassThrough = FALSE;
107
109
110 PVOLUME_DEVICE_OBJECT OurDeviceObject;
111 PVCB Vcb;
112
113 PAGED_CODE();
114
115 // Global lock object is acquired based on internal book-keeping
117
118 //
119 // Get the current Irp stack location.
120 //
121
123
124 //
125 // Find our Vcb. This is tricky since we have no file object in the Irp.
126 //
127
128 OurDeviceObject = (PVOLUME_DEVICE_OBJECT) IrpSp->DeviceObject;
129
130 //
131 // IO holds a handle reference on our VDO and holds the device lock, which
132 // syncs us against mounts/verifies. However we hold no reference on the
133 // volume, which may already have been torn down (and the Vpb freed), for
134 // example by a force dismount. Check for this condition. We must hold this
135 // lock until the pnp worker functions take additional locks/refs on the Vcb.
136 //
137
138 CdAcquireCdData( IrpContext);
139
140 //
141 // Make sure this device object really is big enough to be a volume device
142 // object. If it isn't, we need to get out before we try to reference some
143 // field that takes us past the end of an ordinary device object.
144 //
145
146#ifdef _MSC_VER
147#pragma prefast(suppress: 28175, "this is a filesystem driver, touching the size member is allowed")
148#endif
149 if (OurDeviceObject->DeviceObject.Size != sizeof(VOLUME_DEVICE_OBJECT) ||
150 NodeType( &OurDeviceObject->Vcb ) != CDFS_NTC_VCB) {
151
152 //
153 // We were called with something we don't understand.
154 //
155
157 CdReleaseCdData( IrpContext);
158 CdCompleteRequest( IrpContext, Irp, Status );
159 return Status;
160 }
161
162 //
163 // Force all PnP operations to be synchronous.
164 //
165
166 SetFlag( IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT );
167
168 Vcb = &OurDeviceObject->Vcb;
169
170 //
171 // Check that the Vcb hasn't already been deleted. If so, just pass the
172 // request through to the driver below, we don't need to do anything.
173 //
174
175 if (NULL == Vcb->Vpb) {
176
177 PassThrough = TRUE;
178 }
179 else {
180
181 //
182 // Case on the minor code.
183 //
184
185 switch ( IrpSp->MinorFunction ) {
186
188
189 Status = CdPnpQueryRemove( IrpContext, Irp, Vcb );
190 break;
191
193
194 Status = CdPnpSurpriseRemove( IrpContext, Irp, Vcb );
195 break;
196
198
199 Status = CdPnpRemove( IrpContext, Irp, Vcb );
200 break;
201
203
204 Status = CdPnpCancelRemove( IrpContext, Irp, Vcb );
205 break;
206
207 default:
208
209 PassThrough = TRUE;
210 break;
211 }
212 }
213
214 if (PassThrough) {
215
216 CdReleaseCdData( IrpContext);
217
218 //
219 // Just pass the IRP on. As we do not need to be in the
220 // way on return, ellide ourselves out of the stack.
221 //
222
224
225 Status = IoCallDriver(Vcb->TargetDeviceObject, Irp);
226
227 //
228 // Cleanup our Irp Context. The driver has completed the Irp.
229 //
230
231 CdCompleteRequest( IrpContext, NULL, STATUS_SUCCESS );
232 }
233
234 return Status;
235}
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define PAGED_CODE()
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
VOID CdCompleteRequest(_Inout_opt_ PIRP_CONTEXT IrpContext, _Inout_opt_ PIRP Irp, _In_ NTSTATUS Status)
Definition: cddata.c:914
CD_DATA CdData
Definition: cddata.c:42
#define CdAcquireCdData(IC)
Definition: cdprocs.h:973
#define CdReleaseCdData(IC)
Definition: cdprocs.h:976
#define IRP_CONTEXT_FLAG_WAIT
Definition: cdstruc.h:1215
VOLUME_DEVICE_OBJECT * PVOLUME_DEVICE_OBJECT
Definition: cdstruc.h:769
#define _Analysis_suppress_lock_checking_(lock)
_In_ PIRP Irp
Definition: csq.h:116
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define CDFS_NTC_VCB
Definition: nodetype.h:28
#define NodeType(P)
Definition: nodetype.h:51
_In_ PIO_STACK_LOCATION IrpSp
Definition: create.c:4137
#define SetFlag(_F, _SF)
Definition: ext2fs.h:187
Status
Definition: gdiplustypes.h:25
#define IRP_MN_SURPRISE_REMOVAL
Definition: ntifs_ex.h:408
#define IoSkipCurrentIrpStackLocation(Irp)
Definition: ntifs_ex.h:421
#define IoCallDriver
Definition: irp.c:1225
#define Vcb
Definition: cdprocs.h:1415
#define STATUS_SUCCESS
Definition: shellext.h:65
ERESOURCE DataResource
Definition: cdstruc.h:402
PDEVICE_OBJECT DeviceObject
Definition: iotypes.h:3223
Definition: cdstruc.h:498
DEVICE_OBJECT DeviceObject
Definition: cdstruc.h:729
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE

◆ CdPnpCompletionRoutine()

NTSTATUS NTAPI CdPnpCompletionRoutine ( _In_ PDEVICE_OBJECT  DeviceObject,
_In_ PIRP  Irp,
_In_reads_opt_(_Inexpressible_("varies")) PVOID  Contxt 
)

Definition at line 819 of file pnp.c.

824{
825 PKEVENT Event = (PKEVENT) Contxt;
826 _Analysis_assume_(Contxt != NULL);
827
828 KeSetEvent( Event, 0, FALSE );
829
831
834 UNREFERENCED_PARAMETER( Contxt );
835}
#define PKEVENT
Definition: env_spec_w32.h:70
#define KeSetEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:476
#define _Analysis_assume_
Definition: no_sal2.h:388
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:325
#define STATUS_MORE_PROCESSING_REQUIRED
Definition: shellext.h:68
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055