ReactOS  0.4.15-dev-2703-g05fb0f1
fxhandle.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  FxContextHeader
 

Macros

#define FX_CONTEXT_HEADER_SIZE   FIELD_OFFSET(FxContextHeader, Context)
 
#define COMPUTE_RAW_OBJECT_SIZE(_rawObjectSize)   ((USHORT) WDF_ALIGN_SIZE_UP(_rawObjectSize, MEMORY_ALLOCATION_ALIGNMENT))
 
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)   (COMPUTE_RAW_OBJECT_SIZE(_rawObjectSize) + (USHORT) WDF_ALIGN_SIZE_UP(_extraSize, MEMORY_ALLOCATION_ALIGNMENT))
 

Functions

size_t FxGetContextSize (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize2 (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in size_t ContextSize, __out size_t *Total)
 
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out size_t *Total)
 
PVOID FxObjectHandleAlloc (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType, __in size_t Size, __in ULONG Tag, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize, __in FxObjectType ObjectType)
 
VOID FxContextHeaderInit (__in FxContextHeader *Header, __in FxObject *Object, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
 
PVOID FxObjectAndHandleHeaderInit (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID AllocationStart, __in USHORT ObjectSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObjectType ObjectType)
 
VOID __inline FxObjectHandleCreate (__in FxObject *Object, __out PWDFOBJECT Handle)
 
VOID FxObjectHandleGetPtrQI (__in FxObject *Object, __out PVOID *PPObject, __in WDFOBJECT Handle, __in WDFTYPE Type, __in WDFOBJECT_OFFSET Offset)
 
_Must_inspect_result_ NTSTATUS FxObjectAllocateContext (__in FxObject *Object, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in BOOLEAN AllowCallbacksOnly, __deref_opt_out PVOID *Context)
 
__inline BOOLEAN FxObjectCheckType (__in FxObject *Object, __in WDFTYPE Type)
 
__inline VOID FxObjectHandleGetPtr (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFOBJECT Handle, __in WDFTYPE Type, __out PVOID *PPObject)
 
__inline VOID FxObjectHandleGetPtrOffset (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFOBJECT Handle, __in WDFTYPE Type, __out PVOID *PPObject, __out PWDFOBJECT_OFFSET Offset)
 
VOID __inline FxObjectHandleGetPtrAndGlobals (__in PFX_DRIVER_GLOBALS CallersGlobals, __in WDFOBJECT Handle, __in WDFTYPE Type, __out PVOID *PPObject, __out PFX_DRIVER_GLOBALS *ObjectGlobals)
 
VOID __inline FxObjectHandleGetGlobals (__in PFX_DRIVER_GLOBALS CallersGlobals, __in WDFOBJECT Handle, __out PFX_DRIVER_GLOBALS *ObjectGlobals)
 

Macro Definition Documentation

◆ COMPUTE_OBJECT_SIZE

#define COMPUTE_OBJECT_SIZE (   _rawObjectSize,
  _extraSize 
)    (COMPUTE_RAW_OBJECT_SIZE(_rawObjectSize) + (USHORT) WDF_ALIGN_SIZE_UP(_extraSize, MEMORY_ALLOCATION_ALIGNMENT))

Definition at line 107 of file fxhandle.h.

◆ COMPUTE_RAW_OBJECT_SIZE

#define COMPUTE_RAW_OBJECT_SIZE (   _rawObjectSize)    ((USHORT) WDF_ALIGN_SIZE_UP(_rawObjectSize, MEMORY_ALLOCATION_ALIGNMENT))

Definition at line 100 of file fxhandle.h.

◆ FX_CONTEXT_HEADER_SIZE

#define FX_CONTEXT_HEADER_SIZE   FIELD_OFFSET(FxContextHeader, Context)

Definition at line 98 of file fxhandle.h.

Function Documentation

◆ FxCalculateObjectTotalSize()

_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in USHORT  RawObjectSize,
__in USHORT  ExtraSize,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__out size_t Total 
)

Definition at line 147 of file handleapi.cpp.

