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

Unpackaged Windows App SDK app doesn't run on RS5/19H1 #1681

Merged
merged 7 commits into from
Nov 1, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions WindowsAppRuntime.sln
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicDependencyLifetimeManager", "dev\DynamicDependencyLifetimeManager\DynamicDependencyLifetimeManager\DynamicDependencyLifetimeManager.vcxproj", "{2E5BF0D2-78FA-4B60-A341-F65A0D58BD86}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicDependencyLifetimeManager.Msix", "test\DynamicDependency\data\DynamicDependencyLifetimeManager.Msix\DynamicDependencyLifetimeManager.Msix.vcxproj", "{A7391725-4EF5-438F-8DE1-645423E46955}"
ProjectSection(ProjectDependencies) = postProject
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B} = {6539E9E1-BF36-40E5-86BC-070E99DB7B7B}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicDependencyLifetimeManager.ProxyStub", "dev\DynamicDependencyLifetimeManager\DynamicDependencyLifetimeManager.ProxyStub\DynamicDependencyLifetimeManager.ProxyStub.vcxproj", "{8C79C46D-1577-44CA-83DF-88B74C3E4586}"
EndProject
Expand Down Expand Up @@ -244,6 +247,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsAppRuntime_MSIXInsta
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Framework.Widgets", "test\DynamicDependency\data\Framework.Widgets\Framework.Widgets.vcxproj", "{09DDAE21-397F-4263-8561-7F2FF28127CF}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DynamicDependencyLifetimeManagerShadow", "dev\DynamicDependency\DynamicDependencyLifetimeManagerShadow\DynamicDependencyLifetimeManagerShadow.vcxproj", "{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\inc\inc.vcxitems*{0a5fee93-48b7-40ec-bb9a-b27d11060da9}*SharedItemsImports = 4
Expand Down Expand Up @@ -921,6 +926,20 @@ Global
{09DDAE21-397F-4263-8561-7F2FF28127CF}.Release|x64.Build.0 = Release|x64
{09DDAE21-397F-4263-8561-7F2FF28127CF}.Release|x86.ActiveCfg = Release|Win32
{09DDAE21-397F-4263-8561-7F2FF28127CF}.Release|x86.Build.0 = Release|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|Any CPU.ActiveCfg = Debug|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|ARM64.ActiveCfg = Debug|ARM64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|ARM64.Build.0 = Debug|ARM64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|x64.ActiveCfg = Debug|x64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|x64.Build.0 = Debug|x64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|x86.ActiveCfg = Debug|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Debug|x86.Build.0 = Debug|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|Any CPU.ActiveCfg = Release|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|ARM64.ActiveCfg = Release|ARM64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|ARM64.Build.0 = Release|ARM64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|x64.ActiveCfg = Release|x64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|x64.Build.0 = Release|x64
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|x86.ActiveCfg = Release|Win32
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -1003,6 +1022,7 @@ Global
{E15C3465-9D45-495D-92CE-B91EF45E8623} = {6967798A-AC07-4994-8FE9-DC9442F88E97}
{D45D4170-E055-4926-8B03-04DAA5F02C6C} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{09DDAE21-397F-4263-8561-7F2FF28127CF} = {0C534F12-B076-47E5-A05B-2A711233AC6F}
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B} = {6CD01EF6-D4A4-4801-ADCF-344CF87FF942}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77}
Expand Down
50 changes: 50 additions & 0 deletions dev/Common/IsWindowsVersion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.

#ifndef __ISWINDOWSVERSION_H
DrusTheAxe marked this conversation as resolved.
Show resolved Hide resolved
#define __ISWINDOWSVERSION_H

#include <VersionHelpers.h>

namespace WindowsVersion
{
VERSIONHELPERAPI IsWindowsVersionOrGreaterEx(
const WORD majorVersion,
const WORD minorVersion,
const WORD servicePackMajor,
DrusTheAxe marked this conversation as resolved.
Show resolved Hide resolved
const WORD buildNumber)
{
OSVERSIONINFOEXW osvi{ sizeof(osvi) };
osvi.dwMajorVersion = majorVersion;
osvi.dwMinorVersion = minorVersion;
osvi.wServicePackMajor = servicePackMajor;
osvi.dwBuildNumber = buildNumber;

const DWORDLONG c_conditionMask{
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL),
VER_BUILDNUMBER, VER_GREATER_EQUAL)
};

