LockPages (Windows CE 5.0)

Send Feedback

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.

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


  • 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] Options flag. The following table shows the possible values.

    Value Description
    LOCKFLAG_WRITE Write access is required (locking excludes other writers).
    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.

Return Values

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


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

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


OS Versions: Windows CE 2.10 and later.
Header: Pkfuncs.h.
Link Library: Coredll.lib.

See Also

UnlockPages | LoadDriver | Trusted APIs

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.