| 1568 | }; |
| 1569 | |
| 1570 | static void ParseSegmentInfo( |
| 1571 | const SEGMENT_DESCRIPTOR_LONG* Gdt, |
| 1572 | const SEGMENT_DESCRIPTOR_LONG* Ldt, |
| 1573 | unsigned short Selector, |
| 1574 | __out SEGMENT_INFO* Info |
| 1575 | ) { |
| 1576 | *Info = {}; |
| 1577 | |
| 1578 | SEGMENT_SELECTOR SegmentSelector; |
| 1579 | SegmentSelector.Value = Selector; |
| 1580 | |
| 1581 | auto* SegmentDescriptor = SegmentSelector.Bitmap.TableIndicator == 0 |
| 1582 | ? reinterpret_cast<const SEGMENT_DESCRIPTOR_LONG*>(&Gdt[SegmentSelector.Bitmap.SelectorIndex]) |
| 1583 | : reinterpret_cast<const SEGMENT_DESCRIPTOR_LONG*>(&Ldt[SegmentSelector.Bitmap.SelectorIndex]); |
| 1584 | |
| 1585 | Info->BaseAddress = ExtractSegmentBaseAddress(SegmentDescriptor); |
| 1586 | Info->Limit = GetSegmentLimit(Selector); |
| 1587 | |
| 1588 | Info->AccessRights.Bitmap.SegmentType = SegmentDescriptor->Generic.Type; |
| 1589 | Info->AccessRights.Bitmap.S = SegmentDescriptor->Generic.System; |
| 1590 | Info->AccessRights.Bitmap.DPL = SegmentDescriptor->Generic.Dpl; |
| 1591 | Info->AccessRights.Bitmap.P = SegmentDescriptor->Generic.Present; |
| 1592 | Info->AccessRights.Bitmap.AVL = SegmentDescriptor->Generic.Available; |
| 1593 | Info->AccessRights.Bitmap.L = SegmentDescriptor->Generic.LongMode; |
| 1594 | Info->AccessRights.Bitmap.DB = SegmentDescriptor->Generic.System == 1 // If it is a user segment descriptor: |
| 1595 | ? reinterpret_cast<const USER_SEGMENT_DESCRIPTOR_LONG*>(SegmentDescriptor)->Generic.DefaultOperandSize |
| 1596 | : 0; // The DefaultOperandSize is not applicable to system segments and marked as reserved! |
| 1597 | Info->AccessRights.Bitmap.G = SegmentDescriptor->Generic.Granularity; |
| 1598 | Info->AccessRights.Bitmap.SegmentUnusable = static_cast<unsigned int>(!Info->AccessRights.Bitmap.P); |
| 1599 | |
| 1600 | Info->Selector = Selector; |
| 1601 | } |
| 1602 | |
| 1603 | inline unsigned long long GetVpid() |
| 1604 | { |
no test coverage detected