WORD AllocDStoCSAlias(wSelector)
This function accepts a data-segment selector and returns a code-segment selector that
can be used to execute code in the data segment. When in protected mode, attempting
to execute code directly in a data segment will cause a general protection violation.
AllocDStoCSAlias allows an application to execute code which the application had created in its own stack segment.
The application must free the new selector by calling the FreeSelector function.
Parameter | Type/Description |
wSelector | WORD Specifies the data-segment selector. |
The return value is the code-segment selector corresponding to the data-segment selector. If the function cannot allocate a new selector, the return value is zero.
Windows does not track segment movements. Consequently, the data segment must be fixed and nondiscardable; otherwise, the data segment might move, invalidating the code-segment selector.
The ChangeSelector function provides another method of obtaining a code selector corresponding to a data selector.
An application should not use this function unless it is absolutely necessary. Use of this function violates preferred Windows programming practices.