AllocPhysMem (Windows CE 5.0)

Send Feedback

This function allocates physically contiguous memory.

LPVOID AllocPhysMem(DWORD cbSize,DWORD fdwProtect,DWORD dwAlignmentMask,DWORD dwFlags,PULONG pPhysicalAddress);

Parameters

  • cbSize
    [in] Number of bytes to allocate. The physical memory allocated is rounded up to the nearest page and is aligned on a 64-KB address.
  • fdwProtect
    [in] Specifies the protection desired. The following table shows the values you can specify.
    Value Description
    PAGE_READONLY Enables read access to the committed region of pages. An attempt to write to the committed region results in an access violation. If the system differentiates between read-only access and execute access, an attempt to execute code in the committed region results in an access violation.
    PAGE_READWRITE Enables both read and write access to the committed region of pages.
    PAGE_EXECUTE Enables execute access to the committed region of pages. An attempt to read or write to the committed region results in an access violation.
    PAGE_EXECUTE_READ Enables execute and read access to the committed region of pages. An attempt to write to the committed region results in an access violation.
    PAGE_EXECUTE_READWRITE Enables execute, read, and write access to the committed region of pages.
    PAGE_GUARD Pages in the region become guard pages. Any attempt to read from or write to a guard page causes the system to raise a STATUS_GUARD_PAGE exception and turn off the guard page status. Guard pages thus act as a one-shot access alarm.

    The PAGE_GUARD flag is a page protection modifier. An application uses it with one of the other page protection flags, with one exception: It cannot be used with PAGE_NOACCESS. When an access attempt leads the system to turn off guard page status, the underlying page protection takes over.

    If a guard page exception occurs during a system service, the service typically returns a failure status indicator.

    PAGE_NOACCESS Disables all access to the committed region of pages. An attempt to read from, write to, or execute in the committed region results in an access violation exception, called a general protection (GP) fault.
    PAGE_NOCACHE Memory returned by AllocPhysMem is always uncached. This flag is a no operation.
  • dwAlignmentMask
    [in] Bit mask that describes the byte alignment needed. If it is set to 0 (zero), the default system alignment is used. If it is set to any other value, the kernel will try to fulfill the memory request based on the alignment request. The dwAlignmentMask parameter is AND with a physical address to determine if the memory is aligned correctly for the request.
  • dwFlags
    Reserved for future use. Must be set to 0 (zero).
  • pPhysicalAddress
    [out] Pointer to a DWORD that stores the physical address of the memory allocation.

Return Values

If the allocation failed, NULL is returned; otherwise, a valid virtual pointer is returned.

Call GetLastError for extended error information.

Remarks

If there is no physically contiguous memory to fulfill the request then no attempt will be made to move memory around to fulfill the request.

Note   To call AllocPhysMem, you must first set WINCEOEM=1.

Requirements

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

See Also

FreePhysMem | Trusted APIs

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.