Feature for sharing security descriptors (take 2) (#2005)

* Initial

* Working tests

* WinRT implementation

* Delay load both DLLS and perform full bootstrap setup. It works!

* PR feedback

* Wrap long lines

* Merge in test package changes
This commit is contained in:
Ryan Shepherd 2022-01-27 10:57:44 -08:00 коммит произвёл GitHub
Родитель 4beff300b5
Коммит 40461bf9a4
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
36 изменённых файлов: 1452 добавлений и 7 удалений

Просмотреть файл

@ -265,8 +265,25 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Licensing", "Licensing", "{
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Licensing", "dev\Licensing\Licensing.vcxitems", "{885A43FA-052D-4B0D-A2DC-13EE15796435}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AccessControl", "AccessControl", "{A06B7FE8-D201-4EA2-BB10-61B4595EC377}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AccessControl", "dev\AccessControl\AccessControl.vcxitems", "{C91BCB93-9ED1-4ACD-85F3-26F9F6AC52E3}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AccessControlTests", "test\AccessControlTests\AccessControlTests.vcxproj", "{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}"
ProjectSection(ProjectDependencies) = postProject
{B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1}
{9C1A6C58-52D6-4514-9120-5C339C5DF4BE} = {9C1A6C58-52D6-4514-9120-5C339C5DF4BE}
{03EBF097-66C6-4996-95A3-28F6F5999E27} = {03EBF097-66C6-4996-95A3-28F6F5999E27}
{D5667DF6-A151-4081-ABC7-B93E8E5604CE} = {D5667DF6-A151-4081-ABC7-B93E8E5604CE}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AccessControlTestApp", "test\TestApps\AccessControlTestApp\AccessControlTestApp.vcxproj", "{D5667DF6-A151-4081-ABC7-B93E8E5604CE}"
EndProject
Project("{C7167F0D-BC9F-4E6E-AFE1-012C56B48DB5}") = "AccessControlTestAppPackage", "test\TestApps\AccessControlTestAppPackage\AccessControlTestAppPackage.wapproj", "{03EBF097-66C6-4996-95A3-28F6F5999E27}"
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
test\inc\inc.vcxitems*{08bc78e0-63c6-49a7-81b3-6afc3deac4de}*SharedItemsImports = 4
test\inc\inc.vcxitems*{0a5fee93-48b7-40ec-bb9a-b27d11060da9}*SharedItemsImports = 4
dev\PushNotifications\PushNotifications.vcxitems*{103c0c23-7ba8-4d44-a63c-83488e2e3a81}*SharedItemsImports = 9
test\inc\inc.vcxitems*{2cd5cd9b-cf45-4fa7-9769-ee4e02426bf0}*SharedItemsImports = 4
@ -286,7 +303,9 @@ Global
dev\PowerNotifications\PowerNotifications.vcxitems*{b75c1b22-553c-40e4-b38e-6ab4d01fdb9d}*SharedItemsImports = 9
dev\DynamicDependency\API\DynamicDependency.vcxitems*{bf055a59-0919-4e34-9b76-dd055495cc5a}*SharedItemsImports = 9
test\inc\inc.vcxitems*{c62688a1-16a0-4729-b6ed-842f4faa29f3}*SharedItemsImports = 4
dev\AccessControl\AccessControl.vcxitems*{c91bcb93-9ed1-4acd-85f3-26f9f6ac52e3}*SharedItemsImports = 9
dev\Common\Common.vcxitems*{d45d4170-e055-4926-8b03-04daa5f02c6c}*SharedItemsImports = 4
test\inc\inc.vcxitems*{d5667df6-a151-4081-abc7-b93e8e5604ce}*SharedItemsImports = 4
dev\Deployment\Deployment.vcxitems*{db38fb4d-d04f-4c1d-93e0-f8ae259c5fd6}*SharedItemsImports = 9
dev\EnvironmentManager\ChangeTracker\ChangeTracker.vcxitems*{e15c3465-9d45-495d-92ce-b91ef45e8623}*SharedItemsImports = 9
dev\AppLifecycle\AppLifecycle.vcxitems*{e3a522a3-6635-4a42-bded-1af46a15f63c}*SharedItemsImports = 9
@ -971,6 +990,53 @@ Global
{BC5E5A3E-E733-4388-8B00-F8495DA7C778}.Release|x64.Build.0 = Release|x64
{BC5E5A3E-E733-4388-8B00-F8495DA7C778}.Release|x86.ActiveCfg = Release|Win32
{BC5E5A3E-E733-4388-8B00-F8495DA7C778}.Release|x86.Build.0 = Release|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|Any CPU.ActiveCfg = Debug|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|ARM64.ActiveCfg = Debug|ARM64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|ARM64.Build.0 = Debug|ARM64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|x64.ActiveCfg = Debug|x64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|x64.Build.0 = Debug|x64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|x86.ActiveCfg = Debug|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Debug|x86.Build.0 = Debug|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|Any CPU.ActiveCfg = Release|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|ARM64.ActiveCfg = Release|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|x64.ActiveCfg = Release|x64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|x64.Build.0 = Release|x64
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|x86.ActiveCfg = Release|Win32
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE}.Release|x86.Build.0 = Release|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|Any CPU.ActiveCfg = Debug|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|ARM64.ActiveCfg = Debug|ARM64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|ARM64.Build.0 = Debug|ARM64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|x64.ActiveCfg = Debug|x64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|x64.Build.0 = Debug|x64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|x86.ActiveCfg = Debug|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Debug|x86.Build.0 = Debug|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|Any CPU.ActiveCfg = Release|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|ARM64.ActiveCfg = Release|ARM64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|ARM64.Build.0 = Release|ARM64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|x64.ActiveCfg = Release|x64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|x64.Build.0 = Release|x64
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|x86.ActiveCfg = Release|Win32
{D5667DF6-A151-4081-ABC7-B93E8E5604CE}.Release|x86.Build.0 = Release|Win32
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|Any CPU.ActiveCfg = Debug|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|ARM64.ActiveCfg = Debug|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|ARM64.Build.0 = Debug|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|ARM64.Deploy.0 = Debug|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x64.ActiveCfg = Debug|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x64.Build.0 = Debug|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x64.Deploy.0 = Debug|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x86.ActiveCfg = Debug|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x86.Build.0 = Debug|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Debug|x86.Deploy.0 = Debug|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|Any CPU.ActiveCfg = Release|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|ARM64.ActiveCfg = Release|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|ARM64.Build.0 = Release|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|ARM64.Deploy.0 = Release|ARM64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x64.ActiveCfg = Release|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x64.Build.0 = Release|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x64.Deploy.0 = Release|x64
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x86.ActiveCfg = Release|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x86.Build.0 = Release|x86
{03EBF097-66C6-4996-95A3-28F6F5999E27}.Release|x86.Deploy.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -1055,6 +1121,11 @@ Global
{09DDAE21-397F-4263-8561-7F2FF28127CF} = {0C534F12-B076-47E5-A05B-2A711233AC6F}
{6539E9E1-BF36-40E5-86BC-070E99DB7B7B} = {6CD01EF6-D4A4-4801-ADCF-344CF87FF942}
{BC5E5A3E-E733-4388-8B00-F8495DA7C778} = {3DE93B2F-F887-437D-B512-6B1024ABA290}
{A06B7FE8-D201-4EA2-BB10-61B4595EC377} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{C91BCB93-9ED1-4ACD-85F3-26F9F6AC52E3} = {A06B7FE8-D201-4EA2-BB10-61B4595EC377}
{08BC78E0-63C6-49A7-81B3-6AFC3DEAC4DE} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D}
{D5667DF6-A151-4081-ABC7-B93E8E5604CE} = {AC5FFC80-92FE-4933-BED2-EC5519AC4440}
{03EBF097-66C6-4996-95A3-28F6F5999E27} = {AC5FFC80-92FE-4933-BED2-EC5519AC4440}
{34671779-4A4D-4D0E-B259-CD0F14D4F6D4} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A}
{885A43FA-052D-4B0D-A2DC-13EE15796435} = {34671779-4A4D-4D0E-B259-CD0F14D4F6D4}
EndGlobalSection

