WDF_PTR_ADD_OFFSET macro
The WDF_PTR_ADD_OFFSET macro adds an offset value to an address and returns the resulting address.
Syntax
PVOID WDF_PTR_ADD_OFFSET(
_ptr,
_offset
);
Parameters
_ptr
Specifies an address.
_offset
Specifies the offset value in bytes.
Return value
Returns a pointer to the resulting address.
Remarks
This macro invokes WDF_PTR_ADD_OFFSET_TYPE with the _type parameter set to PVOID.
The macro is defined as follows:
#define WDF_PTR_ADD_OFFSET(_ptr, _offset) \
WDF_PTR_ADD_OFFSET_TYPE(_ptr, _offset, PVOID)
Here is an example from the Toaster sample (toaster\func\featured\wmi.c). In the example, the driver calls WDF_PTR_ADD_OFFSET to add an offset to an address to determine a destination buffer address to pass to the WDF_WMI_BUFFER_APPEND_STRING function.
//
// Write the instance name
//
size -= wnodeSize;
status = WDF_WMI_BUFFER_APPEND_STRING(
WDF_PTR_ADD_OFFSET(wnode, wnode->OffsetInstanceName),
size,
&deviceName,
&length
);
//
// Size was precomputed, this should never fail
//
ASSERT(NT_SUCCESS(status));
//
// Write the data, which is the model name as a string
//
size -= wnodeInstanceNameSize;
WDF_WMI_BUFFER_APPEND_STRING(
WDF_PTR_ADD_OFFSET(wnode, wnode->DataBlockOffset),
size,
&modelName,
&length
);
Requirements
Target platform |
Universal |
Minimum KMDF version |
1.5 |
Minimum UMDF version |
2.0 |
Header |
Wdfcore.h (include Wdf.h) |
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for