ReactOS 0.4.15-dev-8116-gf69e256
FxFileObject Class Reference

#include <fxfileobject.hpp>

Inheritance diagram for FxFileObject:
Collaboration diagram for FxFileObject:

Public Member Functions

 FxFileObject (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in MdFileObject pWdmFileObject, __in FxDevice *Device)
 
virtual ~FxFileObject ()
 
__inline WDFFILEOBJECT GetHandle (VOID)
 
__inline MdFileObject GetWdmFileObject (VOID)
 
__inline CfxDeviceGetDevice (VOID)
 
__inline PUNICODE_STRING GetFileName (VOID)
 
__inline PLARGE_INTEGER GetCurrentByteOffset (VOID)
 
__inline ULONG GetFlags (VOID)
 
__inline VOID SetPkgCleanupCloseContext (PVOID Context)
 
__inline PVOID GetPkgCleanupCloseContext (VOID)
 
VOID Initialize (_In_ MdIrp CreateIrp)
 
VOID DeleteFileObjectFromFailedCreate (VOID)
 
_Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID GetConstraints (__in WDF_EXECUTION_LEVEL *ExecutionLevel, __in WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
 
_Must_inspect_result_ FxCallbackLockGetCallbackLockPtr (__deref_out_opt FxObject **LockObject)
 
_Must_inspect_result_ NTSTATUS UpdateProcessKeepAliveCount (_In_ BOOLEAN Increment)
 
FxFileObjectGetRelatedFileObject (VOID)
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 
- Public Member Functions inherited from IFxHasCallbacks
virtual VOID GetConstraints (__out WDF_EXECUTION_LEVEL *ExecutionLevel, __out WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)=0
 
virtual _Must_inspect_result_ FxCallbackLockGetCallbackLockPtr (__out_opt FxObject **LockObject)=0
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _CreateFileObject (__in FxDevice *pDevice, __in MdIrp Irp, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt PWDF_OBJECT_ATTRIBUTES pObjectAttributes, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
 
static VOID _DestroyFileObject (__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject)
 
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm (__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Public Attributes

LIST_ENTRY m_Link
 

Private Member Functions

VOID SetFileObjectContext (_In_ MdFileObject WdmFileObject, _In_ WDF_FILEOBJECT_CLASS NormalizedFileClass, _In_ MdIrp Irp, _In_ FxDevice *Device)
 

Private Attributes

MxFileObject m_FileObject
 
PVOID m_PkgContext
 
UNICODE_STRING m_FileName
 
FxFileObjectm_RelatedFileObject
 

Additional Inherited Members

- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Detailed Description

Definition at line 29 of file fxfileobject.hpp.

Constructor & Destructor Documentation

◆ FxFileObject()

FxFileObject::FxFileObject ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in MdFileObject  pWdmFileObject,
__in FxDevice Device 
)

Definition at line 38 of file fxfileobject.cpp.

42 :
43 FxNonPagedObject(FX_TYPE_FILEOBJECT, sizeof(FxFileObject), FxDriverGlobals)
44{
45 m_FileObject.SetFileObject(pWdmFileObject);
48
49#if (FX_CORE_MODE == FX_CORE_USER_MODE)
52#endif
53
54 //
55 // Cannot be deleted by the device driver
56 //
58}
UNICODE_STRING m_FileName
PVOID m_PkgContext
MxFileObject m_FileObject
FxFileObject * m_RelatedFileObject
CfxDevice * m_Device
Definition: fxobject.hpp:329
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
__inline VOID SetFileObject(_In_ MdFileObject FileObject)
Definition: mxfileobject.h:36
#define NULL
Definition: types.h:112
FxDevice * pDevice
@ FX_TYPE_FILEOBJECT
Definition: fxtypes.h:71
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

◆ ~FxFileObject()

FxFileObject::~FxFileObject ( )
virtual

Definition at line 60 of file fxfileobject.cpp.

61{
62#if (FX_CORE_MODE == FX_CORE_USER_MODE)
64#endif
65}
#define SAFE_RELEASE(p)

Member Function Documentation

◆ _CreateFileObject()

_Must_inspect_result_ NTSTATUS FxFileObject::_CreateFileObject ( __in FxDevice pDevice,
__in MdIrp  Irp,
__in WDF_FILEOBJECT_CLASS  FileObjectClass,
__in_opt PWDF_OBJECT_ATTRIBUTES  pObjectAttributes,
__in_opt MdFileObject  pWdmFileObject,
__deref_out_opt FxFileObject **  ppFxFileObject 
)
static

Definition at line 72 of file fxfileobject.cpp.

80{
83 KIRQL irql;
85
86 PFX_DRIVER_GLOBALS FxDriverGlobals = pDevice->GetDriverGlobals();
87
88 //
89 // Create does require a WDM file obj based on the normalized file obj
90 // class value.
91 //
93
94 //
95 // No FileObject support
96 //
98 if( pFileObject != NULL ) *pFileObject = NULL;
99 return STATUS_SUCCESS;
100 }
101
102 //
103 // If fileobject support was specified, and a NULL
104 // WDM PFILE_OBJECT is supplied, then it's an error
105 //
106 if( pWdmFileObject == NULL ) {
107
108 //
109 // Seems like some filter driver above us sending a create without fileobject.
110 // We support this only if the FileObjectClass class is set to
111 // WdfFileObjectWdfCannotUseFsContexts and device is created to be
112 // exclusive.
113 //
115 pDevice->IsExclusive() ) {
116
117 DO_NOTHING();
118
119 } else {
121 "WdfFileObjectWdfCanUseFsContexts is specified, but the Create "
122 "IRP %p doesn't have a fileObject\n",
123 Irp);
126 }
127
128 }
129
130 // Allocate a new FxFileObject with context
131 pfo = new(pDevice->GetDriverGlobals(), pObjectAttributes)
132 FxFileObject(pDevice->GetDriverGlobals(), pWdmFileObject, pDevice);
133
134 if( pfo == NULL ) {
136 }
137
138 pfo->Initialize(Irp);
139
140 // Assign FxDevice as the parent for the file object
141 Status = pfo->Commit(pObjectAttributes, NULL, pDevice);
142 if( !NT_SUCCESS(Status) ) {
143 pfo->DeleteFromFailedCreate();
144 return Status;
145 }
146
147 //
148 // Place it on the list of FxFileObject's for this FxDevice
149 //
150 pDevice->Lock(&irql);
153
154 //
155 // Set file object context in mode-specific manner
156 //
157 pfo->SetFileObjectContext(pWdmFileObject,
159 Irp,
160 pDevice);
161
162 // FxFileObject* to caller
163 if( pFileObject != NULL ) {
164 *pFileObject = pfo;
165 }
166
167 return STATUS_SUCCESS;
168}
LONG NTSTATUS
Definition: precomp.h:26
__inline BOOLEAN IsExclusive(VOID)
Definition: fxdevice.hpp:1218
LIST_ENTRY m_FileObjectListHead
Definition: fxdevice.hpp:643
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
_In_ PIRP Irp
Definition: csq.h:116
#define TRACINGIO
Definition: dbgtrace.h:66
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
KIRQL irql
Definition: wave.h:1
#define InsertHeadList(ListHead, Entry)
UCHAR KIRQL
Definition: env_spec_w32.h:591
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
WDF_FILEOBJECT_CLASS normalizedFileClass
WDF_FILEOBJECT_CLASS __inline FxFileObjectClassNormalize(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:103
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Status
Definition: gdiplustypes.h:25
#define DO_NOTHING()
Definition: mxgeneral.h:32
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
@ WdfFileObjectNotRequired
Definition: wdfdevice.h:460
@ WdfFileObjectWdfCannotUseFsContexts
Definition: wdfdevice.h:463
_In_opt_ FONTOBJ * pfo
Definition: winddi.h:3603

Referenced by FxPkgGeneral::OnCreate().

◆ _DestroyFileObject()

VOID FxFileObject::_DestroyFileObject ( __in FxDevice pDevice,
__in WDF_FILEOBJECT_CLASS  FileObjectClass,
__in_opt MdFileObject  pWdmFileObject 
)
static

Definition at line 175 of file fxfileobject.cpp.

180{
182 PFX_DRIVER_GLOBALS FxDriverGlobals = pDevice->GetDriverGlobals();
184
185 //
186 // Close does require a WDM file obj based on the normalized file obj
187 // class value.
188 //
190
192 return;
193 }
194
195 //
196 // Driver has specified file object support, and we
197 // allocated one at Create, so they must pass one
198 // to close, otherwise it's an error and we will leak
199 // the file object.
200 //
201 MxFileObject wdmFileObject(pWdmFileObject);
202 if( pWdmFileObject == NULL &&
204
205 //
206 // It's likely that IRP_MJ_CREATE had NULL for the Wdm FileObject as well.
207 //
208 // If a driver passes != NULL for Wdm FileObject to create, and NULL to
209 // this routine, a WDF FxFileObject object leak will occur, which will
210 // be reported at driver unload.
211 //
213 "PFILE_OBJECT in close IRP is NULL, *Possible Leak of FxFileObject*\n");
214
216
217 return;
218 }
220 pfo = (FxFileObject*)wdmFileObject.GetFsContext();
221 wdmFileObject.SetFsContext(NULL);
222
223 }
225 pfo = (FxFileObject*)wdmFileObject.GetFsContext2();
226 wdmFileObject.SetFsContext2(NULL);
227 }
228 else {
230 //
231 // We must find the associated FxFileObject from the list
232 // on the device
233 //
235 pDevice,
237 pWdmFileObject,
238 &pfo
239 );
240
241 //
242 // We should find it, unless a different one was passed to IRP_MJ_CLOSE
243 // than to IRP_MJ_CREATE, which is an error.
244 //
245 if (NT_SUCCESS(status) == FALSE || pfo == NULL) {
247 "Could not find WDFFILEOBJECT for PFILE_OBJECT 0x%p",
248 pWdmFileObject);
249
251 "Did a different PFILE_OBJECT get passed to "
252 "IRP_MJ_CLOSE than did to IRP_MJ_CREATE?");
254 }
255 }
256
257 if( pfo != NULL ) {
258 KIRQL irql;
259
260 //
261 // Remove it from the list of FxFileObjects on the FxDevice
262 //
263 pDevice->Lock(&irql);
264 RemoveEntryList(&pfo->m_Link);
266
267 // Delete the file object
268 pfo->DeleteObject();
269 }
270
271 return;
272}
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define FALSE
Definition: types.h:117
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
@ WdfFileObjectWdfCanUseFsContext
Definition: wdfdevice.h:461
@ WdfFileObjectWdfCanUseFsContext2
Definition: wdfdevice.h:462

