#include <winmem32.h> |
WORD Global16PointerAlloc(wSelector, dwOffset, lpBuffer, dwSize, wFlags) | |||||
WORD wSelector; | /* selector of object, */ | ||||
DWORD dwOffset; | /* offset of first byte for alias | */ | |||
LPDWORD lpBuffer; | /* address of location for alias | */ | |||
DWORD dwSize; | /* size of region, */ | ||||
WORD wFlags; | /* reserved, must be zero | */ |
The Global16PointerAlloc function converts a 16:32 pointer into a 16:16 pointer alias that the application can pass to a Windows function or to other 16:16 functions.
wSelector
Specifies the selector of the object for which an alias is to be created. This must be the selector returned by a previous call to the Global32Alloc function.
dwOffset
Specifies the offset of the first byte for which an alias is to be created. The offset is from the first byte of the object specified by the wSelector parameter. Note that wSelector:dwOffset forms a 16:32 address of the first byte of the region for which an alias is to be created.
lpBuffer
Points to a four-byte location in memory that receives the 16:16 pointer alias for the specified region.
dwSize
Specifies the addressable size, in bytes, of the region for which an alias is to be created. This value must be no larger than 64K.
wFlags
Reserved; must be zero.
The return value is zero if the function is successful. Otherwise, it is an error value, which can be one of the following:
WM32_Insufficient_Mem
WM32_Insufficient_Sels
WM32_Invalid_Arg
WM32_Invalid_Flags
WM32_Invalid_Func
When this function returns successfully, the location pointed to by the lpBuffer parameter contains a 16:16 pointer to the first byte of the region. This is the same byte to which wSelector:dwOffset points.
The returned selector identifies a descriptor for a data segment that has the following attributes: read-write, expand up, and small (B bit clear). The descriptor privilege level (DPL) and the granularity (the G bit) are set at the system's discretion, so you should make no assumptions regarding their settings. The DPL and requestor privilege level (RPL) are appropriate for a Windows application.
Note:
An application must not change the setting of any bits in the DPL or the RPL selector. Doing so can result in a system crash and will prevent the application from running on compatible platforms.
Because of tiling schemes implemented by some systems, the offset portion of the returned 16:16 pointer is not necessarily zero.
When writing your application, you should not assume the size limit of the returned selector. Instead, assume that at least dwSize bytes can be addressed starting at the 16:16 pointer created by this function.