Global32CodeAlias

3.0

  #include <winmem32.h>    

  WORD Global32CodeAlias(wSelector, lpAlias, wFlags)    
  WORD wSelector; /* selector of object for alias */
  LPWORD lpAlias; /* address of location for alias selector */
  WORD wFlags; /* reserved, must be zero */

The Global32CodeAlias function creates a 16:32 (USE32) code-segment alias selector for a 32-bit memory object previously created by the Global32Alloc function. This allows the application to execute code contained in the memory object.

Parameters

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.

lpAlias

Points to a 2-byte location in memory that receives the selector portion of the 16:32 code-segment alias for the specified object.

wFlags

Reserved; must be zero.

Return Value

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

Comments

If the function fails, the value pointed to by the lpAlias parameter is zero. If the function is successful, lpAlias points to a USE32 code-segment alias for the object specified by the wSelector parameter. The first byte of the object is at offset 0 from the selector returned in lpAlias. Valid offsets are determined by the size of the object as set by the most recent call to the Global32Alloc or Global32Realloc function.

The returned selector identifies a descriptor for a code segment that has the following attributes: read-execute, nonconforming, and USE32 (D bit set). 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 granularity will be consistent with the current data selector for the object. 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.

An application should not call this function more than once for an object. Depending on the system, the function might fail if an application calls it a second time for a given object without first calling the Global32CodeAliasFree function for the object.

See Also

Global32Alloc, Global32CodeAliasFree