ReactOS  0.4.15-dev-2344-g8ddbfde
FxDisposeList Class Reference

#include <fxdisposelist.hpp>

Inheritance diagram for FxDisposeList:
Collaboration diagram for FxDisposeList:

Public Member Functions

 FxDisposeList (PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 ~FxDisposeList ()
 
NTSTATUS Initialize (PVOID wdmObject)
 
VOID Add (FxObject *object)
 
VOID WaitForEmpty (VOID)
 
 DECLARE_INTERNAL_NEW_OPERATOR ()
 
- 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)
 
_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)
 

Static Public Member Functions

static NTSTATUS _Create (PFX_DRIVER_GLOBALS FxDriverGlobals, PVOID WdmObject, FxDisposeList **pObject)
 
- 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)
 

Private Member Functions

VOID DrainListLocked (PKIRQL PreviousIrql)
 
virtual BOOLEAN Dispose (VOID)
 

Static Private Member Functions

static VOID _WorkItemThunk (__in PVOID Parameter)
 

Private Attributes

SINGLE_LIST_ENTRY m_List
 
SINGLE_LIST_ENTRY ** m_ListEnd
 
MxThread m_WorkItemThread
 
FxSystemWorkItemm_SystemWorkItem
 
PVOID m_WdmObject
 

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 51 of file fxdisposelist.hpp.

Constructor & Destructor Documentation

◆ FxDisposeList()