Просмотреть файл

@ -56,6 +56,8 @@
<!-- PowerNotifications -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.Power.PowerManager" ThreadingModel="both" />
<!-- AccessControl -->
<ActivatableClass ActivatableClassId="Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>

Просмотреть файл

@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
namespace Microsoft.Windows.Security.AccessControl
{
struct AppContainerNameAndAccess
{
String appContainerName;
UInt32 accessMask;
};
static runtimeclass SecurityDescriptorHelpers
{
static String GetSddlForAppContainerNames(
AppContainerNameAndAccess[] accessRequests,
String principalStringSid,
UInt32 principalAccessMask
);
static UInt8[] GetSecurityDescriptorBytesFromAppContainerNames(
AppContainerNameAndAccess[] accessRequests,
String principalStringSid,
UInt32 principalAccessMask
);
};
}

Просмотреть файл

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Globals">
<MSBuildAllProjects Condition="'$(MSBuildVersion)' == '' Or '$(MSBuildVersion)' &lt; '16.0'">$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
<HasSharedItems>true</HasSharedItems>
<ItemsProjectGuid>{c91bcb93-9ed1-4acd-85f3-26f9f6ac52e3}</ItemsProjectGuid>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(MSBuildThisFileDirectory)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ProjectCapability Include="SourceItemsFromImports" />
</ItemGroup>
<ItemGroup>
<Midl Include="$(MSBuildThisFileDirectory)AccessControl.idl" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(MSBuildThisFileDirectory)Security.AccessControl.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)Microsoft.Windows.Security.AccessControl.h" />
<ClInclude Include="$(MSBuildThisFileDirectory)SecurityDescriptorHelpers.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(MSBuildThisFileDirectory)GetSecurityDescriptorForAppContainerNames.cpp" />
<ClCompile Include="$(MSBuildThisFileDirectory)Microsoft.Windows.Security.AccessControl.cpp" />
</ItemGroup>
<ItemGroup>
<PublicHeaders Include="$(MSBuildThisFileDirectory)Security.AccessControl.h" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,92 @@
#include <pch.h>
#include <accctrl.h>
#include <aclapi.h>
#include <userenv.h>
#include <vector>
#include "Security.AccessControl.h"
#include "SecurityDescriptorHelpers.h"
using namespace std;
STDAPI GetSecurityDescriptorForAppContainerNames(
UINT32 accessRequestCount,
_In_reads_(accessRequestCount) const AppContainerNameAndAccess* accessRequests,
_In_opt_ PSID principal,
UINT32 principalAccessMask,
_Outptr_ PSECURITY_DESCRIPTOR* securityDescriptor,
_Out_opt_ UINT32* securityDescriptorLength
) try
{
*securityDescriptor = nullptr;
if (securityDescriptorLength)
{
*securityDescriptorLength = 0;
}
THROW_HR_IF(E_INVALIDARG, accessRequestCount == UINT32_MAX);
wil::unique_any_psid currentProcessSid;
if (!principal)
{
currentProcessSid = Security::Descriptors::GetCurrentProcessSid();
principal = currentProcessSid.get();
}
vector<EXPLICIT_ACCESS_W> ea;
ea.reserve(accessRequestCount + 1);
{
EXPLICIT_ACCESS_W entry{};
entry.grfAccessMode = GRANT_ACCESS;
entry.grfAccessPermissions = principalAccessMask;
entry.grfInheritance = NO_INHERITANCE;
entry.Trustee.TrusteeForm = TRUSTEE_IS_SID;
entry.Trustee.TrusteeType = TRUSTEE_IS_USER;
entry.Trustee.ptstrName = static_cast<PWSTR>(principal);
ea.push_back(entry);
}
vector<wil::unique_sid> appSids;
appSids.reserve(accessRequestCount);
for (auto const end = accessRequests + accessRequestCount; accessRequests < end; ++accessRequests)
{
EXPLICIT_ACCESS_W entry{};
wil::unique_sid sid;
THROW_IF_FAILED(::DeriveAppContainerSidFromAppContainerName(accessRequests->appContainerName, &sid));
entry.grfAccessMode = GRANT_ACCESS;
entry.grfAccessPermissions = accessRequests->accessMask;
entry.grfInheritance = NO_INHERITANCE;
entry.Trustee.TrusteeForm = TRUSTEE_IS_SID;
entry.Trustee.TrusteeType = TRUSTEE_IS_USER;
entry.Trustee.ptstrName = static_cast<PWSTR>(sid.get());
appSids.push_back(std::move(sid));
ea.push_back(entry);
}
wil::unique_any<PACL, decltype(&::LocalFree), ::LocalFree> acl;
THROW_IF_WIN32_ERROR(::SetEntriesInAclW(static_cast<uint32_t>(ea.size()), ea.data(), nullptr, &acl));
auto absoluteSD = wil::make_unique_hlocal<SECURITY_DESCRIPTOR>();
THROW_IF_WIN32_BOOL_FALSE(::InitializeSecurityDescriptor(absoluteSD.get(), SECURITY_DESCRIPTOR_REVISION));
THROW_IF_WIN32_BOOL_FALSE(::SetSecurityDescriptorDacl(absoluteSD.get(), TRUE, acl.get(), FALSE));
DWORD sdLength = 0;
if (!::MakeSelfRelativeSD(absoluteSD.get(), nullptr, &sdLength))
{
auto err = ::GetLastError();
if (err != ERROR_INSUFFICIENT_BUFFER)
{
THROW_WIN32(err);
}
}
wil::unique_hlocal_security_descriptor selfRelativeSD{ ::LocalAlloc(LMEM_FIXED, sdLength) };
THROW_IF_WIN32_BOOL_FALSE(::MakeSelfRelativeSD(absoluteSD.get(), selfRelativeSD.get(), &sdLength));
*securityDescriptor = selfRelativeSD.release();
if (securityDescriptorLength)
{
*securityDescriptorLength = sdLength;
}
return S_OK;
}
CATCH_RETURN()

