Allocating and Using Memory

You can allocate either local memory or global memory for use at interrupt time.

Local Memory

To allocate local memory for use at interrupt time, follow these steps:

  1. Use LocalAlloc with the LMEM_FIXED flag to get a handle to the memory block. (This assumes fixed data segments.)
  2. Pass this handle to LocalLock to get a near pointer to the memory block.

Global Memory

Any global memory a driver uses at interrupt time must be page-locked. To allocate and page-lock global memory, follow these steps:

  1. Use GlobalAlloc with the GMEM_MOVEABLE and GMEM_SHARE flags to get a handle to the memory block.
  2. Pass this handle to GlobalLock to get a far pointer to the memory block.
  3. Pass the high-order word of the far pointer to GlobalPageLock to page-lock the memory block.