(wdm.h) RtlZeroDeviceMemory 函式

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);

規格需求

需求
標頭 wdm.h (包含 Wdm.h)
程式庫 volatileaccessk.lib (核心模式) 、volatileaccessu.lib (使用者模式)

另請參閱

RtlFillDeviceMemory