154 {
155  return FxCalculateObjectTotalSize2(FxDriverGlobals,
156  RawObjectSize,
157  ExtraSize,
159  Total);
160 }
size_t FxGetContextSize(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: handleapi.cpp:38
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize2(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in size_t ContextSize, __out size_t *Total)
Definition: handleapi.cpp:73
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by FxObjectAllocateContext(), FxObjectHandleAlloc(), FxLookasideList::InitializeLookaside(), and VfAllocateContext().

◆ FxCalculateObjectTotalSize2()

_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize2 ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in USHORT  RawObjectSize,
__in USHORT  ExtraSize,
__in size_t  ContextSize,
__out size_t Total 
)

Definition at line 73 of file handleapi.cpp.

97 {
99 
100  *Total = 0;
101 
102  status = RtlSizeTAdd(
105  Total
106  );
107 
108  if (NT_SUCCESS(status)) {
109  if (ContextSize != 0) {
110  size_t alignUp;
111 
112  alignUp = ALIGN_UP(ContextSize, PVOID);
113 
114  //
115  // overflow after aligning up to a pointer boundary;
116  //
117  if (alignUp < ContextSize) {
119  }
120 
121  status = RtlSizeTAdd(*Total, alignUp, Total);
122  }
123  }
124 
125  if (NT_SUCCESS(status) && FxDriverGlobals->IsObjectDebugOn()) {
126  //
127  // Attempt to add in the debug extension
128  //
129  status = RtlSizeTAdd(*Total,
131  Total);
132  }
133 
134  if (!NT_SUCCESS(status)) {
136  FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGOBJECT,
137  "Size overflow, object size 0x%x, extra object size 0x%x, "
138  "context size 0x%I64x, %!STATUS!",
139  RawObjectSize, ExtraSize, ContextSize, status);
140  }
141 
142  return status;
143 }
#define ALIGN_UP(size, type)
Definition: umtypes.h:91
LONG NTSTATUS
Definition: precomp.h:26
_Must_inspect_result_ _In_ FLT_CONTEXT_TYPE _In_ SIZE_T ContextSize
Definition: fltkernel.h:1444
#define STATUS_INTEGER_OVERFLOW
Definition: ntstatus.h:385
FORCEINLINE size_t WDF_ALIGN_SIZE_UP(_In_ size_t Length, _In_ size_t AlignTo)
Definition: wdfcore.h:129
#define TRACINGOBJECT
Definition: dbgtrace.h:59
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGHANDLE, "Attempting to get context type %s from WDFOBJECT 0x%p", pGivenName, Handle)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
NTSTATUS status
Definition: handleapi.cpp:537
#define MEMORY_ALLOCATION_ALIGNMENT
Definition: ntbasedef.h:90
#define FX_CONTEXT_HEADER_SIZE
Definition: fxhandle.h:98
Definition: ps.c:97

Referenced by FxCalculateObjectTotalSize(), and FxDevice::Initialize().

◆ FxContextHeaderInit()

VOID FxContextHeaderInit ( __in FxContextHeader Header,
__in FxObject Object,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes 
)

Definition at line 248 of file handleapi.cpp.

264 {
266 
267  Header->Object = Object;
268 
269  if (Attributes != NULL) {
270  if (Attributes->ContextTypeInfo != NULL) {
271  size_t contextSize;
272 
273  if (Attributes->ContextSizeOverride != 0) {
274  contextSize = Attributes->ContextSizeOverride;
275 
276  }
277  else {
278  contextSize = Attributes->ContextTypeInfo->ContextSize;
279  }
280 
281  //
282  // Zero initialize the entire context
283  //
284  RtlZeroMemory(&Header->Context[0], ALIGN_UP(contextSize, PVOID));
285  }
286 
287  Header->ContextTypeInfo = Attributes->ContextTypeInfo;
288  }
289 }
#define ALIGN_UP(size, type)
Definition: umtypes.h:91
Definition: Header.h:8
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
return NULL
Definition: handleapi.cpp:653
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define FX_CONTEXT_HEADER_SIZE
Definition: fxhandle.h:98
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by FxObjectAllocateContext(), FxObjectAndHandleHeaderInit(), and VfAddContextToHandle().

◆ FxGetContextSize()

size_t FxGetContextSize ( __in_opt PWDF_OBJECT_ATTRIBUTES  Attributes)

Definition at line 38 of file handleapi.cpp.

