RtlZeroDeviceMemory 函数 (wdm.h)
RtlZeroDeviceMemory 函数是 RtlFillDeviceMemory 的便捷包装器。
语法
volatile void * RtlZeroDeviceMemory(
[out] volatile void *Destination,
[in] size_t Length
);
参数
[out] Destination
指向要用零填充的内存块的起始地址的指针。
[in] Length
要用零填充的内存块的大小(以字节为单位)。
返回值
返回 Destination 的值。
注解
RtlZeroDeviceMemory 函数是 RtlFillDeviceMemory 的便捷包装器。
有关详细信息,请参阅 RtlFillDeviceMemory 的备注部分。
注意
此函数适用于所有版本的 Windows,而不仅仅是最新版本。 需要使用最新的 WDK 才能从 wdm.h 标头获取函数声明。 还需要从最新 WDK (volatileaccessk.lib) 库。 但是,生成的驱动程序将在较旧版本的 Windows 上运行正常。
示例
// In this scenario we are setting data on memory mapped
// as "device memory" (for example, memory not backed by RAM) to the value zero. On
// some platforms like ARM64, device memory cannot tolerate
// memory accesses that are not naturally aligned (for example, a 4-byte
// load must be 4-byte aligned). Functions like memset, RtlFillMemory,
// and even RtlFillVolatileMemory may perform unaligned memory accesses
// because it is typically faster to do this.
// To ensure only naturally aligned accesses happen, use RtlFillDeviceMemory.
//
// RtlZeroDeviceMemory is an wrapper around RtlFillDeviceMemory that sets the memory
// to zero.
RtlZeroDeviceMemory(DeviceMemoryBuffer, 100);
要求
要求 | 值 |
---|---|
Header | wdm.h (包括 Wdm.h) |
Library | volatileaccessk.lib (内核模式) ,volatileaccessu.lib (用户模式) |