Просмотреть файл

@ -0,0 +1,58 @@
#include <pch.h>
#include "Microsoft.Windows.Security.AccessControl.h"
#include "Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers.g.cpp"
#include "Security.AccessControl.h"
#include <sddl.h>
namespace winrt::Microsoft::Windows::Security::AccessControl::implementation
{
wil::unique_hlocal_security_descriptor GetSecurityDescriptor(
array_view<winrt::Microsoft::Windows::Security::AccessControl::AppContainerNameAndAccess const> accessRequests,
hstring const& principalStringSid, uint32_t principalAccessMask, uint32_t* sdLength)
{
wil::unique_any_psid sid;
if (!principalStringSid.empty())
{
winrt::check_hresult(::ConvertStringSidToSidW(principalStringSid.data(), &sid));
}
std::vector<::AppContainerNameAndAccess> rawAccessRequests;
rawAccessRequests.reserve(accessRequests.size());
for (auto&& request : accessRequests)
{
rawAccessRequests.push_back({ request.appContainerName.data(), request.accessMask });
}
wil::unique_hlocal_security_descriptor sd;
winrt::check_hresult(
GetSecurityDescriptorForAppContainerNames(
rawAccessRequests.size(), rawAccessRequests.data(), sid.get(), principalAccessMask, &sd, sdLength));
return sd;
}
hstring SecurityDescriptorHelpers::GetSddlForAppContainerNames(
array_view<winrt::Microsoft::Windows::Security::AccessControl::AppContainerNameAndAccess const> accessRequests,
hstring const& principalStringSid, uint32_t principalAccessMask)
{
auto sd = GetSecurityDescriptor(accessRequests, principalStringSid, principalAccessMask, nullptr);
wil::unique_hlocal_string resultStr;
DWORD resultLen = 0;
winrt::check_bool(
::ConvertSecurityDescriptorToStringSecurityDescriptorW(
sd.get(), SDDL_REVISION_1,
OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION,
&resultStr, &resultLen));
return { resultStr.get(), resultLen };
}
com_array<uint8_t> SecurityDescriptorHelpers::GetSecurityDescriptorBytesFromAppContainerNames(
array_view<winrt::Microsoft::Windows::Security::AccessControl::AppContainerNameAndAccess const> accessRequests,
hstring const& principalStringSid, uint32_t principalAccessMask)
{
uint32_t sdLength = 0;
auto sd = GetSecurityDescriptor(accessRequests, principalStringSid, principalAccessMask, &sdLength);
auto begin = static_cast<uint8_t*>(sd.get());
return { begin, begin + sdLength };
}
}