54 {
55  size_t contextSize = 0;
56 
57  if (Attributes != NULL) {
58  if (Attributes->ContextTypeInfo != NULL) {
59  if (Attributes->ContextSizeOverride != 0) {
60  contextSize = Attributes->ContextSizeOverride;
61  }
62  else {
63  contextSize = Attributes->ContextTypeInfo->ContextSize;
64  }
65  }
66  }
67 
68  return contextSize;
69 }
return NULL
Definition: handleapi.cpp:653
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by FxCalculateObjectTotalSize(), and FxDevice::Initialize().

◆ FxObjectAllocateContext()

_Must_inspect_result_ NTSTATUS FxObjectAllocateContext ( __in FxObject Object,
__in PWDF_OBJECT_ATTRIBUTES  Attributes,
__in BOOLEAN  AllowCallbacksOnly,
__deref_opt_out PVOID Context 
)

Definition at line 397 of file handleapi.cpp.

419 {
423  size_t size;
424  BOOLEAN relRef;
425  ULONG flags;
426 
427  fxDriverGlobals = Object->GetDriverGlobals();
428  header = NULL;
429  relRef = FALSE;
430 
431  //
432  // Init validation flags.
433  //
437  }
438 
439  //
440  // Basic validations.
441  //
443  if (!NT_SUCCESS(status)) {
444  goto Done;
445  }
446 
447  //
448  // Check for context type!
449  //
450  if (Attributes->ContextTypeInfo == NULL && AllowCallbacksOnly == FALSE) {
454  "Attributes %p ContextTypeInfo is NULL, %!STATUS!",
455  Attributes, status);
456  goto Done;
457  }
458 
459  Object->ADDREF(&status);
460  relRef = TRUE;
461 
462  //
463  // By passing 0's for raw object size and extra size, we can compute the
464  // size of only the header and its contents.
465  //
467  if (!NT_SUCCESS(status)) {
468  goto Done;
469  }
470 
472  FxPoolAllocate(fxDriverGlobals, NonPagedPool, size);
473 
474  if (header == NULL) {
476  goto Done;
477  }
478 
480 
481  status = Object->AddContext(header, Context, Attributes);
482 
483  //
484  // STATUS_OBJECT_NAME_EXISTS will not fail NT_SUCCESS, so check
485  // explicitly for STATUS_SUCCESS.
486  //
487  if (status != STATUS_SUCCESS) {
489  }
490 
491 Done:
492 
493  if (relRef) {
494  Object->RELEASE(&status);
495  }
496 
497  return status;
498 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
GLsizeiptr size
Definition: glext.h:5919
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
GLbitfield flags
Definition: glext.h:7161
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out size_t *Total)
Definition: handleapi.cpp:147
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGHANDLE, "Attempting to get context type %s from WDFOBJECT 0x%p", pGivenName, Handle)
VOID FxContextHeaderInit(__in FxContextHeader *Header, __in FxObject *Object, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: handleapi.cpp:248
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define TRACINGHANDLE
Definition: dbgtrace.h:61
PFX_DRIVER_GLOBALS fxDriverGlobals
return NULL
Definition: handleapi.cpp:653
#define STATUS_OBJECT_NAME_INVALID
Definition: udferr_usr.h:148
NTSTATUS status
Definition: handleapi.cpp:537
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
struct CFHEADER header
Definition: fdi.c:101
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97

Referenced by FxPkgGeneral::OnCreate(), and FxUsbInterface::UpdatePipeAttributes().

◆ FxObjectAndHandleHeaderInit()

PVOID FxObjectAndHandleHeaderInit ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PVOID  AllocationStart,
__in USHORT  ObjectSize,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__in FxObjectType  ObjectType 
)

Definition at line 292 of file handleapi.cpp.

318 {
319  FxObject* pObject;
320 
321  if (FxDriverGlobals->IsObjectDebugOn()) {
322  FxObjectDebugExtension* pExtension;
323 
324  pExtension = (FxObjectDebugExtension*) AllocationStart;
325 
328 
329  pObject = (FxObject*) &pExtension->AllocationStart[0];
330  }
331  else {
332  pObject = (FxObject*) AllocationStart;
333  }
334 
338  pObject,
339  Attributes
340  );
341  }
342 
343  return pObject;
344 }
ObjectType
Definition: metafile.c:80
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144
FxObject * pObject
Definition: handleapi.cpp:605
VOID FxContextHeaderInit(__in FxContextHeader *Header, __in FxObject *Object, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes)
Definition: handleapi.cpp:248
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes

