Compartilhar via


Função FillModeMemory (usermode_accessors.h)

The FillModeMemory function fills a memory region with a specified byte value, based on the specified processor mode.

Syntax

VOID FillModeMemory(
  VOID            *Destination,
  SIZE_T          Length,
  UCHAR           Fill,
  KPROCESSOR_MODE Mode
);

Parameters

Destination

[out] Um ponteiro para o endereço inicial do bloco de memória a ser preenchido.

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.

Mode

[in] O modo de processador que determina como o acesso à memória é executado. Mode can be one of the following values.

Value Meaning
KernelMode Destination points to kernel-mode memory. The function performs a direct memory fill operation with memory_order_relaxed semantics. Consulte Comentários para obter mais detalhes.
UserMode Destination points to user-mode memory. The function raises an exception if Destination doesn't point to user-mode memory; otherwise it performs a fill operation at the specified address with memory_order_relaxed semantics. Consulte Comentários para obter mais detalhes.

Return value

None

Remarks

Essa função fornece uma maneira segura de preencher uma região de memória com um valor de byte especificado, com o mecanismo de preenchimento determinado pelo modo de processador especificado.

Essa função tem as seguintes propriedades:

  • When Mode is KernelMode, the function performs a direct memory fill without additional safety checks.

  • When Mode is UserMode, the function validates the pointer is a user-mode address and then performs the fill. The memory access is performed with memory_order_relaxed semantics.

  • Essa função não é reconhecida como um compilador instrinsic, portanto, o compilador nunca otimizará a chamada (totalmente ou substituirá a chamada por uma sequência equivalente de instruções).

  • When the call returns, the first Length bytes of the buffer have 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).

  • A função poderá executar acessos de memória não assinados se a plataforma permitir.

  • A função pode acessar locais de memória mais de uma vez como parte de sua operação de preenchimento.

A função gerará uma exceção estruturada se a operação de preenchimento falhar, como quando o endereço de destino não for um endereço válido no modo de usuário ou estiver inacessível.

Essa função funciona em todas as versões do Windows, não apenas nas mais recentes. 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. No entanto, o driver resultante será executado bem em versões mais antigas do Windows.

Requirements

Requirement Value
Cliente mínimo suportado See Remarks
Header usermode_accessors.h
Library umaccess.lib
IRQL Menor ou igual a APC_LEVEL

See also

FillUserMemory

SetModeMemory

ZeroModeMemory

CopyToMode