return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_BUILDNUMBER, c_conditionMask) != FALSE;
}

VERSIONHELPERAPI IsWindows10_19H1OrGreater()
{
const WORD c_win10_19h1_build{ 18362 };
return IsWindowsVersionOrGreaterEx(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0, c_win10_19h1_build);
}

VERSIONHELPERAPI IsWindows10_20H1OrGreater()
{
const WORD c_win10_20h1_build{ 19041 };
return IsWindowsVersionOrGreaterEx(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0, c_win10_20h1_build);
}
}

#endif // __ISWINDOWSVERSION_H
44 changes: 3 additions & 41 deletions dev/DynamicDependency/API/MddDetourPackageGraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "pch.h"

#include <VersionHelpers.h>
#include <IsWindowsVersion.h>

#include "MddDetourPackageGraph.h"

Expand Down Expand Up @@ -99,44 +99,6 @@ typedef HRESULT (WINAPI* GetPackageInfo2Function)(
BYTE* buffer,
UINT32* count);

VERSIONHELPERAPI IsWindowsVersionOrGreaterEx(
const WORD majorVersion,
const WORD minorVersion,
const WORD servicePackMajor,
const WORD buildNumber)
{
OSVERSIONINFOEXW osvi{ sizeof(osvi) };
osvi.dwMajorVersion = majorVersion;
osvi.dwMinorVersion = minorVersion;
osvi.wServicePackMajor = servicePackMajor;
osvi.dwBuildNumber = buildNumber;

const DWORDLONG c_conditionMask{
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
VerSetConditionMask(
0, VER_MAJORVERSION, VER_GREATER_EQUAL),
VER_MINORVERSION, VER_GREATER_EQUAL),
VER_SERVICEPACKMAJOR, VER_GREATER_EQUAL),
VER_BUILDNUMBER, VER_GREATER_EQUAL)
};

return VerifyVersionInfoW(&osvi, VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR | VER_BUILDNUMBER, c_conditionMask) != FALSE;
}

VERSIONHELPERAPI IsWindows10_19H1OrGreater()
{
const WORD c_win10_19h1_build{ 18362 };
return IsWindowsVersionOrGreaterEx(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0, c_win10_19h1_build);
}

VERSIONHELPERAPI IsWindows10_20H1OrGreater()
{
const WORD c_win10_20h1_build{ 19041 };
return IsWindowsVersionOrGreaterEx(HIBYTE(_WIN32_WINNT_WIN10), LOBYTE(_WIN32_WINNT_WIN10), 0, c_win10_20h1_build);
}

HRESULT WINAPI MddDetourPackageGraphInitialize() noexcept
{
// Detour package graph APIs to our implementation
Expand All @@ -146,7 +108,7 @@ HRESULT WINAPI MddDetourPackageGraphInitialize() noexcept
// NOTE: GetCurrentPackageInfo2 requires >=19H1
// NOTE: GetCurrentPackageInfo3 requires >=20H1
// Support down to RS5
if (IsWindows10_19H1OrGreater())
if (WindowsVersion::IsWindows10_19H1OrGreater())
{
HMODULE dllApisetAppmodelRuntime_1_3{ LoadLibraryExW(L"api-ms-win-appmodel-runtime-l1-1-3.dll", nullptr, 0) };
FAIL_FAST_HR_IF_NULL(HRESULT_FROM_WIN32(GetLastError()), dllApisetAppmodelRuntime_1_3);
Expand All @@ -161,7 +123,7 @@ HRESULT WINAPI MddDetourPackageGraphInitialize() noexcept
FAIL_FAST_HR_IF_NULL(HRESULT_FROM_WIN32(GetLastError()), dllGetPackageInfo2);
TrueGetPackageInfo2 = dllGetPackageInfo2;

if (IsWindows10_20H1OrGreater())
if (WindowsVersion::IsWindows10_20H1OrGreater())
{
HMODULE dllApisetAppmodelRuntimeInternal_1_6{ LoadLibraryExW(L"api-ms-win-appmodel-runtime-internal-l1-1-6.dll", nullptr, 0) };
FAIL_FAST_HR_IF_NULL(HRESULT_FROM_WIN32(GetLastError()), dllApisetAppmodelRuntimeInternal_1_6);
Expand Down
Loading