Referenced by FxDevice::AllocateRequestMemory(), FxObjectHandleAlloc(), FxMemoryBufferFromLookaside::operator new(), and FxMemoryBufferFromPoolLookaside::operator new().

◆ FxObjectCheckType()

__inline BOOLEAN FxObjectCheckType ( __in FxObject Object,
__in WDFTYPE  Type 
)

Definition at line 240 of file fxhandle.h.

257 {
259  PVOID tmpObject;
260  FxQueryInterfaceParams params = {&tmpObject, Type, 0};
261 
262  //
263  // Do a quick non virtual call for the type and only do the slow QI if
264  // the first types do not match
265  //
266 
267  if (Object->GetType() == Type) {
268  return TRUE;
269  }
270 
271  status = Object->QueryInterface(&params);
272 
273  if (!NT_SUCCESS(status)) {
274  return FALSE;
275  }
276 
277  return TRUE;
278 
279 }
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
#define FALSE
Definition: types.h:117
GLenum const GLfloat * params
Definition: glext.h:5645
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Type
Definition: Type.h:6
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxUsbDevice::IsObjectDisposedOnRemove().

◆ FxObjectHandleAlloc()

PVOID FxObjectHandleAlloc ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in POOL_TYPE  PoolType,
__in size_t  Size,
__in ULONG  Tag,
__in_opt PWDF_OBJECT_ATTRIBUTES  Attributes,
__in USHORT  ExtraSize,
__in FxObjectType  ObjectType 
)

Definition at line 163 of file handleapi.cpp.

195 {
196  PVOID blob;
197  size_t totalSize;
199 
200  if (Tag == 0) {
201  Tag = FxDriverGlobals->Tag;
202  ASSERT(Tag != 0);
203  }
204 
206  //
207  // An internal object might need the debug extension size added to it,
208  // but that's it. No extra size, no FxContextHeader.
209  //
210  if (FxDriverGlobals->IsObjectDebugOn()) {
211  status = RtlSizeTAdd(Size,
213  &totalSize);
214  }
215  else {
216  totalSize = Size;
218  }
219  }
220  else {
221  status = FxCalculateObjectTotalSize(FxDriverGlobals,
222  (USHORT) Size,
223  ExtraSize,
224  Attributes,
225  &totalSize);
226  }
227 
228  if (!NT_SUCCESS(status)) {
229  return NULL;
230  }
231 
232  blob = FxPoolAllocateWithTag(FxDriverGlobals, PoolType, totalSize, Tag);
233 
234  if (blob != NULL) {
236  FxDriverGlobals,
237  blob,
238  COMPUTE_OBJECT_SIZE((USHORT) Size, ExtraSize),
239  Attributes,
240  ObjectType
241  );
242  }
243 
244  return blob;
245 }
ObjectType
Definition: metafile.c:80
Definition: image.c:133
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
const DWORD * blob
Definition: effect.c:980
#define COMPUTE_OBJECT_SIZE(_rawObjectSize, _extraSize)
Definition: fxhandle.h:107
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_Must_inspect_result_ NTSTATUS FxCalculateObjectTotalSize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT RawObjectSize, __in USHORT ExtraSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out size_t *Total)
Definition: handleapi.cpp:147
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
unsigned short USHORT
Definition: pedump.c:61
return NULL
Definition: handleapi.cpp:653
NTSTATUS status
Definition: handleapi.cpp:537
PVOID FxObjectAndHandleHeaderInit(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PVOID AllocationStart, __in USHORT ObjectSize, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in FxObjectType ObjectType)
Definition: handleapi.cpp:292
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97

◆ FxObjectHandleCreate()

VOID __inline FxObjectHandleCreate ( __in FxObject Object,
__out PWDFOBJECT  Handle 
)

Definition at line 176 of file fxhandle.h.