Просмотреть файл

@ -0,0 +1,24 @@
#pragma once
#include "Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers.g.h"
namespace winrt::Microsoft::Windows::Security::AccessControl::implementation
{
struct SecurityDescriptorHelpers
{
SecurityDescriptorHelpers() = default;
static hstring GetSddlForAppContainerNames(
array_view<winrt::Microsoft::Windows::Security::AccessControl::AppContainerNameAndAccess const> accessRequests,
hstring const& principalStringSid, uint32_t principalAccessMask);
static com_array<uint8_t> GetSecurityDescriptorBytesFromAppContainerNames(
array_view<winrt::Microsoft::Windows::Security::AccessControl::AppContainerNameAndAccess const> accessRequests,
hstring const& principalStringSid, uint32_t principalAccessMask);
};
}
namespace winrt::Microsoft::Windows::Security::AccessControl::factory_implementation
{
struct SecurityDescriptorHelpers : SecurityDescriptorHelpersT<SecurityDescriptorHelpers, implementation::SecurityDescriptorHelpers>
{
};
}

Просмотреть файл

@ -0,0 +1,18 @@
#pragma once
#include <Windows.h>
struct AppContainerNameAndAccess
{
PCWSTR appContainerName;
UINT32 accessMask;
};
STDAPI GetSecurityDescriptorForAppContainerNames(
UINT32 accessRequestCount,
_In_reads_(accessRequestCount) const AppContainerNameAndAccess* accessRequests,
_In_opt_ PSID principal,
UINT32 principalAccessMask,
_Outptr_ PSECURITY_DESCRIPTOR* securityDescriptor,
_Out_opt_ UINT32* securityDescriptorSize
);

Просмотреть файл

@ -0,0 +1,43 @@
#pragma once
#include <Windows.h>
#include <wil/resource.h>
#include <wil/result.h>
#include <processthreadsapi.h>
namespace Security::Descriptors
{
wil::unique_any_psid GetCurrentProcessSid()
{
wil::unique_any_psid result;
wil::unique_process_heap_ptr<TOKEN_GROUPS> tg;
DWORD length = 0;
if (!::GetTokenInformation(
::GetCurrentProcessToken(),
TokenLogonSid,
nullptr,
0,
&length))
{
auto err = ::GetLastError();
if (err != ERROR_INSUFFICIENT_BUFFER)
{
THROW_WIN32(err);
}
tg.reset(static_cast<TOKEN_GROUPS*>(::HeapAlloc(::GetProcessHeap(), HEAP_ZERO_MEMORY, length)));
}
THROW_IF_WIN32_BOOL_FALSE(::GetTokenInformation(
::GetCurrentProcessToken(),
TokenLogonSid,
tg.get(),
length,
&length));
auto sidLength = ::GetLengthSid(tg->Groups[0].Sid);
result.reset(::HeapAlloc(::GetProcessHeap(), 0, sidLength));
THROW_IF_WIN32_BOOL_FALSE(::CopySid(
sidLength, result.get(), tg->Groups[0].Sid));
return result;
}
}

Просмотреть файл

@ -17,3 +17,4 @@ EXPORTS
MddGetGenerationId
MsixInstallLicenses
GetSecurityDescriptorForAppContainerNames

Просмотреть файл

@ -108,6 +108,7 @@
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\AccessControl\AccessControl.vcxitems" Label="AccessControl" />
<Import Project="..\AppLifecycle\AppLifecycle.vcxitems" Label="AppLifecycle" />
<Import Project="..\PushNotifications\PushNotifications.vcxitems" Label="PushNotifications" />
<Import Project="..\DynamicDependency\API\DynamicDependency.vcxitems" Label="Shared" />

Просмотреть файл

