_Allocate_LDT_Selector

include vmm.inc

VMMCall _Allocate_LDT_Selector, <VM, DescDWORD1, DescDWORD2, 
    Count, flags>

Creates a new selector or selectors, and adds them to the Local Descriptor Table (LDT) for the specified virtual machine. Uses EAX, ECX, EDX, and Flags.

Register Description
EAX Contains the new selector. If Count is greater than 1, EAX contains only the first selector. The second selector is EAX+8, the third EAX+16, and so on. The high 16 bits of the selector are always zero.
EDX Contains the selector for and the size of the local descriptor table (LDT). The low 16 bits contains the selector for the LDT, and the high 16 bits contains the size of the LDT expressed as the number of selectors in the table.

The service returns zero in both registers if an error occurs

VM
Handle of the virtual machine to receive the selectors.
DescDWORD1
High-order doubleword of the segment descriptor. This parameter contains the high 16 bits of the base address, the high 4 bits of the limit, and the status and type bits.
DescDWORD2
Low-order doubleword of the segment descriptor. This parameter contains the low 16 bits of the base address and limit.
Count
Number of contiguous LDT selectors to allocate if the flags parameter does not specify the ALDTSpecSel value. Otherwise, this parameter specifies the LDT selector to allocate.
flags
Specifies the operation flags. Can be zero or the following value:
Value Meaning
ALDTSpecSel Allocates the LDT selector specified by the Count parameter. The service copies the descriptor data to the specified LDT entry and returns the selector. If the LDT selector is already allocated, the service returns an error value instead.

this value is not given, the service allocates the number of selectors specified by Count.


All other values are reserved.

The service returns an error if an invalid descriptor is specified, the LDT is full, an invalid virtual machine handle is specified, or a selector is already allocated.

Although this service returns a selector for the LDT, virtual devices should not attempt to edit the LDT directly. A virtual device should use the _SetDescriptor service to change an LDT selector rather than edit the LDT.

This service sets the RPL of the selector to the DPL of the selector set in the DescDWORD1 parameter.

LDT selectors are only valid when the virtual machine for which they are created is the current virtual machine. However, a virtual device can use the _SelectorMapFlat service to examine the region described by an LDT selector in virtual machines that are not the current virtual machine.

Although this service can create multiple selectors, the _Free_LDT_Selector service cannot free multiple selectors. Multiple selectors must be freed individually.

When this service creates multiple selectors, it gives each selector the same descriptor values. It does not change the base address for each selector. It is up to the virtual device to edit the selectors, and assign appropriate base addresses.

Virtual devices should not rely on specific hard-coded LDT selectors, and therefore, they should avoid using the ALDTSpecSel value.

See Also

_Allocate_GDT_Selector, _Free_LDT_Selector