180 {
181 #if FX_SUPER_DBG
182  if (Object->GetDriverGlobals()->FxVerifierHandle) {
183 
184 
185 
186 
187 
188 
189  ASSERT(Object->GetObjectSize() > 0);
190  ASSERT(Object == Object->GetContextHeader()->Object);
191  }
192 #endif
193 
195  *Handle = Object->GetObjectHandle();
196 }
GLint x0
Definition: linetemp.h:95
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define ASSERT(a)
Definition: mode.c:44
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by FxObject::Commit().

◆ FxObjectHandleGetGlobals()

VOID __inline FxObjectHandleGetGlobals ( __in PFX_DRIVER_GLOBALS  CallersGlobals,
__in WDFOBJECT  Handle,
__out PFX_DRIVER_GLOBALS ObjectGlobals 
)

Definition at line 453 of file fxhandle.h.

470 {
471  PVOID pObject;
472 
473  FxObjectHandleGetPtrAndGlobals(CallersGlobals,
474  Handle,
476  &pObject,
477  ObjectGlobals);
478 
480 }
FxObject * pObject
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
VOID __inline FxObjectHandleGetPtrAndGlobals(__in PFX_DRIVER_GLOBALS CallersGlobals, __in WDFOBJECT Handle, __in WDFTYPE Type, __out PVOID *PPObject, __out PFX_DRIVER_GLOBALS *ObjectGlobals)
Definition: fxhandle.h:414
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by if().

◆ FxObjectHandleGetPtr()

__inline VOID FxObjectHandleGetPtr ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in WDFOBJECT  Handle,
__in WDFTYPE  Type,
__out PVOID PPObject 
)

Definition at line 283 of file fxhandle.h.

301 {
303  FxObject* pObject;
304 
305  if (Handle == NULL) {
306 
307 
308 
309 
310 
311  FxVerifierBugCheck(FxDriverGlobals,
313  (ULONG_PTR) Handle,
314  Type);
315 
316  /* NOTREACHED */
317  return;
318  }
319 
320  offset = 0;
322 
323  //
324  // The only DDI you can call on an object which has a ref count of zero is
325  // WdfObjectGetTypedContextWorker().
326  //
327  ASSERT(pObject->GetRefCnt() > 0);
328 
329  //
330  // Do a quick non virtual call for the type and only do the slow QI if
331  // the first types do not match
332  //
333  if (pObject->GetType() == Type) {
334  *PPObject = pObject;
335  ASSERT(offset == 0x0);
336  return;
337  }
338  else {
340  }
341 }
FxObject * pObject
GLint x0
Definition: linetemp.h:95
WDFTYPE GetType(VOID)
Definition: fxobject.hpp:742
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FxObjectHandleGetPtrQI(__in FxObject *Object, __out PVOID *PPObject, __in WDFOBJECT Handle, __in WDFTYPE Type, __in WDFOBJECT_OFFSET Offset)
Definition: handleapi.cpp:347
USHORT WDFOBJECT_OFFSET
Definition: fxobject.hpp:80
#define ASSERT(a)
Definition: mode.c:44
GLintptr offset
Definition: glext.h:5920
Type
Definition: Type.h:6
LONG GetRefCnt(VOID)
Definition: fxobject.hpp:758
#define NULL
Definition: types.h:112
static FxObject * _GetObjectFromHandle(__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
Definition: fxobject.hpp:613
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by FxObjectHandleGetPtrAndGlobals().

◆ FxObjectHandleGetPtrAndGlobals()

VOID __inline FxObjectHandleGetPtrAndGlobals ( __in PFX_DRIVER_GLOBALS  CallersGlobals,
__in WDFOBJECT  Handle,
__in WDFTYPE  Type,
__out PVOID PPObject,
__out PFX_DRIVER_GLOBALS ObjectGlobals 
)

Definition at line 414 of file fxhandle.h.

434 {
435  //
436  // All FX_TYPEs except for IFX_TYPE_MEMORY derive from FxObject, so our cast
437  // below will work with all types but IFX_TYPE_MEMORY (in which case the caller
438  // should call FxObjectHandleGetPtr and then get the globals on their own
439  // from the IFxMemory interface).
440  //
442 
443  FxObjectHandleGetPtr(CallersGlobals,
444  Handle,
445  Type,
446  PPObject);
447 
448  *ObjectGlobals = ((FxObject*) (*PPObject))->GetDriverGlobals();
449 }
__inline VOID FxObjectHandleGetPtr(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in WDFOBJECT Handle, __in WDFTYPE Type, __out PVOID *PPObject)
Definition: fxhandle.h:283
#define ASSERT(a)
Definition: mode.c:44
Type
Definition: Type.h:6
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by FxObjectHandleGetGlobals().

◆ FxObjectHandleGetPtrOffset()

__inline VOID FxObjectHandleGetPtrOffset ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in WDFOBJECT  Handle,
__in WDFTYPE  Type,
__out PVOID PPObject,
__out PWDFOBJECT_OFFSET  Offset 
)

