Skip to content
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

[release/1.4-stable] Fix crashes in the installer #3806

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 12 additions & 14 deletions installer/dev/InstallActivityContext.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -65,7 +65,7 @@ BOOL WindowsAppRuntimeInstaller::InstallActivity::Context::LogInstallerCommandLi
WCHAR message[1024]{};
PCWSTR messageFormat{ L"Windows App Runtime Installer (ActivityId: %s) is called with Command Line Args: %s" };
auto installerActivityId{ winrt::to_hstring(*m_activity.Id()) };
FAIL_FAST_IF_FAILED(StringCchPrintfW(message, ARRAYSIZE(message), messageFormat, installerActivityId, cmdlineArgs));
FAIL_FAST_IF_FAILED(StringCchPrintfW(message, ARRAYSIZE(message), messageFormat, installerActivityId.data(), cmdlineArgs));
PCWSTR messageStrings[1]{ message };
return ReportEventW(m_hEventLog, EVENTLOG_INFORMATION_TYPE, 0, eventId, nullptr, ARRAYSIZE(messageStrings), 0, messageStrings, nullptr);
}
Expand All @@ -76,8 +76,6 @@ BOOL WindowsAppRuntimeInstaller::InstallActivity::Context::LogInstallerFailureEv
{
if (m_hEventLog)
{
std::wstring customMessage{};

switch (m_installStage)
{
case InstallStage::None:
Expand All @@ -98,15 +96,15 @@ BOOL WindowsAppRuntimeInstaller::InstallActivity::Context::LogInstallerFailureEv
case InstallStage::AddPackage:
{
WCHAR customMessage[1024]{};
auto deploymentActivityId{ winrt::to_hstring(*m_activity.Id()) };
auto deploymentErrorActivityId{ winrt::to_hstring(m_deploymentErrorActivityId) };
auto customMessageFormat{ L"Installing Package %s with DeploymentExtendedError: 0x%08X, DeploymentExtendedText:%s, DeploymentActivityId: %s" };
FAIL_FAST_IF_FAILED(StringCchPrintfW(customMessage,
ARRAYSIZE(customMessage),
customMessageFormat,
m_currentResourceId,
m_currentResourceId.c_str(),
m_deploymentErrorExtendedHresult,
m_deploymentErrorText,
m_deploymentErrorActivityId));
m_deploymentErrorText.c_str(),
deploymentErrorActivityId.data()));
THROW_IF_WIN32_BOOL_FALSE(LogInstallerFailureEventWithResourceId(EVENTLOG_ERROR_TYPE, hresult, customMessage));
break;
}
Expand All @@ -125,22 +123,22 @@ BOOL WindowsAppRuntimeInstaller::InstallActivity::Context::LogInstallerFailureEv
WCHAR customProvisionMessage[1024]{};
auto provisionActivityId{ winrt::to_hstring(*m_activity.Id()) };
auto customProvisionMessageFormat{ L"Provisioning Package %s (Activity Id:%s)" };
FAIL_FAST_IF_FAILED(StringCchPrintfW(customProvisionMessage, ARRAYSIZE(customProvisionMessage), customProvisionMessageFormat, provisionActivityId));
FAIL_FAST_IF_FAILED(StringCchPrintfW(customProvisionMessage, ARRAYSIZE(customProvisionMessage), customProvisionMessageFormat, m_currentResourceId.c_str(), provisionActivityId.data()));
THROW_IF_WIN32_BOOL_FALSE(LogInstallerFailureEventWithResourceId(EVENTLOG_WARNING_TYPE, hresult, customProvisionMessage));
break;
}
case InstallStage::StagePackage:
{
WCHAR customMessage[1024]{};
auto deploymentActivityId{ winrt::to_hstring(*m_activity.Id()) };
auto deploymentErrorActivityId{ winrt::to_hstring(m_deploymentErrorActivityId) };
auto customMessageFormat{ L"Staging Package %s with DeploymentExtendedError: 0x%08X, DeploymentExtendedText:%s, DeploymentActivityId: %s" };
FAIL_FAST_IF_FAILED(StringCchPrintfW(customMessage,
ARRAYSIZE(customMessage),
customMessageFormat,
m_currentResourceId,
m_currentResourceId.c_str(),
m_deploymentErrorExtendedHresult,
m_deploymentErrorText,
m_deploymentErrorActivityId));
m_deploymentErrorText.c_str(),
deploymentErrorActivityId.data()));
THROW_IF_WIN32_BOOL_FALSE(LogInstallerFailureEventWithResourceId(EVENTLOG_ERROR_TYPE, hresult, customMessage));
break;
}
Expand All @@ -166,7 +164,7 @@ BOOL WindowsAppRuntimeInstaller::InstallActivity::Context::LogInstallerFailureEv
WCHAR message[1024]{};
PCWSTR messageFormat{ L"Error 0x%08X: Windows App Runtime Installer (Activity ID: %s) failed in %s" };
auto installerActivityId{ winrt::to_hstring(*m_activity.Id()) };
FAIL_FAST_IF_FAILED(StringCchPrintfW(message, ARRAYSIZE(message), messageFormat, hresult, installerActivityId, (resourceId ? failedComponentMessage : failedComponentMessageFormat)));
FAIL_FAST_IF_FAILED(StringCchPrintfW(message, ARRAYSIZE(message), messageFormat, hresult, installerActivityId.data(), (resourceId ? failedComponentMessage : failedComponentMessageFormat)));

PCWSTR messageStrings[1]{ message };
return ReportEventW(m_hEventLog, eventLogType, 0, eventId, nullptr, ARRAYSIZE(messageStrings), 0, messageStrings, nullptr);
Expand Down
4 changes: 2 additions & 2 deletions installer/dev/InstallActivityContext.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#pragma once
Expand Down Expand Up @@ -137,7 +137,7 @@ namespace WindowsAppRuntimeInstaller::InstallActivity
return m_hEventLog;
}

const BOOL& DeregisterInstallerEventSourceW()
const BOOL DeregisterInstallerEventSourceW()
{
return DeregisterEventSource(m_hEventLog);
}
Expand Down
4 changes: 3 additions & 1 deletion installer/dev/install.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation and Contributors.
// Copyright (c) Microsoft Corporation and Contributors.
// Licensed under the MIT License.

#include "pch.h"
Expand Down Expand Up @@ -35,6 +35,8 @@ namespace WindowsAppRuntimeInstaller

RETURN_HR(static_cast<HRESULT>(deploymentResult.ExtendedErrorCode() ? deploymentResult.ExtendedErrorCode() : deploymentOperation.ErrorCode()));
}

return S_OK;
}

HRESULT RegisterPackage(
Expand Down