Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The RtlFillDeviceMemory routine fills a block of device memory with the specified fill value and returns a pointer to the filled memory. This function is safe for use on device memory because it uses appropriate access patterns for device memory regions.
Syntax
volatile void * RtlFillDeviceMemory(
[out] volatile void *Destination,
[in] size_t Length,
[in] int Fill
);
Parameters
[out] Destination
A pointer to the starting address of the volatile device memory block to fill.
[in] Length
The size of the block of memory to fill, in bytes. This value must be less than or equal to the size of the Destination buffer.
[in] Fill
The byte value with which to fill the memory block.
Return value
RtlFillDeviceMemory returns a pointer to the filled volatile device memory block (Destination).
Remarks
The RtlFillDeviceMemory routine is designed for safe filling of device memory regions where standard memory filling functions might not be appropriate due to the special characteristics of device memory.
The function uses volatile memory accesses to ensure proper handling of device memory that may have side effects or special access requirements.
The function is optimized for performance while maintaining safety for device memory access patterns.
The function might perform unaligned memory accesses if the platform allows for it.
The function might use optimized filling patterns for larger memory blocks while ensuring device memory safety.
This function provides RtlFillMemory behavior specifically designed for device memory regions.
Callers of RtlFillDeviceMemory can be running at any IRQL if the destination memory block is in nonpaged system memory. Otherwise, the caller must be running at IRQL <= APC_LEVEL.
This function works on all versions of Windows, not just the latest. You need to consume the latest WDK to get the function declaration from the wdm.h header. You also need the library (volatileaccessk.lib) from the latest WDK. However, the resulting driver will run fine on older versions of Windows.
Example
volatile UCHAR* DeviceBuffer;
SIZE_T BufferSize = 1024;
// Allocate or map device memory
DeviceBuffer = MapDeviceMemory(BufferSize);
// Fill the device memory with a specific pattern
volatile void* result = RtlFillDeviceMemory(DeviceBuffer, BufferSize, 0xAA);
// Use the filled device memory
ProcessDeviceData(DeviceBuffer, BufferSize);
// Clean up
UnmapDeviceMemory(DeviceBuffer);
Requirements
Requirement | Value |
---|---|
Target Platform | Universal |
Header | wdm.h (include Wdm.h, Ntddk.h, Ntifs.h) |
Library | volatileaccessk.lib (Kernel mode), volatileaccessu.lib (User mode) |
DLL | NtosKrnl.exe |
IRQL | Any level (See Remarks section) |