Skip to content

Commit

Permalink
Handle Win8.1 use of 64-bits for FlipChain ul properties
Browse files Browse the repository at this point in the history
See issue #124
  • Loading branch information
JeffersonMontgomery-Intel committed Mar 8, 2023
1 parent e1a9dd9 commit 2097b8d
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions PresentData/PresentMonTraceConsumer.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2017-2022 Intel Corporation
// Copyright (C) 2017-2023 Intel Corporation
// SPDX-License-Identifier: MIT

#include "PresentMonTraceConsumer.hpp"
Expand Down Expand Up @@ -1494,14 +1494,26 @@ void PMTraceConsumer::HandleDWMEvent(EVENT_RECORD* pEventRecord)
break;
}

// ulFlipChain and ulSerialNumber are expected to be uint32_t data, but
// on Windows 8.1 the event properties are specified as uint64_t.
auto GetU32FromU32OrU64 = [](EventDataDesc const& desc) {
if (desc.size_ == 4) {
return desc.GetData<uint32_t>();
} else {
auto u64 = desc.GetData<uint64_t>();
DebugAssert(u64 <= UINT32_MAX);
return (uint32_t) u64;
}
};

EventDataDesc desc[] = {
{ L"ulFlipChain" },
{ L"ulSerialNumber" },
{ L"hwnd" },
};
mMetadata.GetEventData(pEventRecord, desc, _countof(desc));
auto ulFlipChain = desc[0].GetData<uint32_t>();
auto ulSerialNumber = desc[1].GetData<uint32_t>();
auto ulFlipChain = GetU32FromU32OrU64(desc[0]);
auto ulSerialNumber = GetU32FromU32OrU64(desc[1]);
auto hwnd = desc[2].GetData<uint64_t>();

// Lookup the present using the 64-bit token data from the PHT
Expand Down

0 comments on commit 2097b8d

Please sign in to comment.