| 1529 | } |
| 1530 | |
| 1531 | void PMTraceConsumer::HandleWin32kEvent(EVENT_RECORD* pEventRecord) |
| 1532 | { |
| 1533 | auto const& hdr = pEventRecord->EventHeader; |
| 1534 | |
| 1535 | if (mTrackDisplay) { |
| 1536 | switch (hdr.EventDescriptor.Id) { |
| 1537 | case Microsoft_Windows_Win32k::TokenCompositionSurfaceObject_Info::Id: |
| 1538 | { |
| 1539 | EventDataDesc desc[] = { |
| 1540 | { L"CompositionSurfaceLuid" }, |
| 1541 | { L"PresentCount" }, |
| 1542 | { L"BindId" }, |
| 1543 | { L"DestWidth" }, // version >= 1 |
| 1544 | { L"DestHeight" }, // version >= 1 |
| 1545 | }; |
| 1546 | mMetadata.GetEventData(pEventRecord, desc, _countof(desc) - (hdr.EventDescriptor.Version == 0 ? 2 : 0)); |
| 1547 | auto CompositionSurfaceLuid = desc[0].GetData<uint64_t>(); |
| 1548 | auto PresentCount = desc[1].GetData<uint64_t>(); |
| 1549 | auto BindId = desc[2].GetData<uint64_t>(); |
| 1550 | |
| 1551 | // Lookup the in-progress present. It should not have seen any Win32K |
| 1552 | // events yet, so if it has we assume we looked up a present whose |
| 1553 | // tracking was lost. |
| 1554 | std::shared_ptr<PresentEvent> present; |
| 1555 | for (;;) { |
| 1556 | present = FindOrCreatePresent(hdr); |
| 1557 | if (present == nullptr) { |
| 1558 | return; |
| 1559 | } |
| 1560 | |
| 1561 | if (!present->SeenWin32KEvents) { |
| 1562 | break; |
| 1563 | } |
| 1564 | |
| 1565 | RemoveLostPresent(present); |
| 1566 | } |
| 1567 | |
| 1568 | present->PresentMode = PresentMode::Composed_Flip; |
| 1569 | present->SeenWin32KEvents = true; |
| 1570 | |
| 1571 | if (hdr.EventDescriptor.Version >= 1) { |
| 1572 | present->DestWidth = desc[3].GetData<uint32_t>(); |
| 1573 | present->DestHeight = desc[4].GetData<uint32_t>(); |
| 1574 | } |
| 1575 | |
| 1576 | Win32KPresentHistoryToken key(CompositionSurfaceLuid, PresentCount, BindId); |
| 1577 | DebugAssert(mPresentByWin32KPresentHistoryToken.find(key) == mPresentByWin32KPresentHistoryToken.end()); |
| 1578 | mPresentByWin32KPresentHistoryToken[key] = present; |
| 1579 | present->CompositionSurfaceLuid = CompositionSurfaceLuid; |
| 1580 | present->Win32KPresentCount = PresentCount; |
| 1581 | present->Win32KBindId = BindId; |
| 1582 | return; |
| 1583 | } |
| 1584 | |
| 1585 | case Microsoft_Windows_Win32k::TokenStateChanged_Info::Id: |
| 1586 | { |
| 1587 | EventDataDesc desc[] = { |
| 1588 | { L"CompositionSurfaceLuid" }, |
no test coverage detected