Using Huge Pointers with Blocks of Memory Larger Than 64K (79194)



The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) 3.0
  • Microsoft Windows Software Development Kit (SDK) 3.1

This article was previously published under Q79194

SUMMARY

The GlobalAlloc() function can be used to allocate memory blocks larger than 64 kilobytes (64K). This memory can then be accessed using "huge" pointers. For more information on huge pointers, see your Microsoft C compiler documentation.

MORE INFORMATION

GlobalAlloc() always returns a single contiguous block of memory, if it is possible to satisfy the request. This block can be accessed using huge pointers. Huge pointers are composed of a segment:offset address (real mode), or a selector:offset address (standard mode or 386 enhanced mode), just like a far pointer. Huge pointers allow access to more than 64K, by adjusting the segment or selector part of the address, as well as the offset.

In real mode, the segment address increases or decreases by 0x1000 every time the offset crosses the 64K boundary. In standard mode or 386 enhanced mode, memory is addressed using selectors instead of segments. When GlobalAlloc() allocates a block of memory, it also creates selectors to access that block. If the block of memory is larger than 64K, GlobalAlloc() will create a set of tiled selectors. The first selector in the set provides access to the first 64K of the block. Subsequent selectors provide access to additional 64K portions of the memory block.

Tiled selectors are allocated in a predefined pattern; the value of the second selector equals the value of the first selector plus the value of __AHINCR, and so forth. Therefore, when the offset of a huge pointer crosses a 64K boundary in standard mode or 386 enhanced mode, the value of the selector is increased or decreased by the value of __AHINCR.

Modification Type:MajorLast Reviewed:10/29/2003
Keywords:kb16bitonly KB79194