Implement Windows8+ Applicability PAL
This commit is contained in:
Родитель
cf39a03965
Коммит
ca1a5ca3fb
|
@ -0,0 +1,23 @@
|
|||
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
|
||||
<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'>
|
||||
<description>${DESCRIPTION}</description>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- Windows 7 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- Windows 8 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!-- Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level='asInvoker' uiAccess='false' />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
|
@ -7,6 +7,13 @@ project (makemsix)
|
|||
# Define two variables in order not to repeat ourselves.
|
||||
set(BINARY_NAME ExtractContentsSample)
|
||||
|
||||
if(WIN32)
|
||||
set(DESCRIPTION "makemsix manifest")
|
||||
configure_file(../../manifest.cmakein ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.exe.manifest CRLF)
|
||||
set(MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.exe.manifest)
|
||||
endif()
|
||||
|
||||
|
||||
include_directories(
|
||||
${include_directories}
|
||||
${CMAKE_PROJECT_ROOT}/src/inc
|
||||
|
@ -14,6 +21,7 @@ include_directories(
|
|||
|
||||
add_executable(${BINARY_NAME}
|
||||
ExtractContentsSample.cpp
|
||||
${MANIFEST}
|
||||
)
|
||||
|
||||
# specify that this binary is to be built with C++14
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
//
|
||||
// Copyright (C) 2017 Microsoft. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
class Applicability
|
||||
{
|
||||
public:
|
||||
static MSIX_PLATFORM GetPlatform();
|
||||
static std::set<std::string> GetLanguages();
|
||||
};
|
||||
}
|
|
@ -2010,6 +2010,20 @@ enum MSIX_PACKUNPACK_OPTION
|
|||
MSIX_PACKUNPACK_OPTION_CREATEPACKAGESUBFOLDER = 0x1
|
||||
} MSIX_PACKUNPACK_OPTION;
|
||||
|
||||
typedef /* [v1_enum] */
|
||||
enum MSIX_PLATFORM
|
||||
{
|
||||
MSIX_PLATFORM_ALL = 0x0,
|
||||
MSIX_PLATFORM_WINDOWS10 = 0x1,
|
||||
MSIX_PLATFORM_WINDOWS8POINT1 = 0x2,
|
||||
MSIX_PLATFORM_WINDOWS8 = 0x4,
|
||||
MSIX_PLATFORM_WINDOWS7 = 0x8,
|
||||
MSIX_PLATFORM_MACOS = 0x10,
|
||||
MSIX_PLATFORM_IOS = 0x20,
|
||||
MSIX_PLATFORM_AOSP = 0x40,
|
||||
MSIX_PLATFORM_LINUX = 0x80,
|
||||
} MSIX_PLATFORM;
|
||||
|
||||
MSIX_API HRESULT STDMETHODCALLTYPE UnpackPackage(
|
||||
MSIX_PACKUNPACK_OPTION packUnpackOptions,
|
||||
MSIX_VALIDATION_OPTION validationOption,
|
||||
|
|
|
@ -8,6 +8,12 @@ project (makemsix)
|
|||
# Define two variables in order not to repeat ourselves.
|
||||
set(BINARY_NAME makemsix)
|
||||
|
||||
if(WIN32)
|
||||
set(DESCRIPTION "makemsix manifest")
|
||||
configure_file(../../manifest.cmakein ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.exe.manifest CRLF)
|
||||
set(MANIFEST ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_NAME}.exe.manifest)
|
||||
endif()
|
||||
|
||||
include_directories(
|
||||
${include_directories}
|
||||
${CMAKE_PROJECT_ROOT}/src/inc
|
||||
|
@ -15,6 +21,7 @@ include_directories(
|
|||
|
||||
add_executable(${BINARY_NAME}
|
||||
main.cpp
|
||||
${MANIFEST}
|
||||
)
|
||||
|
||||
# specify that this binary is to be built with C++14
|
||||
|
|
|
@ -23,9 +23,10 @@ IF (XML_PARSER MATCHES msxml6)
|
|||
ENDIF()
|
||||
|
||||
IF(WIN32)
|
||||
SET (DirectoryObject PAL/FileSystem/Win32/DirectoryObject.CPP)
|
||||
SET (SHA256 PAL/SHA256/Win32/SHA256.CPP)
|
||||
SET (DirectoryObject PAL/FileSystem/Win32/DirectoryObject.cpp)
|
||||
SET (SHA256 PAL/SHA256/Win32/SHA256.cpp)
|
||||
SET (Signature PAL/Signature/Win32/SignatureValidator.cpp)
|
||||
SET (Applicability PAL/Applicability/Win32/Applicability.cpp)
|
||||
ELSE()
|
||||
# Visibility variables for non-win32 platforms
|
||||
IF((IOS) OR (MACOS))
|
||||
|
@ -71,6 +72,7 @@ MESSAGE (STATUS "PAL: XML = ${XmlParser}")
|
|||
MESSAGE (STATUS "PAL: DirectoryObject = ${DirectoryObject}")
|
||||
MESSAGE (STATUS "PAL: SHA256 = ${SHA256}")
|
||||
MESSAGE (STATUS "PAL: Signature = ${Signature}")
|
||||
MESSAGE (STATUS "PAL: Applicability = ${Applicability}")
|
||||
|
||||
include(msix_resources)
|
||||
|
||||
|
@ -80,6 +82,7 @@ SET(LIB_PUBLIC_HEADERS
|
|||
)
|
||||
|
||||
SET(LIB_PRIVATE_HEADERS
|
||||
../inc/Applicability.hpp
|
||||
../inc/AppxBlockMapObject.hpp
|
||||
../inc/AppxFactory.hpp
|
||||
../inc/AppxPackageInfo.hpp
|
||||
|
@ -122,6 +125,7 @@ SET(LIB_SOURCES
|
|||
${SHA256}
|
||||
${Signature}
|
||||
${XmlParser}
|
||||
${Applicability}
|
||||
)
|
||||
|
||||
# Copy out public headers
|
||||
|
@ -175,5 +179,6 @@ IF(OpenSSL_FOUND)
|
|||
ENDIF()
|
||||
|
||||
if(WIN32)
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE bcrypt crypt32 wintrust)
|
||||
SET_PROPERTY(TARGET ${BINARY_NAME} PROPERTY VS_WINRT_COMPONENT TRUE)
|
||||
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PRIVATE bcrypt crypt32 wintrust runtimeobject.lib)
|
||||
endif()
|
|
@ -0,0 +1,91 @@
|
|||
//
|
||||
// Copyright (C) 2017 Microsoft. All rights reserved.
|
||||
// See LICENSE file in the project root for full license information.
|
||||
//
|
||||
#include <windows.h>
|
||||
#include <VersionHelpers.h>
|
||||
#include <wrl\wrappers\corewrappers.h>
|
||||
#include <wrl\client.h>
|
||||
#include <windows.system.userprofile.h>
|
||||
|
||||
#include "AppxPackaging.hpp"
|
||||
#include "Exceptions.hpp"
|
||||
#include "Applicability.hpp"
|
||||
#include "ComHelper.hpp"
|
||||
#include "UnicodeConversion.hpp"
|
||||
|
||||
#include <set>
|
||||
#include <iostream>
|
||||
using namespace ABI::Windows::Foundation::Collections;
|
||||
using namespace ABI::Windows::System::UserProfile;
|
||||
using namespace Microsoft::WRL::Wrappers;
|
||||
using namespace Windows::Foundation;
|
||||
|
||||
|
||||
namespace MSIX {
|
||||
|
||||
#define ThrowHrIfFalse(a, m) \
|
||||
{ BOOL _result = a; \
|
||||
if (!_result) \
|
||||
{ MSIX::RaiseException<MSIX::Exception> (__LINE__, __FILE__, m, HRESULT_FROM_WIN32(GetLastError())); \
|
||||
} \
|
||||
}
|
||||
|
||||
MSIX_PLATFORM Applicability::GetPlatform()
|
||||
{
|
||||
if (IsWindows10OrGreater())
|
||||
{
|
||||
return MSIX_PLATFORM_WINDOWS10;
|
||||
}
|
||||
else if (IsWindows8Point1OrGreater())
|
||||
{
|
||||
return MSIX_PLATFORM_WINDOWS8POINT1;
|
||||
}
|
||||
else if (IsWindows8OrGreater())
|
||||
{
|
||||
return MSIX_PLATFORM_WINDOWS8;
|
||||
}
|
||||
else if (IsWindows7SP1OrGreater() || IsWindows7OrGreater())
|
||||
{
|
||||
return MSIX_PLATFORM_WINDOWS7;
|
||||
}
|
||||
UNEXPECTED;
|
||||
}
|
||||
|
||||
std::set<std::string> Applicability::GetLanguages()
|
||||
{
|
||||
std::set<std::string> result;
|
||||
|
||||
if (MSIX_PLATFORM_WINDOWS7 == GetPlatform())
|
||||
{
|
||||
ULONG numOfLangs = 0;
|
||||
DWORD size = 0;
|
||||
std::wstring languagesWin7;
|
||||
ThrowHrIfFalse(GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numOfLangs, nullptr, &size),
|
||||
"Failed GetUserPreferredUILanguages");
|
||||
languagesWin7.resize(size);
|
||||
ThrowHrIfFalse(GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &numOfLangs, &languagesWin7.front(), &size),
|
||||
"Failed GetUserPreferredUILanguages");
|
||||
// TODO: split languagesWin7 by /0 and add the table with MUI to BCP47 conversion
|
||||
}
|
||||
else
|
||||
{
|
||||
RoInitializeWrapper initialize(RO_INIT_MULTITHREADED);
|
||||
ThrowHrIfFailed(initialize);
|
||||
ComPtr<IGlobalizationPreferencesStatics> globalizationPreferences;
|
||||
ComPtr<IVectorView<HSTRING>> languages;
|
||||
ThrowHrIfFailed(GetActivationFactory(HStringReference(
|
||||
RuntimeClass_Windows_System_UserProfile_GlobalizationPreferences).Get(),&globalizationPreferences));
|
||||
ThrowHrIfFailed(globalizationPreferences->get_Languages(&languages));
|
||||
UINT numOfLanguages = 0;
|
||||
ThrowHrIfFailed(languages->get_Size(&numOfLanguages));
|
||||
for (UINT i = 0; i < numOfLanguages; i++)
|
||||
{
|
||||
HString hstring;
|
||||
ThrowHrIfFailed(languages->GetAt(i, hstring.GetAddressOf()));
|
||||
result.insert(utf16_to_utf8(hstring.GetRawBuffer(nullptr)));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче