The FillUserMemory function fills a user-mode memory region with a specified byte value.
Syntax
VOID FillUserMemory(
volatile VOID *Destination,
SIZE_T Length,
UCHAR Fill
);
Parameters
Destination
[out]指向要填充的内存块起始地址的指针。
Length
[in] The number of bytes to fill with the Fill value.
Fill
[in] The byte value used to fill the first Length bytes of Destination.
Return value
None
Remarks
此函数提供了使用指定字节值填充用户模式内存区域的安全方法。 这允许在内核模式代码需要初始化用户模式内存缓冲区时灵活内存作。
该函数具有以下属性:
The function performs a fill using memory_order_relaxed semantics.
函数不能识别为编译器内部函数,因此编译器永远不会优化调用(完全或用等效指令序列替换调用)。
When the call returns, the buffer has been overwritten with the specified Fill value. This function's memory accesses to the Destination will only be performed within the function (for example, the compiler can't move memory accesses out of this function).
如果平台允许它,该函数可能会执行未对齐的内存访问。
该函数在填充作过程中可能会多次访问内存位置。
如果填充作失败(例如目标地址不是有效的用户模式地址或不可访问),该函数将引发结构化异常。
此函数适用于所有版本的 Windows,而不仅仅是最新版本。 You need to consume the latest WDK to get the function declaration from the usermode_accessors.h header. You also need the library (umaccess.lib) from the latest WDK. 但是,生成的驱动程序将在较旧版本的 Windows 上运行。
Requirements
| Requirement | Value |
|---|---|
| 最低支持的客户端 | See Remarks |
| Header | usermode_accessors.h |
| Library | umaccess.lib |
| IRQL | 小于或等于APC_LEVEL |