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) 77 EVT_WDF_OBJECT_CONTEXT_CLEANUP(
90 EVT_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" 311 #endif // WDF_TYPE_DEFAULT_SECTION_NAME 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)\ 318 typedef _contexttype* WDF_TYPE_NAME_POINTER_TYPE(_contexttype); \ 322 const WDF_OBJECT_CONTEXT_TYPE_INFO \ 323 WDF_TYPE_NAME_TO_TYPE_INFO(_contexttype) = \ 325 sizeof(WDF_OBJECT_CONTEXT_TYPE_INFO), \ 327 sizeof(_contexttype), \ 331 //__declspec(allocate(_section)) 333 #define WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction) \ 338 WDF_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) \ 352 WDF_DECLARE_TYPE_AND_GLOBALS( \ 354 WDF_GET_CONTEXT_TYPE_INFO(_contexttype), \ 356 WDF_TYPE_DEFAULT_SECTION_NAME) \ 358 WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction) 378 #define WDF_DECLARE_SHARED_CONTEXT_TYPE_WITH_NAME(_contexttype, _castingfunction) \ 380 WDF_DECLARE_TYPE_AND_GLOBALS( \ 383 WDF_TYPE_NAME_TO_EXTERNAL_INIT_FUNCTION(_contexttype), \ 384 WDF_TYPE_INIT_SECTION_NAME) \ 386 WDF_DECLARE_CASTING_FUNCTION(_contexttype, _castingfunction) 404 #define WdfObjectGetTypedContext(handle, type) \ 406 WdfObjectGetTypedContextWorker( \ 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) \ 445 typedef WDF_CUSTOM_TYPE_CONTEXT WDF_CUSTOM_TYPE_CONTEXT_NAME(_type); \ 447 WDF_DECLARE_CONTEXT_TYPE_WITH_NAME( \ 448 WDF_CUSTOM_TYPE_CONTEXT_NAME(_type), \ 449 WDF_GET_CUSTOM_TYPE_FUNCTION_NAME(_type) \ 455 WDF_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) 700 (
STDCALL *PFN_WDFOBJECTCREATE)(
730 (
STDCALL *PFN_WDFOBJECTDELETE)(
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__) 833 #endif // (NTDDI_VERSION >= NTDDI_WIN2K) 838 #endif // _WDFOBJECT_H_
WDFAPI VOID(STDCALL * PFN_WDFOBJECTREFERENCEACTUAL)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
__in WDFOBJECT __in PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID _In_ ULONG _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
_WDF_SYNCHRONIZATION_SCOPE
const struct _WDF_OBJECT_CONTEXT_TYPE_INFO * PCWDF_OBJECT_CONTEXT_TYPE_INFO
__in PVOID ContextPointer
WDFAPI WDFOBJECT(FASTCALL * PFN_WDFOBJECTCONTEXTGETOBJECT)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ PVOID ContextPointer)
PFN_GET_UNIQUE_CONTEXT_TYPE EvtDriverGetUniqueContextType
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_ WDFOBJECT _In_ CONST GUID _In_ ULONG QueryBufferLength
WDF_EXECUTION_LEVEL ExecutionLevel
WDFAPI NTSTATUS(STDCALL * PFN_WDFOBJECTALLOCATECONTEXT)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFOBJECT * Object
struct _WDF_CUSTOM_TYPE_CONTEXT WDF_CUSTOM_TYPE_CONTEXT
#define _IRQL_requires_same_
_Must_inspect_result_ _IRQL_requires_max_(DISPATCH_LEVEL) WDFAPI NTSTATUS(STDCALL *PFN_WDFOBJECTCREATE)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals
struct _WDF_OBJECT_CONTEXT_TYPE_INFO WDF_OBJECT_CONTEXT_TYPE_INFO
enum _WDF_SYNCHRONIZATION_SCOPE WDF_SYNCHRONIZATION_SCOPE
PWDF_DRIVER_GLOBALS WdfDriverGlobals
_Must_inspect_result_ _In_ WDFOBJECT _In_ CONST GUID * Guid
FORCEINLINE WDFOBJECT WdfObjectContextGetObject(_In_ PVOID ContextPointer)
EVT_WDF_OBJECT_CONTEXT_DESTROY * PFN_WDF_OBJECT_CONTEXT_DESTROY
FORCEINLINE PVOID WdfObjectGetTypedContextWorker(_In_ WDFOBJECT Handle, _In_ PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo)
EVT_WDF_OBJECT_CONTEXT_CLEANUP * PFN_WDF_OBJECT_CONTEXT_CLEANUP
FORCEINLINE NTSTATUS WdfObjectAllocateContext(_In_ WDFOBJECT Handle, _In_ PWDF_OBJECT_ATTRIBUTES ContextAttributes, _Outptr_opt_ PVOID *Context)
typedef _Function_class_(EVT_WDF_OBJECT_CONTEXT_CLEANUP) _IRQL_requires_same_ _IRQL_requires_max_(DISPATCH_LEVEL) VOID STDCALL EVT_WDF_OBJECT_CONTEXT_CLEANUP(_In_ WDFOBJECT Object)
#define _Must_inspect_result_
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
FORCEINLINE VOID WDF_OBJECT_ATTRIBUTES_INIT(_Out_ PWDF_OBJECT_ATTRIBUTES Attributes)
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
FORCEINLINE VOID WdfObjectReferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
PCWDF_OBJECT_CONTEXT_TYPE_INFO ContextTypeInfo
struct _WDF_OBJECT_CONTEXT_TYPE_INFO * PWDF_OBJECT_CONTEXT_TYPE_INFO
PFN_WDF_OBJECT_CONTEXT_CLEANUP EvtCleanupCallback
size_t ContextSizeOverride
struct _WDF_OBJECT_ATTRIBUTES WDF_OBJECT_ATTRIBUTES
struct tagContext Context
WDF_EXTERN_C_START enum _WDF_EXECUTION_LEVEL WDF_EXECUTION_LEVEL
#define RtlZeroMemory(Destination, Length)
struct _WDF_CUSTOM_TYPE_CONTEXT * PWDF_CUSTOM_TYPE_CONTEXT
WDF_SYNCHRONIZATION_SCOPE SynchronizationScope
#define WDF_EXTERN_C_START
PCWDF_OBJECT_CONTEXT_TYPE_INFO(__cdecl * PFN_GET_UNIQUE_CONTEXT_TYPE)(VOID)
WDFAPI PVOID(FASTCALL * PFN_WDFOBJECTGETTYPEDCONTEXTWORKER)(_In_ PWDF_DRIVER_GLOBALS DriverGlobals, _In_ WDFOBJECT Handle, _In_ PCWDF_OBJECT_CONTEXT_TYPE_INFO TypeInfo)
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID _In_ LONG _In_z_ PCHAR File
FORCEINLINE VOID WdfObjectDereferenceActual(_In_ WDFOBJECT Handle, _In_opt_ PVOID Tag, _In_ LONG Line, _In_z_ PCHAR File)
PCWDF_OBJECT_CONTEXT_TYPE_INFO UniqueType
PFN_WDF_OBJECT_CONTEXT_DESTROY EvtDestroyCallback
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
struct _WDF_OBJECT_ATTRIBUTES * PWDF_OBJECT_ATTRIBUTES