ReactOS  0.4.15-dev-3308-g9455def
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)
 
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);
47  m_Device = pDevice;
48 
49 #if (FX_CORE_MODE == FX_CORE_USER_MODE)
52 #endif
53 
54  //
55  // Cannot be deleted by the device driver
56  //
58 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
__inline VOID SetFileObject(_In_ MdFileObject FileObject)
Definition: mxfileobject.h:36
FxFileObject * m_RelatedFileObject
UNICODE_STRING m_FileName
FxDevice * pDevice
VOID MarkNoDeleteDDI(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1118
MxFileObject m_FileObject
#define NULL
Definition: types.h:112
PVOID m_PkgContext
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)

Referenced by _CreateFileObject().

◆ ~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 }
FxFileObject * m_RelatedFileObject
#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);
152  pDevice->Unlock(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 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
LONG NTSTATUS
Definition: precomp.h:26
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
FxFileObject(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in MdFileObject pWdmFileObject, __in FxDevice *Device)
_In_ PIRP Irp
Definition: csq.h:116
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
FxDevice * pDevice
Status
Definition: gdiplustypes.h:24
_In_opt_ FONTOBJ * pfo
Definition: winddi.h:3603
LIST_ENTRY m_FileObjectListHead
Definition: fxdevice.hpp:643
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WDF_FILEOBJECT_CLASS __inline FxFileObjectClassNormalize(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:103
WDF_FILEOBJECT_CLASS normalizedFileClass
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
__inline BOOLEAN IsExclusive(VOID)
Definition: fxdevice.hpp:1218
#define STATUS_DEVICE_CONFIGURATION_ERROR
Definition: ntstatus.h:619
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define DO_NOTHING()
Definition: mxgeneral.h:32

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 {
181  FxFileObject* pfo = NULL;
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);
265  pDevice->Unlock(irql);
266 
267  // Delete the file object
268  pfo->DeleteObject();
269  }
270 
271  return;
272 }
LONG NTSTATUS
Definition: precomp.h:26
KIRQL irql
Definition: wave.h:1
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
FxDevice * pDevice
_In_opt_ FONTOBJ * pfo
Definition: winddi.h:3603
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
WDF_FILEOBJECT_CLASS __inline FxFileObjectClassNormalize(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:103
WDF_FILEOBJECT_CLASS normalizedFileClass
static _Must_inspect_result_ NTSTATUS _GetFileObjectFromWdm(__in FxDevice *pDevice, __in WDF_FILEOBJECT_CLASS FileObjectClass, __in_opt MdFileObject pWdmFileObject, __deref_out_opt FxFileObject **ppFxFileObject)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define TRACINGIO
Definition: dbgtrace.h:66
static SERVICE_STATUS status
Definition: service.c:31
FxVerifierDbgBreakPoint(pFxDriverGlobals)
virtual VOID DeleteObject(VOID)
Definition: fxdevice.cpp:1135
Definition: ps.c:97

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 {
286  FxFileObject* pfo = NULL;
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 {
349  FxFileObject* f;
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 
414  pDevice->Unlock(irql);
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
KIRQL irql
Definition: wave.h:1
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
enum _WDF_FILEOBJECT_CLASS WDF_FILEOBJECT_CLASS
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
FxDevice * pDevice
LIST_ENTRY m_Link
_In_opt_ FONTOBJ * pfo
Definition: winddi.h:3603
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
LIST_ENTRY m_FileObjectListHead
Definition: fxdevice.hpp:643
GLfloat f
Definition: glext.h:7540
#define TRACINGDEVICE
Definition: dbgtrace.h:58
BOOLEAN __inline FxIsFileObjectOptional(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:112
#define ASSERT(a)
Definition: mode.c:44
WDF_FILEOBJECT_CLASS __inline FxFileObjectClassNormalize(__in WDF_FILEOBJECT_CLASS FileObjectClass)
Definition: fxdevice.hpp:103
WDF_FILEOBJECT_CLASS normalizedFileClass
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
DEVICE_TYPE GetDeviceType(VOID)
Definition: typedefs.h:119
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
static unsigned __int64 next
Definition: rand_nt.c:6
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define f
Definition: ke_i.h:83
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
#define STATUS_SUCCESS
Definition: shellext.h:65
__inline BOOLEAN IsExclusive(VOID)
Definition: fxdevice.hpp:1218
#define FILE_DEVICE_SERIAL_PORT
Definition: serial.c:44
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define DO_NOTHING()
Definition: mxgeneral.h:32

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);
469  m_Device->Unlock(irql);
470 
471  // Delete the file object
473 }
CfxDevice * m_Device
Definition: fxobject.hpp:329
KIRQL irql
Definition: wave.h:1
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
UCHAR KIRQL
Definition: env_spec_w32.h:591
LIST_ENTRY m_Link
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  //
563 }
FxCallbackLock * GetCallbackLockPtrHelper(__deref_out_opt FxObject **LockObject)
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
__inline CfxDevice * GetDevice(VOID)
#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 }
FxPkgGeneral * m_PkgGeneral
Definition: fxdevice.hpp:671
VOID GetConstraintsHelper(__out_opt WDF_EXECUTION_LEVEL *ExecutionLevel, __out_opt WDF_SYNCHRONIZATION_SCOPE *SynchronizationScope)
__inline CfxDevice * GetDevice(VOID)

◆ GetCurrentByteOffset()

__inline PLARGE_INTEGER FxFileObject::GetCurrentByteOffset ( VOID  )
inline

Definition at line 121 of file fxfileobject.hpp.

124  {
126  }
PLARGE_INTEGER GetCurrentByteOffset(VOID)
MxFileObject m_FileObject

◆ GetDevice()

__inline CfxDevice* FxFileObject::GetDevice ( VOID  )
inline

Definition at line 99 of file fxfileobject.hpp.

102  {
103  return m_Device;
104  }
CfxDevice * m_Device
Definition: fxobject.hpp:329

Referenced by GetCallbackLockPtr(), and GetConstraints().

◆ 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)
113  return m_FileObject.GetFileName(NULL);
114  #else
116  #endif
117  }
UNICODE_STRING m_FileName
MxFileObject m_FileObject
#define NULL
Definition: types.h:112
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)
MxFileObject m_FileObject