Referenced by FxPkgGeneral::CreateCompleted(), and FxPkgGeneral::OnClose().

◆ _GetFileObjectFromWdm()

_Must_inspect_result_ NTSTATUS FxFileObject::_GetFileObjectFromWdm ( __in FxDevice pDevice,
__in WDF_FILEOBJECT_CLASS  FileObjectClass,
__in_opt MdFileObject  pWdmFileObject,
__deref_out_opt FxFileObject **  ppFxFileObject 
)
static

Definition at line 279 of file fxfileobject.cpp.

285{
287 PFX_DRIVER_GLOBALS FxDriverGlobals = pDevice->GetDriverGlobals();
289
290 //
291 // Normalize file object class value.
292 //
294
295 //
296 // No FileObject support
297 //
299 *ppFxFileObject = NULL;
300 return STATUS_SUCCESS;
301 }
302
303 if( pWdmFileObject == NULL ) {
304
305 //
306 // Warn if an I/O request has NULL for the WDM PFILE_OBJECT
307 //
308 if ( pDevice->IsExclusive() &&
310 //
311 // We allow a NULL file object iff the device is exclusive and
312 // we have to look up the WDFFILEOBJECT by PFILE_OBJECT value
313 //
314 DO_NOTHING();
315 }
316 else if ( FxIsFileObjectOptional(FileObjectClass) ) {
317 //
318 // Driver told us that it's able to handle this case.
319 //
320 *ppFxFileObject = NULL;
321 return STATUS_SUCCESS;
322 }
323 else {
325 "NULL passed for PFILE_OBJECT when FileObject "
326 "support is requested in an I/O request");
328
329 return STATUS_UNSUCCESSFUL;
330 }
331 }
332
333 //
334 // Depending on the drivers configuration, we can quickly
335 // get the FxFileObject* from FxContext, or FxContext2.
336 //
337 // Some drivers can not touch either of the FxContext(s), and
338 // in that case we must resort to a list or hashtable.
339 //
340 MxFileObject wdmFileObject(pWdmFileObject);
342 pfo = (FxFileObject*)wdmFileObject.GetFsContext();
343 }
345 pfo = (FxFileObject*)wdmFileObject.GetFsContext2();
346 }
347 else {
350 KIRQL irql;
351
352 //
353 // Must look it up from the FxDevice->m_FileObjectListHead.
354 //
355 pfo = NULL;
356
357 pDevice->Lock(&irql);
358
360
361 if(pWdmFileObject == NULL) {
362 //
363 // If the pWdmFileObject is NULL then we will pass the first entry
364 // in the list because the device must be exclusive and there
365 // can be only one fileobject in the list.
366 //
368
370 pfo = f;
371
372 } else {
373
374 while( next != &pDevice->m_FileObjectListHead ) {
376
377 if( f->m_FileObject.GetFileObject()== pWdmFileObject ) {
378 pfo = f;
379 break;
380 }
381
382 next = next->Flink;
383 }
384 }
385
386
387
388
389
390
391
392
393
394
395 if(pfo == NULL
396 && pDevice->IsExclusive()
399
402 pfo = f;
403
405 "The PFILE_OBJECT 0x%p in this request (cleanup/close) "
406 "is different from the one specified in "
407 "create request 0x%p.This is bad!", pWdmFileObject,
408 ((f != NULL) ? f->m_FileObject.GetFileObject(): NULL));
410 "Since this is a serial port device, framework is "
411 "using a workaround to allow this");
412 }
413
415 }
416
417 //
418 // This can happen if a different PFILE_OBJECT is passed to an I/O
419 // request than was presented to IRP_MJ_CREATE
420 //
421 if (pfo == NULL && FxIsFileObjectOptional(FileObjectClass) == FALSE) {
422
424 "Could not locate WDFFILEOBJECT for "
425 "PFILE_OBJECT 0x%p",pWdmFileObject);
426
428 "Did a different PFILE_OBJECT get passed to the "
429 "request than was to IRP_MJ_CREATE?");
430
431
432
433
434
435
436
437
438
439
440 if (FxDriverGlobals->IsVersionGreaterThanOrEqualTo(1,9)) {
442 }
443 }
444
445 //
446 // We don't do an extra reference count since the file objects
447 // lifetime is controlled by the IoMgr. When the IRP_MJ_CLOSE
448 // occurs, the reference is released after the optional
449 // driver event callback.
450 //
451
452 *ppFxFileObject = pfo;
453
454 return STATUS_SUCCESS;
455}
__inline MxDeviceObject * GetMxDeviceObject(VOID)
Definition: fxdevice.hpp:183
LIST_ENTRY m_Link
DEVICE_TYPE GetDeviceType(VOID)
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
BOOLEAN __inline FxIsFileObjectOptional(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:112
GLfloat f
Definition: glext.h:7540
#define f
Definition: ke_i.h:83
#define ASSERT(a)
Definition: mode.c:44
#define FILE_DEVICE_SERIAL_PORT
Definition: serial.c:44
static unsigned __int64 next
Definition: rand_nt.c:6
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by _DestroyFileObject(), FxRequest::GetFileObject(), FxPkgGeneral::OnCleanup(), and FxPkgGeneral::OnClose().

◆ DeleteFileObjectFromFailedCreate()

VOID FxFileObject::DeleteFileObjectFromFailedCreate ( VOID  )

Definition at line 458 of file fxfileobject.cpp.

461{
462 KIRQL irql;
463
464 //
465 // Remove it from the list of FxFileObjects on the FxDevice
466 //
467 m_Device->Lock(&irql);
470
471 // Delete the file object
473}
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391

Referenced by FxPkgGeneral::OnCreate().

◆ GetCallbackLockPtr()

_Must_inspect_result_ FxCallbackLock * FxFileObject::GetCallbackLockPtr ( __deref_out_opt FxObject **  LockObject)

Definition at line 541 of file fxfileobject.cpp.

558{
559 //
560 // Get it from FxPkgGeneral which has the File attributes passed to it at device Creation time.
561 //
562 return GetDevice()->m_PkgGeneral->GetCallbackLockPtrHelper(LockObject);
563}
return pList GetDevice()
#define LockObject(Object)
Definition: titypes.h:34

◆ GetConstraints()

VOID FxFileObject::GetConstraints ( __in WDF_EXECUTION_LEVEL ExecutionLevel,
__in WDF_SYNCHRONIZATION_SCOPE SynchronizationScope 
)

Definition at line 511 of file fxfileobject.cpp.

532{
533 //
534 // Get it from FxPkgGeneral which has the File attributes passed to it at device Creation time.
535 //
536 return GetDevice()->m_PkgGeneral->GetConstraintsHelper(ExecutionLevel, SynchronizationScope);
537}

◆ GetCurrentByteOffset()

__inline PLARGE_INTEGER FxFileObject::GetCurrentByteOffset ( VOID  )
inline

Definition at line 121 of file fxfileobject.hpp.

124 {
126 }
PLARGE_INTEGER GetCurrentByteOffset(VOID)

◆ GetDevice()

__inline CfxDevice * FxFileObject::GetDevice ( VOID  )
inline

Definition at line 99 of file fxfileobject.hpp.

102 {
103 return m_Device;
104 }

◆ GetFileName()

__inline PUNICODE_STRING FxFileObject::GetFileName ( VOID  )
inline

Definition at line 108 of file fxfileobject.hpp.

111 {
112 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
114 #else
116 #endif
117 }
PUNICODE_STRING GetFileName(_Inout_opt_ PUNICODE_STRING Filename)

Referenced by if().

◆ GetFlags()

__inline ULONG FxFileObject::GetFlags ( VOID  )
inline

Definition at line 130 of file fxfileobject.hpp.

133 {
134 return m_FileObject.GetFlags();
135 }
ULONG GetFlags(VOID)

◆ GetHandle()

__inline WDFFILEOBJECT FxFileObject::GetHandle ( VOID  )
inline

Definition at line 81 of file fxfileobject.hpp.

84 {
85 return (WDFFILEOBJECT) GetObjectHandle();
86 }
return pObject GetObjectHandle()

Referenced by if(), FxPkgGeneral::OnCleanup(), FxPkgGeneral::OnClose(), and FxPkgGeneral::OnCreate().

◆ GetPkgCleanupCloseContext()

__inline PVOID FxFileObject::GetPkgCleanupCloseContext ( VOID  )
inline

Definition at line 148 of file fxfileobject.hpp.

151 {
152 return m_PkgContext;
153 }

Referenced by FxPkgGeneral::OnCleanup(), and FxPkgGeneral::OnClose().

◆ GetRelatedFileObject()

FxFileObject * FxFileObject::GetRelatedFileObject ( VOID  )
inline

Definition at line 243 of file fxfileobject.hpp.

246 {
247 return m_RelatedFileObject;
248 }

◆ GetWdmFileObject()

__inline MdFileObject FxFileObject::GetWdmFileObject ( VOID  )
inline

Definition at line 90 of file fxfileobject.hpp.

93 {
95 }
__inline MdFileObject GetFileObject(VOID)
Definition: mxfileobject.h:45

Referenced by if().

◆ Initialize()

VOID FxFileObject::Initialize ( _In_ MdIrp  CreateIrp)

Definition at line 69 of file fxfileobjectkm.cpp.

72{
73 UNREFERENCED_PARAMETER(CreateIrp);
74
75 //
76 // Not needed for KMDF.
77 //
78 DO_NOTHING();
79
80 return;
81}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ QueryInterface()

_Must_inspect_result_ NTSTATUS FxFileObject::QueryInterface ( __in FxQueryInterfaceParams Params)
virtual

Reimplemented from FxObject.

Definition at line 477 of file fxfileobject.cpp.

493{
494 switch (Params->Type) {
496 *Params->Object = (FxFileObject*) this;
497 break;
498
500 *Params->Object = (IFxHasCallbacks*) this;
501 break;
502
503 default:
504 return FxNonPagedObject::QueryInterface(Params); // __super call
505 }
506
507 return STATUS_SUCCESS;
508}
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
@ FX_TYPE_IHASCALLBACKS
Definition: fxtypes.h:114
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:308

◆ SetFileObjectContext()

VOID FxFileObject::SetFileObjectContext ( _In_ MdFileObject  WdmFileObject,
_In_ WDF_FILEOBJECT_CLASS  NormalizedFileClass,
_In_ MdIrp  Irp,
_In_ FxDevice Device 
)
private

Definition at line 34 of file fxfileobjectkm.cpp.

40{
41 MxFileObject wdmFileObject(WdmFileObject);
42
45
46 //
47 // We now must be able to quickly retrieve the FxFileObject*
48 // from the WDM PFILE_OBJECT when we get I/O requests.
49 //
50 // But different driver stacks have different rules, so
51 // we must be flexible here, including not touching the
52 // WDM PFILE_OBJECT at all.
53 //
54 if( NormalizedFileClass == WdfFileObjectWdfCanUseFsContext ) {
55 wdmFileObject.SetFsContext(this);
56 }
57 else if( NormalizedFileClass == WdfFileObjectWdfCanUseFsContext2 ) {
58 wdmFileObject.SetFsContext2(this);
59 }
60 else {
61 //
62 // WdfDeviceFileObjectNoContext will look up the FxFileObject
63 // from the FxDevice->m_FileObjectListHead at runtime.
64 //
65 }
66}
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474

◆ SetPkgCleanupCloseContext()

__inline VOID FxFileObject::SetPkgCleanupCloseContext ( PVOID  Context)
inline

Definition at line 139 of file fxfileobject.hpp.

142 {
144 }

Referenced by FxPkgGeneral::OnCreate().

◆ UpdateProcessKeepAliveCount()

_Must_inspect_result_ NTSTATUS FxFileObject::UpdateProcessKeepAliveCount ( _In_ BOOLEAN  Increment)

Definition at line 85 of file fxfileobjectkm.cpp.

88{
90
91 //
92 // Not needed for KMDF.
93 //
94 DO_NOTHING();
95
97}
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:46
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

Member Data Documentation

◆ m_FileName

UNICODE_STRING FxFileObject::m_FileName
private

Definition at line 44 of file fxfileobject.hpp.

Referenced by FxFileObject(), and GetFileName().

◆ m_FileObject

MxFileObject FxFileObject::m_FileObject
private

◆ m_Link

LIST_ENTRY FxFileObject::m_Link

Definition at line 56 of file fxfileobject.hpp.

Referenced by _GetFileObjectFromWdm(), and DeleteFileObjectFromFailedCreate().

◆ m_PkgContext

PVOID FxFileObject::m_PkgContext
private

◆ m_RelatedFileObject

FxFileObject* FxFileObject::m_RelatedFileObject
private

Definition at line 49 of file fxfileobject.hpp.

Referenced by FxFileObject(), GetRelatedFileObject(), and ~FxFileObject().


The documentation for this class was generated from the following files: