-
Notifications
You must be signed in to change notification settings - Fork 428
[1.8-stable] Add IsPackagedProcess and IsSelfContained to common insights PartB fields #6334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: release/1.8-stable
Are you sure you want to change the base?
Changes from 3 commits
8887adc
232341c
842c138
3c12855
5ac15b4
4947b5f
fd5625d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| // Copyright (c) Microsoft Corporation and Contributors. | ||
| // Licensed under the MIT License. | ||
|
|
||
| #ifndef __APPMODEL_IDENTITY_ISPACKAGEDPROCESS_H | ||
| #define __APPMODEL_IDENTITY_ISPACKAGEDPROCESS_H | ||
|
|
||
| #include <appmodel.h> | ||
|
|
||
| namespace AppModel::Identity | ||
| { | ||
| inline HRESULT IsPackagedProcess_nothrow(bool& isPackagedProcess) noexcept | ||
| { | ||
| isPackagedProcess = false; | ||
| UINT32 n{}; | ||
| const auto rc{ ::GetCurrentPackageFullName(&n, nullptr) }; | ||
| RETURN_HR_IF(HRESULT_FROM_WIN32(rc), (rc != APPMODEL_ERROR_NO_PACKAGE) && (rc != ERROR_INSUFFICIENT_BUFFER)); | ||
| isPackagedProcess = (rc == ERROR_INSUFFICIENT_BUFFER); | ||
| return S_OK; | ||
| } | ||
|
|
||
| inline bool IsPackagedProcess() | ||
| { | ||
| UINT32 n{}; | ||
| const auto rc{ ::GetCurrentPackageFullName(&n, nullptr) }; | ||
| THROW_HR_IF_MSG(HRESULT_FROM_WIN32(rc), (rc != APPMODEL_ERROR_NO_PACKAGE) && (rc != ERROR_INSUFFICIENT_BUFFER), "GetCurrentPackageFullName rc=%d", rc); | ||
| return rc == ERROR_INSUFFICIENT_BUFFER; | ||
| } | ||
| } | ||
|
|
||
| #endif // __APPMODEL_IDENTITY_ISPACKAGEDPROCESS_H |
agniuks marked this conversation as resolved.
Show resolved
Hide resolved
|
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,8 +13,22 @@ | |
|
|
||
| #include <wil/resource.h> | ||
| #include <string> | ||
| #include <appmodel.h> | ||
| #include <FrameworkUdk/Containment.h> | ||
|
|
||
| // Bug 61555948: [1.8.6 servicing] AppRuntime_Insights - Add IsPackagedProcess and IsSelfContained to common insights PartB fields | ||
agniuks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| #define WINAPPSDK_CHANGEID_61555948 61555948, WinAppSDK_1_8_7 | ||
agniuks marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| namespace Microsoft::WindowsAppRuntime::Insights | ||
| { | ||
| enum class TraceLoggingInformationFlags : std::uint32_t | ||
| { | ||
| None = 0, | ||
| IsDebuggerPresent = 0x00000001, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this flag factoring is compact - just want to confirm it's actually useful in reports. i.e., can you filter on specific bit values, or is it just an opaque number? if the latter, I'd stick with unique values.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah we can query individual bits, Kusto has bitwise operators like binary_and. And since there's only 3 bits, each combo maps to a unique value (0–7) so we can also filter on the number directly if that's easier. This was Howard's design from #6233 to keep the struct at 4 fields |
||
| 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<WINAPPSDK_CHANGEID_61555948>()) | ||
| { | ||
| { | ||
| 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<IsSelfContainedFn>(::GetProcAddress(module, "WindowsAppRuntime_IsSelfContained")) }; | ||
| if (fn) | ||
| { | ||
| BOOL result{}; | ||
| if (SUCCEEDED_LOG(fn(&result)) && result) | ||
| { | ||
| f |= Insights::TraceLoggingInformationFlags::IsSelfContained; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return static_cast<std::uint32_t>(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"), \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is definitely not contained. For that reason alone, I'd go with conditional logging of separate bools. Probably makes reporting easier too.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The data values should be contained, when the change is off we just report the debugger bit (0 or 1), same as the old IsDebugging bool. The field name/type is compile-time metadata though, so I'm not sure how to contain that part without duplicating every TraceLoggingWrite call across the ~20 callsites. Open to ideas! |
||
| TraceLoggingBool(true, "UTCReplace_AppSessionGuid") | ||
|
|
||
| #include <wil/tracelogging.h> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.