FxDisposeList::FxDisposeList ( PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 41 of file fxdisposelist.cpp.

43  :
44  FxNonPagedObject(FX_TYPE_DISPOSELIST, 0, FxDriverGlobals)
45 {
46  m_List.Next = NULL;
48 
51 }
FxNonPagedObject(__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
SINGLE_LIST_ENTRY m_List
FxSystemWorkItem * m_SystemWorkItem
SINGLE_LIST_ENTRY ** m_ListEnd
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
#define NULL
Definition: types.h:112
MxThread m_WorkItemThread

Referenced by _Create().

◆ ~FxDisposeList()

FxDisposeList::~FxDisposeList ( )

Definition at line 53 of file fxdisposelist.cpp.

54 {
55  ASSERT(m_List.Next == NULL);
56 }
SINGLE_LIST_ENTRY m_List
#define ASSERT(a)
Definition: mode.c:45
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
#define NULL
Definition: types.h:112

Member Function Documentation

◆ _Create()

NTSTATUS FxDisposeList::_Create ( PFX_DRIVER_GLOBALS  FxDriverGlobals,
PVOID  WdmObject,
FxDisposeList **  pObject 
)
static

Definition at line 59 of file fxdisposelist.cpp.

64 {
67 
68  *pObject = NULL;
69 
70  list = new(FxDriverGlobals) FxDisposeList(FxDriverGlobals);
71 
72  if (list == NULL) {
74  }
75 
76  status = list->Initialize(WdmObject);
77 
78  if (NT_SUCCESS(status)) {
79  *pObject = list;
80  }
81  else {
82  list->DeleteFromFailedCreate();
83  }
84 
85  return status;
86 }
FxObject * pObject
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
FxDisposeList(PFX_DRIVER_GLOBALS FxDriverGlobals)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Definition: _list.h:228
#define list
Definition: rosglue.h:35
#define NULL
Definition: types.h:112
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxDriver::Initialize(), and FxDevice::PostInitialize().

◆ _WorkItemThunk()

VOID FxDisposeList::_WorkItemThunk ( __in PVOID  Parameter)
staticprivate

Definition at line 238 of file fxdisposelist.cpp.

241 {
242  FxDisposeList* pThis;
243  KIRQL irql;
244 
245  pThis = (FxDisposeList*) Parameter;
246 
247  pThis->Lock(&irql);
248 
249  pThis->DrainListLocked(&irql);
250 
251  pThis->Unlock(irql);
252 }
KIRQL irql
Definition: wave.h:1
_In_ PVOID Parameter
Definition: ldrtypes.h:241
UCHAR KIRQL
Definition: env_spec_w32.h:591
VOID DrainListLocked(PKIRQL PreviousIrql)

Referenced by Add().

◆ Add()

VOID FxDisposeList::Add ( FxObject object)

Definition at line 130 of file fxdisposelist.cpp.

159 {
160  KIRQL irql;
161  BOOLEAN previouslyEmpty;
162 
163  Lock(&irql);
164 
165  ASSERT(Object->m_DisposeSingleEntry.Next == NULL);
166 
167  previouslyEmpty = m_List.Next == NULL ? TRUE : FALSE;
168 
169  //
170  // Add to the end of m_List
171  //
172  *m_ListEnd = &Object->m_DisposeSingleEntry;
173 
174  //
175  // Update the end
176  //
177  m_ListEnd = &Object->m_DisposeSingleEntry.Next;
178 
179  if (previouslyEmpty) {
181  }
182 
183  Unlock(irql);
184 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
static VOID _WorkItemThunk(__in PVOID Parameter)
#define TRUE
Definition: types.h:120
SINGLE_LIST_ENTRY m_List
KIRQL irql
Definition: wave.h:1
__inline BOOLEAN TryToEnqueue(__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
FxSystemWorkItem * m_SystemWorkItem
SINGLE_LIST_ENTRY ** m_ListEnd
unsigned char BOOLEAN
#define ASSERT(a)
Definition: mode.c:45
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124

Referenced by FxDeviceBase::AddToDisposeList(), FxObject::FinalRelease(), and FxObject::QueueDeferredDisposeLocked().

◆ DECLARE_INTERNAL_NEW_OPERATOR()

FxDisposeList::DECLARE_INTERNAL_NEW_OPERATOR ( )

◆ Dispose()

BOOLEAN FxDisposeList::Dispose ( VOID  )
privatevirtual

Reimplemented from FxObject.

Definition at line 114 of file fxdisposelist.cpp.

116 {
117  if (m_SystemWorkItem != NULL) {
120  }
121 
122  ASSERT(m_List.Next == NULL);
123 
124  FxNonPagedObject::Dispose(); // __super call
125 
126  return TRUE;
127 }
virtual VOID DeleteObject(VOID)
#define TRUE
Definition: types.h:120
SINGLE_LIST_ENTRY m_List
FxSystemWorkItem * m_SystemWorkItem
#define ASSERT(a)
Definition: mode.c:45
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
#define NULL
Definition: types.h:112
virtual BOOLEAN Dispose(VOID)

◆ DrainListLocked()

VOID FxDisposeList::DrainListLocked ( PKIRQL  PreviousIrql)
private

Definition at line 187 of file fxdisposelist.cpp.

190 {
191  FxObject* pObject;
193 
194  //
195  // Process items on the list until it is empty
196  //
197  while (m_List.Next != NULL) {
198  pEntry = m_List.Next;
199 
200  //
201  // Remove pEntry from the list
202  //
203  m_List.Next = pEntry->Next;
204 
205  //
206  // Indicate pEntry is no longer in the list
207  //
208  pEntry->Next = NULL;
209 
210  //
211  // Convert back to the object
212  //
214 
215  //
216  // If the list is empty, we just popped off the entry and we need to
217  // update m_ListEnd to a head of the list so it points to valid pool.
218  //
219  if (m_List.Next == NULL) {
220  m_ListEnd = &m_List.Next;
221  }
222 
223  Unlock(*PreviousIrql);
224 
225  //
226  // Invoke the objects deferred dispose entry
227  //
229 
230  //
231  // pObject may be invalid at this point due to its dereferencing itself
232  //
233  Lock(PreviousIrql);
234  }
235 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
FxObject * pObject
Definition: ntbasedef.h:628
static FxObject * _FromDisposeEntry(__in PSINGLE_LIST_ENTRY Entry)
Definition: fxobject.hpp:580
SINGLE_LIST_ENTRY m_List
VOID DeferredDisposeWorkItem(VOID)
SINGLE_LIST_ENTRY ** m_ListEnd
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484

Referenced by _WorkItemThunk(), and WaitForEmpty().

◆ Initialize()

NTSTATUS FxDisposeList::Initialize ( PVOID  wdmObject)

Definition at line 89 of file fxdisposelist.cpp.

92 {
94  PFX_DRIVER_GLOBALS FxDriverGlobals = GetDriverGlobals();
95 
97 
98  status = FxSystemWorkItem::_Create(FxDriverGlobals,
99  WdmObject,
101  );
102  if (!NT_SUCCESS(status)) {
104  "Could not allocate workitem: %!STATUS!", status);
105  return status;
106  }
107 
108  m_WdmObject = WdmObject;
109 
110  return STATUS_SUCCESS;
111 }
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID WdmObject, __out FxSystemWorkItem **pObject)
LONG NTSTATUS
Definition: precomp.h:26
FxSystemWorkItem * m_SystemWorkItem
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#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 STATUS_SUCCESS
Definition: shellext.h:65
#define TRACINGIO
Definition: dbgtrace.h:66
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ WaitForEmpty()

VOID FxDisposeList::WaitForEmpty ( VOID  )

Definition at line 255 of file fxdisposelist.cpp.

276 {
277  KIRQL irql;
278  BOOLEAN wait;
279 
280  Lock(&irql);
281 
282  wait = TRUE;
283 
285 
286 
287 
288 
289 
290 
291 
292  ASSERT(FALSE);
294  wait = FALSE;
295  }
296 
297  Unlock(irql);
298 
299  if (wait) {
301  }
302 
303  // Should only be true for an empty list
304  ASSERT(m_List.Next == NULL);
305 }
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
#define TRUE
Definition: types.h:120
SINGLE_LIST_ENTRY m_List
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
FxSystemWorkItem * m_SystemWorkItem
unsigned char BOOLEAN
#define ASSERT(a)
Definition: mode.c:45
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:629
VOID DrainListLocked(PKIRQL PreviousIrql)
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:124
MxThread m_WorkItemThread

Referenced by FxDevice::DeleteDeviceFromFailedCreateNoDelete(), FxDriver::Dispose(), FxDevice::Dispose(), FxMpDevice::Dispose(), and FxPkgPnp::PnpEventRemovedCommonCode().

Member Data Documentation

◆ m_List

SINGLE_LIST_ENTRY FxDisposeList::m_List
private

◆ m_ListEnd

SINGLE_LIST_ENTRY** FxDisposeList::m_ListEnd
private

Definition at line 64 of file fxdisposelist.hpp.

Referenced by Add(), DrainListLocked(), and FxDisposeList().

◆ m_SystemWorkItem

FxSystemWorkItem* FxDisposeList::m_SystemWorkItem
private

Definition at line 73 of file fxdisposelist.hpp.

Referenced by Add(), Dispose(), FxDisposeList(), Initialize(), and WaitForEmpty().

◆ m_WdmObject

PVOID FxDisposeList::m_WdmObject
private

Definition at line 78 of file fxdisposelist.hpp.

Referenced by Initialize().

◆ m_WorkItemThread

MxThread FxDisposeList::m_WorkItemThread
private

Definition at line 71 of file fxdisposelist.hpp.

Referenced by FxDisposeList(), and WaitForEmpty().


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