31 #define WDF_EXTERN_C extern "C"
32 #define WDF_EXTERN_C_START extern "C" {
33 #define WDF_EXTERN_C_END }
36 #define WDF_EXTERN_C_START
37 #define WDF_EXTERN_C_END
45#if (NTDDI_VERSION >= NTDDI_WIN2K)
77EVT_WDF_OBJECT_CONTEXT_CLEANUP(
90EVT_WDF_OBJECT_CONTEXT_DESTROY(
157#define WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(_attributes, _contexttype) \
158 (_attributes)->ContextTypeInfo = WDF_GET_CONTEXT_TYPE_INFO(_contexttype)->UniqueType
170#define WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(_attributes, _contexttype) \
171 WDF_OBJECT_ATTRIBUTES_INIT(_attributes); \
172 WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(_attributes, _contexttype)
222#define WDF_TYPE_NAME_TO_TYPE_INFO(_contexttype) \
223 _WDF_ ## _contexttype ## _TYPE_INFO
229#define WDF_TYPE_NAME_TO_EXTERNAL_INIT(_contexttype) \
230 _WDF_ ## _contexttype ## _EXTERNAL_INIT
232#define WDF_TYPE_NAME_TO_EXTERNAL_INIT_FUNCTION(_contexttype) \
233 _contexttype ## _EXTERNAL_INIT_FUNCTION
238#define WDF_GET_CONTEXT_TYPE_INFO(_contexttype) \
239 (&WDF_TYPE_NAME_TO_TYPE_INFO(_contexttype))
249#define WDF_TYPE_NAME_POINTER_TYPE(_contexttype) \
250 WDF_POINTER_TYPE_ ## _contexttype
259#define WDF_DECLARE_CONTEXT_TYPE(_contexttype) \
260 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(_contexttype, WdfObjectGet_ ## _contexttype)
301#define WDF_TYPE_INIT_BASE_SECTION_NAME ".kmdftypeinit"
302#define WDF_TYPE_INIT_SECTION_NAME ".kmdftypeinit$b"
309#ifndef WDF_TYPE_DEFAULT_SECTION_NAME
310#define WDF_TYPE_DEFAULT_SECTION_NAME ".data"
313#pragma section(WDF_TYPE_INIT_SECTION_NAME, read, write)
314#pragma section(WDF_TYPE_DEFAULT_SECTION_NAME)
316#define WDF_DECLARE_TYPE_AND_GLOBALS(_contexttype, _UniqueType, _GetUniqueType, _section)\
318typedef _contexttype* WDF_TYPE_NAME_POINTER_TYPE(_contexttype); \
322const WDF_OBJECT_CONTEXT_TYPE_INFO \
323WDF_TYPE_NAME_TO_TYPE_INFO(_contexttype) = \
325 sizeof(WDF_OBJECT_CONTEXT_TYPE_INFO), \
327 sizeof(_contexttype), \
333#define WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction) \
338WDF_TYPE_NAME_POINTER_TYPE(_contexttype) \
340 _In_ WDFOBJECT Handle \
343 return (WDF_TYPE_NAME_POINTER_TYPE(_contexttype)) \
344 WdfObjectGetTypedContextWorker( \
346 WDF_GET_CONTEXT_TYPE_INFO(_contexttype)->UniqueType \
350#define WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(_contexttype, _castingfunction) \
352WDF_DECLARE_TYPE_AND_GLOBALS( \
354 WDF_GET_CONTEXT_TYPE_INFO(_contexttype), \
356 WDF_TYPE_DEFAULT_SECTION_NAME) \
358WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction)
378#define WDF_DECLARE_SHARED_CONTEXT_TYPE_WITH_NAME(_contexttype, _castingfunction) \
380WDF_DECLARE_TYPE_AND_GLOBALS( \
383 WDF_TYPE_NAME_TO_EXTERNAL_INIT_FUNCTION(_contexttype), \
384 WDF_TYPE_INIT_SECTION_NAME) \
386WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction)
404#define WdfObjectGetTypedContext(handle, type) \
406WdfObjectGetTypedContextWorker( \
407 (WDFOBJECT) handle, \
408 WDF_GET_CONTEXT_TYPE_INFO(type)->UniqueType \
414#define WDF_CUSTOM_TYPE_CONTEXT_NAME(_type) \
415 WdfCustomType_ ## _type
420#define WDF_GET_CUSTOM_TYPE_FUNCTION_NAME(_type) \
421 WdfObjectGetCustomType_ ## _type
426#define WDF_ADD_CUSTOM_TYPE_FUNCTION_NAME(_type) \
427 WdfObjectAddCustomType_ ## _type
443#define WDF_DECLARE_CUSTOM_TYPE(_type) \
445typedef WDF_CUSTOM_TYPE_CONTEXT WDF_CUSTOM_TYPE_CONTEXT_NAME(_type); \
447WDF_DECLARE_CONTEXT_TYPE_WITH_NAME( \
448 WDF_CUSTOM_TYPE_CONTEXT_NAME(_type), \
449 WDF_GET_CUSTOM_TYPE_FUNCTION_NAME(_type) \
455WDF_ADD_CUSTOM_TYPE_FUNCTION_NAME(_type)( \
456 _In_ WDFOBJECT Handle, \
457 _In_opt_ ULONG_PTR Data, \
458 _In_opt_ PFN_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanupCallback, \
459 _In_opt_ PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback \
463 WDF_OBJECT_ATTRIBUTES attributes; \
464 WDF_CUSTOM_TYPE_CONTEXT_NAME(_type)* typeInfo; \
466 WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE( \
468 WDF_CUSTOM_TYPE_CONTEXT_NAME(_type)); \
470 attributes.EvtCleanupCallback = EvtCleanupCallback; \
471 attributes.EvtDestroyCallback = EvtDestroyCallback; \
473 status = WdfObjectAllocateContext(Handle, \
475 (PVOID*)&typeInfo); \
476 if (NT_SUCCESS(status)) { \
477 typeInfo->Size = sizeof(WDF_CUSTOM_TYPE_CONTEXT_NAME(_type)); \
478 typeInfo->Data = Data; \
494#define WdfObjectIsCustomType(_handle, _type) \
495 (WdfObjectGetTypedContext(_handle, WDF_CUSTOM_TYPE_CONTEXT_NAME(_type)) \
496 == NULL ? FALSE : TRUE)
511#define WdfObjectAddCustomTypeWithData(_handle, _type, _data, _cleanup, _destroy) \
512 WDF_ADD_CUSTOM_TYPE_FUNCTION_NAME(_type)(_handle, _data, _cleanup, _destroy)
524#define WdfObjectAddCustomType(_handle, _type) \
525 WdfObjectAddCustomTypeWithData(_handle, _type, 0, NULL, NULL)
537#define WdfObjectGetCustomTypeData(_handle, _type) \
538 (WDF_GET_CUSTOM_TYPE_FUNCTION_NAME(_type)(_handle)->Data)
803#define WdfObjectReference(Handle) \
804 WdfObjectReferenceWithTag(Handle, NULL)
806#define WdfObjectReferenceWithTag(Handle, Tag) \
807 WdfObjectReferenceActual(Handle, Tag, __LINE__, __FILE__)
826#define WdfObjectDereference(Handle) \
827 WdfObjectDereferenceWithTag(Handle, NULL)
829#define WdfObjectDereferenceWithTag(Handle, Tag) \
830 WdfObjectDereferenceActual(Handle, Tag, __LINE__, __FILE__)
#define _IRQL_requires_same_
__in WDFOBJECT __in PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo
__in PVOID ContextPointer
#define _Function_class_(x)
#define _Must_inspect_result_
PFN_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanupCallback
WDF_EXECUTION_LEVEL ExecutionLevel
WDF_SYNCHRONIZATION_SCOPE SynchronizationScope
PCWDF_OBJECT_CONTEXT_TYPE_INFO ContextTypeInfo
PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback
size_t ContextSizeOverride
PFN_GET_UNIQUE_CONTEXT_TYPE EvtDriverGetUniqueContextType
PCWDF_OBJECT_CONTEXT_TYPE_INFO UniqueType
#define RtlZeroMemory(Destination, Length)
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
PWDF_DRIVER_GLOBALS WdfDriverGlobals
@ WdfObjectGetTypedContextWorkerTableIndex
@ WdfObjectReferenceActualTableIndex
@ WdfObjectContextGetObjectTableIndex
@ WdfObjectDeleteTableIndex
@ WdfObjectCreateTableIndex
@ WdfObjectAllocateContextTableIndex
@ WdfObjectQueryTableIndex
@ WdfObjectDereferenceActualTableIndex
_Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) WDFAPI NTSTATUS(STDCALL *PFN_WDFOBJECTCREATE)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
FORCEINLINE VOID WdfObjectDereferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
WDFAPI VOID(STDCALL * PFN_WDFOBJECTREFERENCEACTUAL)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
struct _WDF_OBJECT_ATTRIBUTES WDF_OBJECT_ATTRIBUTES
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFOBJECT * Object
const struct _WDF_OBJECT_CONTEXT_TYPE_INFO * PCWDF_OBJECT_CONTEXT_TYPE_INFO
WDFAPI VOID(STDCALL * PFN_WDFOBJECTDEREFERENCEACTUAL)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
FORCEINLINE WDFOBJECT WdfObjectContextGetObject(_In_ PVOID ContextPointer)
_WDF_SYNCHRONIZATION_SCOPE
@ WdfSynchronizationScopeInheritFromParent
@ WdfSynchronizationScopeQueue
@ WdfSynchronizationScopeNone
@ WdfSynchronizationScopeInvalid
@ WdfSynchronizationScopeDevice
struct _WDF_CUSTOM_TYPE_CONTEXT * PWDF_CUSTOM_TYPE_CONTEXT
@ WdfExecutionLevelPassive
@ WdfExecutionLevelDispatch
@ WdfExecutionLevelInheritFromParent
@ WdfExecutionLevelInvalid
struct _WDF_OBJECT_CONTEXT_TYPE_INFO * PWDF_OBJECT_CONTEXT_TYPE_INFO
EVT_WDF_OBJECT_CONTEXT_DESTROY * PFN_WDF_OBJECT_CONTEXT_DESTROY
WDFAPI NTSTATUS(STDCALL * PFN_WDFOBJECTALLOCATECONTEXT)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
WDFAPI PVOID(FASTCALL * PFN_WDFOBJECTGETTYPEDCONTEXTWORKER)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_ PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo)
#define WDF_EXTERN_C_START
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
struct _WDF_CUSTOM_TYPE_CONTEXT WDF_CUSTOM_TYPE_CONTEXT
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
struct _WDF_OBJECT_CONTEXT_TYPE_INFO WDF_OBJECT_CONTEXT_TYPE_INFO
WDFAPI WDFOBJECT(FASTCALL * PFN_WDFOBJECTCONTEXTGETOBJECT)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ PVOID ContextPointer)
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
FORCEINLINE VOID WdfObjectReferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
FORCEINLINE PVOID WdfObjectGetTypedContextWorker(_In_ WDFOBJECT Handle, _In_ PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo)
PCWDF_OBJECT_CONTEXT_TYPE_INFO(__cdecl * PFN_GET_UNIQUE_CONTEXT_TYPE)(VOID)
FORCEINLINE NTSTATUS WdfObjectAllocateContext(_In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
EVT_WDF_OBJECT_CONTEXT_CLEANUP * PFN_WDF_OBJECT_CONTEXT_CLEANUP
WDF_EXTERN_C_START enum _WDF_EXECUTION_LEVEL WDF_EXECUTION_LEVEL
enum _WDF_SYNCHRONIZATION_SCOPE WDF_SYNCHRONIZATION_SCOPE
struct _WDF_OBJECT_ATTRIBUTES * PWDF_OBJECT_ATTRIBUTES