LockPages (Windows Embedded CE 6.0)

1/6/2010

This function locks into memory the specified region of the virtual address space of the process, ensuring that subsequent access to the region does not incur a page fault. This function can be called only in kernel mode.

Syntax

BOOL LockPages(
  LPVOID lpvAddress,
  DWORD cbSize,
  PDWORD pPFNs,
  int fOptions
);

Parameters

  • lpvAddress
    [in] Starting address of a region of committed pages; that is, to be locked.
  • cbSize
    [in] Number of bytes to lock.
  • pPFNs
    [out] Array of page physical frame numbers representing the CPU-dependent physical addresses of the pages.

    This parameter can be set to NULL if the associated physical pages of the locked region does not matter to the caller.

  • fOptions
    [in] Option flag.

    The following table shows possible values for this parameter.

    Value Description

    LOCKFLAG_QUERY_ONLY

    Query the physical to virtual mapping of a memory allocation. No pages are locked.

    LOCKFLAG_READ

    Read access is required, as opposed to page present but PAGE_NOACCESS.

    LOCKFLAG_WRITE

    Write access is required. This means that locking excludes other writers.

Return Value

TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError.

Remarks

To determine the actual physical address, the value returned in pPFNs must be shifted to the left by a number of bits. The shift count can be found in UserKInfo[KINX_PFN_SHIFT]. Shift the returned values to the left by this value to get the actual physical address.

The physical pages are stored in increasing order, but are not guaranteed to be contiguous.

LockPages has a reference count, so if the same thread calls LockPages twice, the second call to UnlockPages unlocks the pages.

Requirements

Header pkfuncs.h
Library coredll.lib
Windows Embedded CE Windows CE 2.10 and later

See Also

Reference

Kernel Functions
UnlockPages
LoadDriver

Concepts

Kernel Mode APIs

Other Resources