_Allocate_LDT_Selector

include vmm.inc

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


The _Allocate_LDT_Selector service creates a new selector or selectors, and adds them to the Local Descriptor Table (LDT) for the specified virtual machine.

Parameters

VM

Specifies a handle identifying the virtual machine to receive the selectors.

DescDWORD1

Specifies the high four bytes of the descriptor for the selector. 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

Specifies the low four bytes of the descriptor for the selector. This parameter contains the low 16 bits of the base address and limit.

Count

Specifies the 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. This parameter can be 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.
  If this value is not given, the service allocates the number of selectors specified by Count.

All other values are reserved.

Return Value

If the service is successful, the EAX and EDX registers contain the following values:

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 is 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 EAX and EDX registers contain zero to indicate an error such as an invalid descriptor value, the LDT is full, an invalid virtual machine handle, or selector already allocated.

Comments

A virtual device can use the selector of the LDT to directly edit the selectors in the LDT. However, 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 which 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.

Uses

EAX, EDX

See Also

_Allocate_GDT_Selector, _Free_LDT_Selector