@ -27,7 +27,7 @@ wil::unique_event CreateShareableEvent(PCWSTR name)
EVENT_MODIFY_STATE | SYNCHRONIZE}};
THROW_IF_FAILED(GetSecurityDescriptorForAppContainerNames(
1, access, nullptr, EVENT_MODIFY_STATE | SYNCHRONIZE, &sd));
1, access, nullptr, EVENT_MODIFY_STATE | SYNCHRONIZE, &sd, nullptr));
SECURITY_ATTRIBUTES sa{};
sa.nLength = sizeof(sa);
@ -71,22 +71,23 @@ EventWaitHandle CreateShareableEvent(String name)
struct AppContainerNameAndAccess
{
PCWSTR appContainerName;
uint32_t accessMask;
UINT32 accessMask;
};
STDAPI GetSecurityDescriptorForAppContainerNames(
uint32_t accessRequestCount,
UINT32 accessRequestCount,
_In_reads_(accessRequestCount)
const AppContainerNameAndAccess* accessRequests,
_In_opt_ PSID principal,
uint32_t principalAccessMask,
_Outptr_ PSECURITY_DESCRIPTOR* securityDescriptor
UINT32 principalAccessMask,
_Outptr_ PSECURITY_DESCRIPTOR* securityDescriptor,
_Out_opt_ UINT32* securityDescriptorSize
)
```
If the **principal** parameter is null, the principal of the current thread is used.
If the function succeds, the returned `SECURITY_DESCRIPTOR` must be freed by calling [LocalFree](https://docs.microsoft.com/windows/desktop/api/winbase/nf-winbase-localfree).
If the function succeds, the `SECURITY_DESCRIPTOR` returned in `securityDescriptor` must be freed by calling [LocalFree](https://docs.microsoft.com/windows/desktop/api/winbase/nf-winbase-localfree).
## WinRT
```c#

Просмотреть файл

@ -0,0 +1,171 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"
#include <Security.AccessControl.h>
#include <winrt/Microsoft.Windows.Security.AccessControl.h>
using namespace WEX::Common;
using namespace WEX::Logging;
using namespace WEX::TestExecution;
namespace winrt
{
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
using namespace winrt::Windows::Foundation::Collections;
using namespace Microsoft::Windows::Security::AccessControl;
}
namespace Test::AccessControl
{
class APITests
{
wil::unique_process_handle m_processHandle;
winrt::com_ptr<IApplicationActivationManager> m_testAppLauncher;
static PCWSTR GetTestPackageFile()
{
return L"AccessControlTestAppPackage";
}
static PCWSTR GetTestPackageFullName()
{
return L"AccessControlTestPackage_1.0.0.0_" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE "8wekyb3d8bbwe";
}
static PCWSTR GetTestPackageFamilyName()
{
return L"AccessControlTestAppPackage_8wekyb3d8bbwe";
}
static PCWSTR GetTestPackageAppId()
{
return L"AccessControlTestAppPackage_8wekyb3d8bbwe!App";
}
void RunTestApp()
{
DWORD processId{};
VERIFY_SUCCEEDED(m_testAppLauncher->ActivateApplication(GetTestPackageAppId(), L"", AO_NONE, &processId));
m_processHandle.reset(::OpenProcess(SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION, FALSE, processId));
VERIFY_IS_TRUE(m_processHandle.is_valid());
}
public:
BEGIN_TEST_CLASS(APITests)
TEST_CLASS_PROPERTY(L"Description", L"Windows App SDK AccessControl test")
TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA")
TEST_CLASS_PROPERTY(L"RunAs:Class", L"RestrictedUser")
END_TEST_CLASS()
TEST_CLASS_SETUP(ClassInit)
{
try
{
::Test::Packages::RemovePackage(GetTestPackageFamilyName());
::Test::Bootstrap::Setup();
::Test::Packages::WapProj::AddPackage(TAEF::GetDeploymentDir(), GetTestPackageFile(), L".msix"); // Installs AccessControlTests.msix
}
catch (...)
{
return false;
}
m_testAppLauncher = winrt::create_instance<IApplicationActivationManager>(CLSID_ApplicationActivationManager, CLSCTX_ALL);
return true;
}
TEST_CLASS_CLEANUP(ClassUninit)
{
try
{
if (m_processHandle.is_valid())
{
VERIFY_IS_TRUE(wil::handle_wait(m_processHandle.get(), 10000));
DWORD exitCode{};
VERIFY_WIN32_BOOL_SUCCEEDED(GetExitCodeProcess(m_processHandle.get(), &exitCode));
VERIFY_ARE_EQUAL(exitCode, 0);
}
// Remove in reverse order to avoid conflicts between inter-dependent packages.
::Test::Packages::RemovePackage(GetTestPackageFamilyName());
::Test::Bootstrap::Cleanup();
}
catch (...)
{
return false;
}
return true;
}
TEST_METHOD_SETUP(MethodInit)
{
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_WindowsAppRuntimeFramework());
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_DynamicDependencyDataStore());
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_DynamicDependencyLifetimeManager());
return true;
}
TEST_METHOD_CLEANUP(MethodUninit)
{
if (m_processHandle.is_valid())
{
VERIFY_IS_TRUE(wil::handle_wait(m_processHandle.get(), 10000));
DWORD exitCode{};
VERIFY_WIN32_BOOL_SUCCEEDED(GetExitCodeProcess(m_processHandle.get(), &exitCode));
VERIFY_ARE_EQUAL(exitCode, 0);
}
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_WindowsAppRuntimeFramework());
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_DynamicDependencyDataStore());
VERIFY_IS_TRUE(::Test::Packages::IsPackageRegistered_DynamicDependencyLifetimeManager());
m_processHandle.reset();
return true;
}
void WaitForEvent(void* securityDescriptor)
{
wil::unique_event win32_event;
SECURITY_ATTRIBUTES sa{ sizeof(sa), securityDescriptor, FALSE };
win32_event.create(wil::EventOptions::None, L"AccessControlTest_Event", &sa);
VERIFY_IS_TRUE(win32_event.wait(5000));
}
TEST_METHOD(FlatAPITest)
{
RunTestApp();
::AppContainerNameAndAccess ac[1] = {{GetTestPackageFile(), EVENT_MODIFY_STATE | SYNCHRONIZE}};
wil::unique_hlocal_security_descriptor sd;
THROW_IF_FAILED(::GetSecurityDescriptorForAppContainerNames(1, ac, nullptr, EVENT_MODIFY_STATE | SYNCHRONIZE, &sd, nullptr));
WaitForEvent(sd.get());
}
TEST_METHOD(WinRTStringTest)
{
RunTestApp();
winrt::AppContainerNameAndAccess ac[1] = { {GetTestPackageFile(), EVENT_MODIFY_STATE | SYNCHRONIZE} };
auto sdString = winrt::SecurityDescriptorHelpers::GetSddlForAppContainerNames(ac, L"", EVENT_MODIFY_STATE | SYNCHRONIZE);
wil::unique_hlocal_security_descriptor sd;
VERIFY_WIN32_BOOL_SUCCEEDED(
ConvertStringSecurityDescriptorToSecurityDescriptorW(
sdString.data(), SDDL_REVISION_1, &sd, nullptr));
WaitForEvent(sd.get());
}
TEST_METHOD(WinRTBytesTest)
{
RunTestApp();
winrt::AppContainerNameAndAccess ac[1] = { {GetTestPackageFile(), EVENT_MODIFY_STATE | SYNCHRONIZE} };
auto sdBytes = winrt::SecurityDescriptorHelpers::GetSecurityDescriptorBytesFromAppContainerNames(ac, L"", EVENT_MODIFY_STATE | SYNCHRONIZE);
WaitForEvent(sdBytes.data());
}
};
}

