diff --git a/dev/RuntimeCompatibilityOptions/RuntimeCompatibilityOptions.idl b/dev/RuntimeCompatibilityOptions/RuntimeCompatibilityOptions.idl index ebade99272..3ccea694bc 100644 --- a/dev/RuntimeCompatibilityOptions/RuntimeCompatibilityOptions.idl +++ b/dev/RuntimeCompatibilityOptions/RuntimeCompatibilityOptions.idl @@ -44,6 +44,9 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime ListViewSelector_FixFocusedIndex = 61499680, ModelInitialization_Activities = 61509436, WindowsML_DiagnosabilityFix = 61592144, + + // 1.8.8 + AppRuntime_Insights = 61555948, }; /// Represents a version of the Windows App Runtime. diff --git a/dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h b/dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h index 3d5930af36..77a3e5716e 100644 --- a/dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h +++ b/dev/WindowsAppRuntime_Insights/WindowsAppRuntimeInsights.h @@ -13,8 +13,22 @@ #include #include +#include +#include + +// Bug 61555948: [1.8.8 servicing] AppRuntime_Insights - Add IsPackagedProcess and IsSelfContained to common insights PartB fields +#define WINAPPSDK_CHANGEID_61555948 61555948, WinAppSDK_1_8_8 namespace Microsoft::WindowsAppRuntime::Insights { + enum class TraceLoggingInformationFlags : std::uint32_t + { + None = 0, + IsDebuggerPresent = 0x00000001, + IsPackagedProcess = 0x00000002, + IsSelfContained = 0x00000004, + }; + DEFINE_ENUM_FLAG_OPERATORS(TraceLoggingInformationFlags) + class RuntimeInformation { public: @@ -32,6 +46,58 @@ return channel; } + // Inlined from the canonical implementations (see for reference): + // IsPackagedProcess: dev/Common/AppModel.Identity.IsPackagedProcess.h + // IsSelfContained: dev/Common/WindowsAppRuntime.SelfContained.h / .cpp + // Duplicated here to avoid exposing those headers as public API. + static std::uint32_t TraceLoggingInformationFlags() + { + static std::uint32_t flags{ []() -> std::uint32_t { + auto f{ Insights::TraceLoggingInformationFlags::None }; + + if (wil::details::IsDebuggerPresent()) + { + f |= Insights::TraceLoggingInformationFlags::IsDebuggerPresent; + } + + if (WinAppSdk::Containment::IsChangeEnabled()) + { + { + UINT32 n{}; + const auto rc{ ::GetCurrentPackageFullName(&n, nullptr) }; + if ((rc != APPMODEL_ERROR_NO_PACKAGE) && (rc != ERROR_INSUFFICIENT_BUFFER)) + { + LOG_HR(HRESULT_FROM_WIN32(rc)); + } + else if (rc == ERROR_INSUFFICIENT_BUFFER) + { + f |= Insights::TraceLoggingInformationFlags::IsPackagedProcess; + } + } + + { + auto module{ ::GetModuleHandleW(L"Microsoft.WindowsAppRuntime.dll") }; + if (module) + { + using IsSelfContainedFn = HRESULT(__stdcall*)(BOOL*); + auto fn{ reinterpret_cast(::GetProcAddress(module, "WindowsAppRuntime_IsSelfContained")) }; + if (fn) + { + BOOL result{}; + if (SUCCEEDED_LOG(fn(&result)) && result) + { + f |= Insights::TraceLoggingInformationFlags::IsSelfContained; + } + } + } + } + } + + return static_cast(f); + }() }; + return flags; + } + private: static std::string LoadStringFromResource(uint32_t id) { @@ -60,7 +126,7 @@ TraceLoggingStruct(4, "COMMON_WINDOWSAPPSDK_PARAMS"), \ TraceLoggingString(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::WindowsAppRuntimeVersion().c_str(), "Version"), \ TraceLoggingString(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::WindowsAppRuntimeChannel().c_str(), "WindowsAppSDKChannel"), \ - TraceLoggingBool(wil::details::IsDebuggerPresent(), "IsDebugging"), \ + TraceLoggingUInt32(::Microsoft::WindowsAppRuntime::Insights::RuntimeInformation::TraceLoggingInformationFlags(), "Flags"), \ TraceLoggingBool(true, "UTCReplace_AppSessionGuid") #include