UINT AllocDStoCSAlias(uSelector) | ||||
UINT uSelector; | /* data-segment selector, */ |
The AllocDStoCSAlias function accepts a data-segment selector and returns a code-segment selector that can be used to execute code in the data segment.
uSelector
Specifies the data-segment selector.
The return value is the code-segment selector corresponding to the data-segment selector if the function is successful. Otherwise, it is zero.
The application should not free the new selector by calling the FreeSelector function. Windows will free the selector when the application terminates.
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 that the application had created in its own stack segment.
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 PrestoChangoSelector 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, since its use violates preferred Windows programming practices.