Export (0) Print
Expand All
Expand Minimize

EngAllocUserMem function

The EngAllocUserMem function allocates a block of memory from the address space of the current process and inserts a caller-supplied tag before the allocation.

Syntax


PVOID EngAllocUserMem(
  _In_  SIZE_T cj,
  _In_  ULONG tag
);

Parameters

cj [in]

Specifies the number of bytes to allocate.

tag [in]

Specifies a 4-byte pool tag that uniquely identifies the driver that does the memory allocation. For more information about pool tags, see ExAllocatePoolWithTag.

Return value

EngAllocUserMem returns a pointer to the allocated memory if there is enough user-mode memory to satisfy the request; otherwise, it returns a null pointer.

Remarks

A process in an NT-based operating system has 4 GB of virtual address space. The upper 2 GB is system memory that is accessible only to kernel-mode threads; this space is identical across all processes. The lower 2 GB is user memory that is accessible to both user-mode and kernel-mode threads; this space is unique to its process. The memory allocated by EngAllocUserMem is allocated from the unique 2 GB of user memory, and is thus accessible only when the graphics driver is called in the context of the thread in which the memory was allocated. Graphics drivers always execute in the context of the caller; that is, graphics drivers cannot switch process contexts.

EngAllocUserMem is particularly useful to a printer driver with large bitmaps that will only be used by the current process. Rather than allocating from the system pool, this driver can instead allocate space from the current process's address space. Drivers need to exercise care with memory allocated by EngAllocUserMem, as it is possible for the application to alter this memory. EngAllocUserMem should only be used to allocate relatively large chunks of memory, as each allocation takes at least 64 KB of virtual address space. Sensitive data structures should never be allocated using this function. Also, user memory allocated by this function cannot be passed to EngWritePrinter by the printer driver.

When the memory is no longer needed, it can be freed by a call to the EngFreeUserMem function.

To allocate user memory from the address space of a different process, use EngAllocPrivateUserMem.

Requirements

Version

Available in Windows 2000 and later versions of the Windows operating systems.

Header

Winddi.h (include Winddi.h)

Library

Win32k.lib

DLL

Win32k.sys

See also

EngFreeUserMem
EngAllocPrivateUserMem

 

 

Send comments about this topic to Microsoft

Show:
© 2014 Microsoft