◆ GetHandle()

__inline WDFFILEOBJECT FxFileObject::GetHandle ( VOID  )
inline

Definition at line 81 of file fxfileobject.hpp.

84  {
85  return (WDFFILEOBJECT) GetObjectHandle();
86  }
PVOID __inline GetObjectHandle(VOID)
Definition: fxobject.hpp:603

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  }
PVOID m_PkgContext

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  }
FxFileObject * m_RelatedFileObject

◆ GetWdmFileObject()

__inline MdFileObject FxFileObject::GetWdmFileObject ( VOID  )
inline

Definition at line 90 of file fxfileobject.hpp.

93  {
94  return m_FileObject.GetFileObject();
95  }
__inline MdFileObject GetFileObject(VOID)
Definition: mxfileobject.h:45
MxFileObject m_FileObject

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
#define DO_NOTHING()
Definition: mxgeneral.h:32

◆ 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) {
495  case FX_TYPE_FILEOBJECT:
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 }
_In_ WDFIOTARGET _In_ PWDF_REQUEST_COMPLETION_PARAMS Params
Definition: wdfrequest.h:306
virtual _Must_inspect_result_ NTSTATUS QueryInterface(__in FxQueryInterfaceParams *Params)
Definition: fxobject.cpp:255
#define STATUS_SUCCESS
Definition: shellext.h:65

◆ 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 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
_In_ PIRP Irp
Definition: csq.h:116
_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  }
struct tagContext Context
Definition: acpixf.h:1034
PVOID m_PkgContext

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 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
return STATUS_NOT_IMPLEMENTED
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG Increment
Definition: CrNtStubs.h:42
#define DO_NOTHING()
Definition: mxgeneral.h:32

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: