Skip to content

Commit 2a2a5dc

Browse files
authored
[1.8-stable CP] Fix: Deployment exceptions masked as ERROR_UNHANDLED_EXCEPTION; SetLastFailure logging single chars (#6330)
* Fix: Deployment exceptions masked as ERROR_UNHANDLED_EXCEPTION; SetLastFailure logging single chars * containment * fix ado id * address feedback/ * better containment * fix containment * Add FrameworkUdk NuGet reference to BootstrapDLL for Containment.h * Copy FrameworkUdk.dll to DynamicDependency test output dirs * remove frameworkudk import in bootstrapper * Remove wil/cppwinrt.h from NuGet-shipped auto-initializer files
1 parent ae37dc4 commit 2a2a5dc

6 files changed

Lines changed: 72 additions & 12 deletions

File tree

dev/Deployment/DeploymentActivityContext.cpp

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55

66
#include "DeploymentActivityContext.h"
77

8+
#include <FrameworkUdk/Containment.h>
9+
10+
// Bug 61543987: [1.8 servicing] Deployment exceptions masked as ERROR_UNHANDLED_EXCEPTION; SetLastFailure logging single chars
11+
#define WINAPPSDK_CHANGEID_61543987 61543987, WinAppSDK_1_8_7
12+
813
WindowsAppRuntime::Deployment::Activity::Context& WindowsAppRuntime::Deployment::Activity::Context::Get()
914
{
1015
return g_DeploymentActivityContext;
@@ -37,7 +42,14 @@ void WindowsAppRuntime::Deployment::Activity::Context::SetLastFailure(const wil:
3742

3843
if (failure.pszFile)
3944
{
40-
m_lastFailure.file = *failure.pszFile;
45+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
46+
{
47+
m_lastFailure.file = failure.pszFile;
48+
}
49+
else
50+
{
51+
m_lastFailure.file = *failure.pszFile;
52+
}
4153
}
4254
else
4355
{
@@ -48,7 +60,14 @@ void WindowsAppRuntime::Deployment::Activity::Context::SetLastFailure(const wil:
4860

4961
if (failure.pszMessage)
5062
{
51-
m_lastFailure.message = *failure.pszMessage;
63+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
64+
{
65+
m_lastFailure.message = failure.pszMessage;
66+
}
67+
else
68+
{
69+
m_lastFailure.message = *failure.pszMessage;
70+
}
5271
}
5372
else
5473
{
@@ -57,7 +76,14 @@ void WindowsAppRuntime::Deployment::Activity::Context::SetLastFailure(const wil:
5776

5877
if (failure.pszModule)
5978
{
60-
m_lastFailure.module = *failure.pszModule;
79+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
80+
{
81+
m_lastFailure.module = failure.pszModule;
82+
}
83+
else
84+
{
85+
m_lastFailure.module = *failure.pszModule;
86+
}
6187
}
6288
else
6389
{

dev/Deployment/DeploymentManager.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
// Bug 61124029: [1.8 servicing] Fixing reset activity data on deployment initialization
1919
#define WINAPPSDK_CHANGEID_61124029 61124029, WinAppSDK_1_8_6
2020

21+
// Bug 61543987: [1.8 servicing] Deployment exceptions masked as ERROR_UNHANDLED_EXCEPTION; SetLastFailure logging single chars
22+
#define WINAPPSDK_CHANGEID_61543987 61543987, WinAppSDK_1_8_7
23+
2124
using namespace winrt;
2225
using namespace winrt::Windows::Foundation;
2326

@@ -209,17 +212,25 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
209212
{
210213
deploymentResult = _Initialize(initializeActivityContext, packageFullName, deploymentInitializeOptions, isRepair);
211214
}
212-
catch (winrt::hresult_error const& e)
215+
catch (...)
213216
{
214-
const HRESULT hr{ e.code() };
217+
const HRESULT hr = []() -> HRESULT {
218+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
219+
{
220+
return wil::ResultFromCaughtException();
221+
}
222+
try { throw; }
223+
catch (winrt::hresult_error const& e) { return e.code(); }
224+
// Non-winrt::hresult_error exceptions propagate (old behavior)
225+
}();
215226

216227
auto packageIdentity{ AppModel::Identity::PackageIdentity::FromPackageFullName(packageFullName.c_str()) };
217228
PCWSTR c_packageNamePrefix{ L"microsoft.windowsappruntime." };
218229
const size_t c_packageNamePrefixLength{ ARRAYSIZE(L"microsoft.windowsappruntime.") - 1 };
219230
std::wstring release;
220231
if (CompareStringOrdinal(packageIdentity.Name(), -1, c_packageNamePrefix, -1, TRUE) == CSTR_EQUAL)
221232
{
222-
release = packageIdentity.Name() + c_packageNamePrefixLength;
233+
release = packageIdentity.Name() + c_packageNamePrefixLength;
223234
}
224235
else
225236
{
@@ -242,7 +253,7 @@ namespace winrt::Microsoft::Windows::ApplicationModel::WindowsAppRuntime::implem
242253

243254
THROW_HR_MSG(hr, "PackageFullName=%ls Options: ForceDeployment=%c OnErrorShowUI=%c isRepair:%c",
244255
packageFullName.c_str(), deploymentInitializeOptions.ForceDeployment() ? 'Y' : 'N',
245-
deploymentInitializeOptions.OnErrorShowUI() ? 'Y' : 'N', isRepair ? 'Y' : 'N' );
256+
deploymentInitializeOptions.OnErrorShowUI() ? 'Y' : 'N', isRepair ? 'Y' : 'N');
246257
}
247258

248259
// Success!

dev/RuntimeCompatibilityOptions/RuntimeCompatibilityOptions.idl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ namespace Microsoft.Windows.ApplicationModel.WindowsAppRuntime
3434
AppLifecycle_SharedMemoryRedirectionQueueFix = 60972838,
3535
SplitMenuFlyoutItem_Available = 60878987,
3636
TextIntelligence_Insights = 61106039,
37+
38+
// 1.8.7
39+
DeploymentManager_DiagnosabilityFix = 61543987,
3740
};
3841

3942
/// Represents a version of the Windows App Runtime.

dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapActivity.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void WindowsAppRuntime::MddBootstrap::Activity::Context::SetLastFailure(const wi
1818

1919
if (failure.pszFile)
2020
{
21-
m_lastFailure.file = *failure.pszFile;
21+
m_lastFailure.file = failure.pszFile;
2222
}
2323
else
2424
{
@@ -29,7 +29,7 @@ void WindowsAppRuntime::MddBootstrap::Activity::Context::SetLastFailure(const wi
2929

3030
if (failure.pszMessage)
3131
{
32-
m_lastFailure.message = *failure.pszMessage;
32+
m_lastFailure.message = failure.pszMessage;
3333
}
3434
else
3535
{
@@ -38,7 +38,7 @@ void WindowsAppRuntime::MddBootstrap::Activity::Context::SetLastFailure(const wi
3838

3939
if (failure.pszModule)
4040
{
41-
m_lastFailure.module = *failure.pszModule;
41+
m_lastFailure.module = failure.pszModule;
4242
}
4343
else
4444
{

dev/WindowsAppRuntime_BootstrapDLL/MddBootstrapAutoInitializer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <Windows.h>
55
#include <stdint.h>
66
#include <stdlib.h>
7+
78
#include <MddBootstrap.h>
89
#include <WindowsAppSDK-VersionInfo.h>
910

installer/dev/InstallActivityContext.cpp

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
#include "pch.h"
55
#include "InstallActivityContext.h"
66

7+
#include <FrameworkUdk/Containment.h>
8+
9+
// Bug 61543987: [1.8 servicing] Deployment exceptions masked as ERROR_UNHANDLED_EXCEPTION; SetLastFailure logging single chars
10+
#define WINAPPSDK_CHANGEID_61543987 61543987, WinAppSDK_1_8_7
11+
712
WindowsAppRuntimeInstaller::InstallActivity::Context& WindowsAppRuntimeInstaller::InstallActivity::Context::Get()
813
{
914
return g_installActivityContext;
@@ -37,7 +42,14 @@ void WindowsAppRuntimeInstaller::InstallActivity::Context::SetLastFailure(const
3742

3843
if (failure.pszFile)
3944
{
40-
m_lastFailure.file = *failure.pszFile;
45+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
46+
{
47+
m_lastFailure.file = failure.pszFile;
48+
}
49+
else
50+
{
51+
m_lastFailure.file = *failure.pszFile;
52+
}
4153
}
4254
else
4355
{
@@ -48,7 +60,14 @@ void WindowsAppRuntimeInstaller::InstallActivity::Context::SetLastFailure(const
4860

4961
if (failure.pszMessage)
5062
{
51-
m_lastFailure.message = *failure.pszMessage;
63+
if (WinAppSdk::Containment::IsChangeEnabled<WINAPPSDK_CHANGEID_61543987>())
64+
{
65+
m_lastFailure.message = failure.pszMessage;
66+
}
67+
else
68+
{
69+
m_lastFailure.message = *failure.pszMessage;
70+
}
5271
}
5372
else
5473
{

0 commit comments

Comments
 (0)