ReactOS 0.4.16-dev-340-g0540c21
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)
 
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)
 

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{
48
51}
MxThread m_WorkItemThread
SINGLE_LIST_ENTRY ** m_ListEnd
FxSystemWorkItem * m_SystemWorkItem
SINGLE_LIST_ENTRY m_List
#define NULL
Definition: types.h:112
@ FX_TYPE_DISPOSELIST
Definition: fxtypes.h:86
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:637

◆ ~FxDisposeList()

FxDisposeList::~FxDisposeList ( )

Definition at line 53 of file fxdisposelist.cpp.

54{
56}
#define ASSERT(a)
Definition: mode.c:44

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}
LONG NTSTATUS
Definition: precomp.h:26
Definition: list.h:37
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
FxObject * pObject
#define list
Definition: rosglue.h:35
Definition: ps.c:97
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

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}
VOID DrainListLocked(PKIRQL PreviousIrql)
__drv_restoresIRQL KIRQL __in BOOLEAN Unlock
Definition: fxobject.hpp:1474
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

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}
unsigned char BOOLEAN
static VOID _WorkItemThunk(__in PVOID Parameter)
__inline BOOLEAN TryToEnqueue(__in PFN_WDF_SYSTEMWORKITEM CallbackFunc, __in PVOID Parameter)
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127

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
123
124 FxNonPagedObject::Dispose(); // __super call
125
126 return TRUE;
127}
virtual VOID DeleteObject(VOID)
virtual BOOLEAN Dispose(VOID)

◆ DrainListLocked()

VOID FxDisposeList::DrainListLocked ( PKIRQL  PreviousIrql)
private

Definition at line 187 of file fxdisposelist.cpp.

190{
193
194 //
195 // Process items on the list until it is empty
196 //
197 while (m_List.Next != NULL) {
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) {
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}
static FxObject * _FromDisposeEntry(__in PSINGLE_LIST_ENTRY Entry)
Definition: fxobject.hpp:580
VOID DeferredDisposeWorkItem(VOID)
PLIST_ENTRY pEntry
Definition: fxioqueue.cpp:4484
Definition: ntbasedef.h:636

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}
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
static _Must_inspect_result_ NTSTATUS _Create(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID WdmObject, __out FxSystemWorkItem **pObject)
#define TRACINGIO
Definition: dbgtrace.h:66
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
@ ObjectDoNotLock
Definition: fxobject.hpp:128
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27

◆ 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
305}
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61

Referenced by FxDevice::DeleteDeviceFromFailedCreateNoDelete(), FxDevice::Dispose(), FxMpDevice::Dispose(), FxDriver::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: