MoveToUserFromUser 函数 (usermode_accessors.h)

The MoveToUserFromUser function safely moves data from user-mode memory to user-mode memory, supporting overlapping memory regions.

Syntax

VOID MoveToUserFromUser(
  volatile VOID       *Destination,
  volatile const VOID *Source,
  SIZE_T              Length
);

Parameters

Destination

[out]指向将复制数据的用户模式内存位置起始地址的指针。

Source

[in]指向从中复制数据的用户模式内存位置起始地址的指针。

Length

[in]要移动的字节数。

Return value

None

Remarks

此函数提供了一种安全的方法,用于将数据从用户模式内存移动到用户模式内存,并支持重叠的内存区域。

该函数具有以下属性:

  • The function performs a move using memory_order_relaxed semantics.

  • 函数不能识别为编译器内部函数,因此编译器永远不会优化调用(完全或用等效指令序列替换调用)。

  • When the call returns, the data has been copied from Source to Destination. This function's memory accesses to the Source and 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

See also

CopyToUserFromUser

CopyToUser

CopyFromUser