Просмотреть файл

@ -0,0 +1,301 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{08bc78e0-63c6-49a7-81b3-6afc3deac4de}</ProjectGuid>
<RootNamespace>AccessControlTests</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\inc\inc.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeader>Use</PrecompiledHeader>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;..\inc;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>onecore.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)\..\WindowsAppRuntime_DLL;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;Microsoft.WindowsAppRuntime.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="APITests.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<PropertyGroup>
<VCLibsDebugConfigName Condition="'$(Configuration)' == 'Debug'">.Debug</VCLibsDebugConfigName>
<TestPkgDebugConfigName Condition="'$(Configuration)' == 'Debug'">_Debug</TestPkgDebugConfigName>
<TestPkgOutputPath>$(AppxPackageDir)\AccessControlTestAppPackage_1.0.0.0_$(PlatformTarget)$(TestPkgDebugConfigName)_Test</TestPkgOutputPath>
<TestPkgOutputFile>$(TestPkgOutputPath)\AccessControlTestAppPackage_1.0.0.0_$(PlatformTarget)$(TestPkgDebugConfigName).msix</TestPkgOutputFile>
</PropertyGroup>
<ItemGroup>
<CopyFileToFolders Include="$(TargetDir)..\AccessControlTestApp\AccessControlTestApp.exe" DestinationFolders="$(TargetDir)" TreatOutputAsContent="true" />
<CopyFileToFolders Include="$(TestPkgOutputFile)" DestinationFolders="$(TargetDir)" DestinationFileName="AccessControlTestAppPackage.msix" TreatOutputAsContent="true" />
<CopyFileToFolders Include="$(TestPkgOutputPath)\Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget)$(VCLibsDebugConfigName).14.00.appx" DestinationFolders="$(TargetDir)" DestinationFileName="VCLibs.appx" TreatOutputAsContent="true" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\dev\WindowsAppRuntime_BootstrapDLL\WindowsAppRuntime_BootstrapDLL.vcxproj">
<Project>{f76b776e-86f5-48c5-8fc7-d2795ecc9746}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Windows.Security.AccessControl">
<HintPath>$(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.Security.AccessControl.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Implementation>$(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.dll</Implementation>
</Reference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets" Condition="Exists('..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="APITests.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<CopyFileToFolders Include="$(TestPkgOutputPath)\Dependencies\$(PlatformTarget)\Microsoft.VCLibs.$(PlatformTarget)$(VCLibsDebugConfigName).14.00.appx" />
<CopyFileToFolders Include="$(TargetDir)..\AccessControlTestApp\AccessControlTestApp.exe" />
<CopyFileToFolders Include="$(TestPkgOutputFile)" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.58.210222006-develop" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.210913.7" targetFramework="native" />
</packages>

Просмотреть файл

@ -0,0 +1,5 @@
// pch.cpp: source file corresponding to the pre-compiled header
#include "pch.h"
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.

Просмотреть файл

@ -0,0 +1,34 @@
// pch.h: This is a precompiled header file.
// Files listed below are compiled only once, improving build performance for future builds.
// This also affects IntelliSense performance, including code completion and many code browsing features.
// However, files listed here are ALL re-compiled if any one of them is updated between builds.
// Do not add files here that you will be updating frequently as this negates the performance advantage.
#ifndef PCH_H
#define PCH_H
#include <unknwn.h>
#include <Windows.h>
#include <sddl.h>
#include <wil/result.h>
#include <wil/cppwinrt.h>
#include <wil/token_helpers.h>
#include <wil/resource.h>
#include <WexTestClass.h>
#include <string>
#include <wil/result_macros.h>
#include <wil/com.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <WindowsAppRuntime.Test.Package.h>
#include <WindowsAppRuntime.Test.TAEF.h>
#include <WindowsAppRuntime.Test.Bootstrap.h>
#include <ShObjIdl_core.h>
#endif //PCH_H

Просмотреть файл

@ -83,5 +83,11 @@
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.EnvironmentManager" ThreadingModel="both" />
</InProcessServer>
</Extension>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>Microsoft.WindowsAppRuntime.dll</Path>
<ActivatableClass ActivatableClassId="Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
</Package>

Просмотреть файл

@ -83,5 +83,11 @@
<ActivatableClass ActivatableClassId="Microsoft.Windows.System.EnvironmentManager" ThreadingModel="both" />
</InProcessServer>
</Extension>
<Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>Microsoft.WindowsAppRuntime.dll</Path>
<ActivatableClass ActivatableClassId="Microsoft.Windows.Security.AccessControl.SecurityDescriptorHelpers" ThreadingModel="both" />
</InProcessServer>
</Extension>
</Extensions>
</Package>

Просмотреть файл

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
</Project>

Просмотреть файл

@ -0,0 +1,278 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props')" />
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Reference Include="Microsoft.Windows.Security.AccessControl">
<HintPath>$(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.Windows.Security.AccessControl.winmd</HintPath>
<IsWinMDFile>true</IsWinMDFile>
<Implementation>$(OutDir)\..\WindowsAppRuntime_DLL\Microsoft.WindowsAppRuntime.dll</Implementation>
</Reference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\dev\WindowsAppRuntime_BootstrapDLL\WindowsAppRuntime_BootstrapDLL.vcxproj">
<Project>{f76b776e-86f5-48c5-8fc7-d2795ecc9746}</Project>
</ProjectReference>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>16.0</VCProjectVersion>
<Keyword>Win32Proj</Keyword>
<ProjectGuid>{d5667df6-a151-4081-abc7-b93e8e5604ce}</ProjectGuid>
<RootNamespace>AccessControlTestApp</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v142</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<UseOfMfc>false</UseOfMfc>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
<Import Project="..\..\inc\inc.vcxitems" Label="Shared" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;..\..\inc</AdditionalIncludeDirectories>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<LanguageStandard>stdcpp17</LanguageStandard>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL</AdditionalLibraryDirectories>
<AdditionalDependencies>onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;%(AdditionalDependencies)</AdditionalDependencies>
<DelayLoadDLLs>Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs)</DelayLoadDLLs>
</Link>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="..\..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets" Condition="Exists('..\..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets')" />
<Import Project="..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Taef.10.58.210222006-develop\build\Microsoft.Taef.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.ImplementationLibrary.1.0.210930.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\packages\Microsoft.Windows.CppWinRT.2.0.210913.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
<Target Name="CopyFiles" AfterTargets="AfterBuild">
<Copy SourceFiles="$(OutDir)\..\WindowsAppRuntime_BootstrapDLL\Microsoft.WindowsAppRuntime.Bootstrap.dll" DestinationFolder="$(OutDir)" />
</Target>
</Project>

Просмотреть файл

@ -0,0 +1,44 @@
#include "pch.h"
#include <testdef.h>
#include <iostream>
#include <sstream>
#include <wil/win32_helpers.h>
#include <winrt/Microsoft.Windows.Security.AccessControl.h>
#include <Security.AccessControl.h>
using namespace winrt;
using namespace winrt::Windows::ApplicationModel::Activation;
using namespace winrt::Windows::Foundation;
int main() try
{
winrt::init_apartment();
auto packageId = Windows::ApplicationModel::Package::Current().Id();
auto familyName = packageId.FamilyName();
std::wcout << L"Family name: " << familyName.data() << L"\n";
wil::unique_event win32_event;
for (int i = 0; i < 100 && !win32_event.is_valid(); ++i)
{
win32_event.try_open(L"AccessControlTest_Event", SYNCHRONIZE | EVENT_MODIFY_STATE);
std::cout << "Waiting to open event...\n";
::Sleep(100);
}
if (!win32_event.is_valid())
{
std::cout << "Timed out creating event.\n";
THROW_LAST_ERROR();
}
win32_event.SetEvent();
return 0;
}
catch (...)
{
std::cout << winrt::to_string(winrt::to_message()) << std::endl;
return 1; // in the event of unhandled test crash
}

Просмотреть файл

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Taef" version="10.58.210222006-develop" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.210913.7" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.210930.1" targetFramework="native" />
</packages>

Просмотреть файл

@ -0,0 +1,3 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#include "pch.h"

Просмотреть файл

@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See LICENSE in the project root for license information.
#pragma once
#include <windows.h>
#include <unknwn.h>
#include <appmodel.h>
#include <wil/result.h>
#include <wil/cppwinrt.h>
#include <wil/resource.h>
#include <winrt/Windows.ApplicationModel.h>
#include <winrt/Windows.ApplicationModel.Activation.h>
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/Windows.Management.Deployment.h>
#include <WindowsAppRuntime.Test.Bootstrap.h>

Просмотреть файл

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' &lt; '15.0'">
<VisualStudioVersion>15.0</VisualStudioVersion>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x86">
<Configuration>Debug</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x86">
<Configuration>Release</Configuration>
<Platform>x86</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration>
<Platform>ARM64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup>
<WapProjPath Condition="'$(WapProjPath)'==''">$(MSBuildExtensionsPath)\Microsoft\DesktopBridge\</WapProjPath>
</PropertyGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.props" />
<PropertyGroup>
<ProjectGuid>03ebf097-66c6-4996-95a3-28f6f5999e27</ProjectGuid>
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
<DefaultLanguage>en-US</DefaultLanguage>
<AppxPackageSigningEnabled>True</AppxPackageSigningEnabled>
<EntryPointProjectUniqueName>..\AccessControlTestApp\AccessControlTestApp.vcxproj</EntryPointProjectUniqueName>
<GenerateAppxPackageOnBuild>true</GenerateAppxPackageOnBuild>
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
<PackageCertificateKeyFile>$(RepoTestCertificatePFX)</PackageCertificateKeyFile>
<PackageCertificatePassword>$(RepoTestCertificatePassword)</PackageCertificatePassword>
<EnableSigningChecks>false</EnableSigningChecks>
<AppxPackageSigningTimestampDigestAlgorithm>SHA256</AppxPackageSigningTimestampDigestAlgorithm>
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
<GenerateTestArtifacts>True</GenerateTestArtifacts>
<AppxBundlePlatforms>$(Platform)</AppxBundlePlatforms>
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
</PropertyGroup>
<ItemGroup>
<AppxManifest Include="Package.appxmanifest">
<SubType>Designer</SubType>
</AppxManifest>
</ItemGroup>
<ItemGroup>
<Content Include="Images\SplashScreen.scale-200.png" />
<Content Include="Images\LockScreenLogo.scale-200.png" />
<Content Include="Images\Square150x150Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.scale-200.png" />
<Content Include="Images\Square44x44Logo.targetsize-24_altform-unplated.png" />
<Content Include="Images\StoreLogo.png" />
<Content Include="Images\Wide310x150Logo.scale-200.png" />
<None Include="MSTest.pfx" />
</ItemGroup>
<Import Project="$(WapProjPath)\Microsoft.DesktopBridge.targets" />
<ItemGroup>
<ProjectReference Include="..\AccessControlTestApp\AccessControlTestApp.vcxproj" />
</ItemGroup>
</Project>

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 432 B

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.2 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 1.7 KiB

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 637 B

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 283 B

Двоичные данные
test/TestApps/AccessControlTestAppPackage/Images/StoreLogo.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 456 B

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.0 KiB

Просмотреть файл

@ -0,0 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:uap5="http://schemas.microsoft.com/appx/manifest/uap/windows10/5"
xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities"
xmlns:com="http://schemas.microsoft.com/appx/manifest/com/windows10"
IgnorableNamespaces="uap uap5 rescap com">
<Identity
Name="AccessControlTestAppPackage"
Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US"
Version="1.0.0.0" />
<Properties>
<DisplayName>AccessControlTestAppPackage</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Images\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.17763.0" MaxVersionTested="10.0.19041.0" />
<PackageDependency Name="Microsoft.WindowsAppRuntime.Framework" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" MinVersion="0.0.0.0"/>
</Dependencies>
<Resources>
<Resource Language="x-generate"/>
</Resources>
<Applications>
<Application Id="App"
Executable="$targetnametoken$.exe"
EntryPoint="$targetentrypoint$">
<uap:VisualElements
DisplayName="AccessControlTestAppPackage"
Description="AccessControlTestAppPackage"
BackgroundColor="transparent"
Square150x150Logo="Images\Square150x150Logo.png"
Square44x44Logo="Images\Square44x44Logo.png">
<uap:DefaultTile Wide310x150Logo="Images\Wide310x150Logo.png" />
<uap:SplashScreen Image="Images\SplashScreen.png" uap5:Optional="true"/>
</uap:VisualElements>
<Extensions>
<uap:Extension Category="windows.protocol" EntryPoint="Windows.FullTrustApplication">
<uap:Protocol Name="windowsappruntimetestprotocol-packaged">
<uap:DisplayName>Windows App Runtime TestProtocol</uap:DisplayName>
</uap:Protocol>
</uap:Extension>
</Extensions>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<rescap:Capability Name="runFullTrust" />
</Capabilities>
</Package>

Просмотреть файл

@ -7,7 +7,7 @@
#include <appmodel.h>
#include <WindowsAppRuntime.Test.FileSystem.h>
#include <winrt/Windows.Management.Deployment.h>
#include <WexTestClass.h>
#define WINDOWSAPPRUNTIME_TEST_METADATA_VERSION 0x0004000107AF014DLLu