Partager via


VirtualSetAttributes (Compact 2013)

3/28/2014

This function enables driver developers to change the per-page attributes for a range of virtual memory, which is usually copied from a physical location not known to the kernel. This function can be called only in kernel mode.

Syntax

BOOL VirtualSetAttributes(
  LPVOID lpvAddress,
  DWORD cbSize,
  DWORD dwNewFlags,
  DWORD dwMask,
  LPDWORD lpdwOldFlags
);

Parameters

  • lpvAddress
    [in] The start address of the virtual memory to be changed.
  • cbSize
    [in] The length, in bytes, of the virtual memory to be changed.
  • dwNewFlags
    [in] Specifies the new value of the bits to be set.
  • dwMask
    [in] Specifies which bits are to be changed.
  • lpdwOldFlags
    [in] If this parameter is not NULL, *lpdwOldFlags contains the original value of the page entry of the first page upon return.

Return Value

TRUE indicates success. FALSE indicates failure.

Remarks

The dwMask parameter specifies the bits to be changed. For example, if the original value is 0x00100010, dwMask is set to 0x30, and dwNewFlags is set to 0x030, the new value will be 0x00100030. The new value is calculated using the following formula:

newValue = (oldValue & ~dwMask)|(dwNewFlags & dwMask);

If dwMask is set to zero, it behaves like a query function. This means that nothing is changed, and the original page entry is returned through lpdwOldFlags.

Note

Do not change the physical page number, which includes bits 10 through 31 for most CPUs. Otherwise, it causes unexpected system behavior.

The VirtualSetAttributes function changes the translation look-aside buffer (TLB) entry directly. The calling function should be aware of what CPU architecture it is running on and which attributes to change.

The VirtualSetAttributes function can be used on the x86 and XScale microprocessors to speed up the display buffer.

Requirements

Header

pkfuncs.h

Library

coredll.lib

See Also

Reference

Kernel Functions

Other Resources

VirtualSetAttrib