Definition at line 345 of file fxhandle.h.

371 {
372  FxObject* pObject;
373 
374  if (Handle == NULL) {
375 
376 
377 
378 
379 
380  FxVerifierBugCheck(FxDriverGlobals,
382  (ULONG_PTR) Handle,
383  Type);
384 
385  /* NOTREACHED */
386  return;
387  }
388 
389  *Offset = 0;
391 
392  //
393  // The only DDI you can call on an object which has a ref count of zero is
394  // WdfObjectGetTypedContextWorker().
395  //
396  ASSERT(pObject->GetRefCnt() > 0);
397 
398  //
399  // Do a quick non virtual call for the type and only do the slow QI if
400  // the first types do not match
401  //
402  if (pObject->GetType() == Type) {
403  *PPObject = pObject;
404  ASSERT(*Offset == 0x0);
405  return;
406  }
407  else {
409  }
410 }
FxObject * pObject
GLint x0
Definition: linetemp.h:95
WDFTYPE GetType(VOID)
Definition: fxobject.hpp:742
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
VOID FxObjectHandleGetPtrQI(__in FxObject *Object, __out PVOID *PPObject, __in WDFOBJECT Handle, __in WDFTYPE Type, __in WDFOBJECT_OFFSET Offset)
Definition: handleapi.cpp:347
#define ASSERT(a)
Definition: mode.c:44
Type
Definition: Type.h:6
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
LONG GetRefCnt(VOID)
Definition: fxobject.hpp:758
#define NULL
Definition: types.h:112
static FxObject * _GetObjectFromHandle(__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
Definition: fxobject.hpp:613
_In_ HANDLE Handle
Definition: extypes.h:390

◆ FxObjectHandleGetPtrQI()

VOID FxObjectHandleGetPtrQI ( __in FxObject Object,
__out PVOID PPObject,
__in WDFOBJECT  Handle,
__in WDFTYPE  Type,
__in WDFOBJECT_OFFSET  Offset 
)

Definition at line 347 of file handleapi.cpp.

370 {
371  FxQueryInterfaceParams params = { PPObject, Type, Offset };
373 
374  *PPObject = NULL;
375 
376  status = Object->QueryInterface(&params);
377 
378  if (!NT_SUCCESS(status)) {
380  Object->GetDriverGlobals(), TRACE_LEVEL_ERROR, TRACINGDEVICE,
381  "Object Type Mismatch, Handle 0x%p, Type 0x%x, "
382  "Obj 0x%p, SB 0x%x",
383  Handle, Type, Object, Object->GetType());
384 
385  FxVerifierBugCheck(Object->GetDriverGlobals(),
387  (ULONG_PTR) Handle,
388  Type);
389 
390  /* NOTREACHED */
391  return;
392  }
393 }
LONG NTSTATUS
Definition: precomp.h:26
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
GLenum const GLfloat * params
Definition: glext.h:5645
#define TRACINGDEVICE
Definition: dbgtrace.h:58
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Type
Definition: Type.h:6
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_WARNING, TRACINGHANDLE, "Attempting to get context type %s from WDFOBJECT 0x%p", pGivenName, Handle)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_Must_inspect_result_ __in WDFOBJECT Handle
Definition: handleapi.cpp:512
return NULL
Definition: handleapi.cpp:653
NTSTATUS status
Definition: handleapi.cpp:537
_In_ HANDLE Handle
Definition: extypes.h:390
#define ULONG_PTR
Definition: config.h:101
Definition: ps.c:97

Referenced by FxObjectHandleGetPtr(), and FxObjectHandleGetPtrOffset().