diff --git a/WindowsAppRuntime.sln b/WindowsAppRuntime.sln index 27a9e51778..0f9e52b1ac 100644 --- a/WindowsAppRuntime.sln +++ b/WindowsAppRuntime.sln @@ -710,6 +710,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Windows.Managemen {B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1} EndProjectSection EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UndockedRegFreeWinRT", "UndockedRegFreeWinRT", "{6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "URFW_WinAppSDK", "test\UndockedRegFreeWinRT\URFW_WinAppSDK\URFW_WinAppSDK.vcxproj", "{E0BD4D47-AA5C-4354-961D-032E2AB612E1}" + ProjectSection(ProjectDependencies) = postProject + {14560FF9-B7AC-45B5-A120-2B49380B0D0D} = {14560FF9-B7AC-45B5-A120-2B49380B0D0D} + {B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "URFW_ExeUsingWinAppSDK", "test\UndockedRegFreeWinRT\URFW_ExeUsingWinAppSDK\URFW_ExeUsingWinAppSDK.vcxproj", "{14560FF9-B7AC-45B5-A120-2B49380B0D0D}" + ProjectSection(ProjectDependencies) = postProject + {B73AD907-6164-4294-88FB-F3C9C10DA1F1} = {B73AD907-6164-4294-88FB-F3C9C10DA1F1} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -2402,6 +2415,38 @@ Global {57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x64.Build.0 = Release|x64 {57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.ActiveCfg = Release|x86 {57E6CCBE-EDEB-4300-8334-98A591D11B3F}.Release|x86.Build.0 = Release|x86 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|Any CPU.ActiveCfg = Debug|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|Any CPU.Build.0 = Debug|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|ARM64.Build.0 = Debug|ARM64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x64.ActiveCfg = Debug|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x64.Build.0 = Debug|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x86.ActiveCfg = Debug|Win32 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Debug|x86.Build.0 = Debug|Win32 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|Any CPU.ActiveCfg = Release|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|Any CPU.Build.0 = Release|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|ARM64.ActiveCfg = Release|ARM64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|ARM64.Build.0 = Release|ARM64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x64.ActiveCfg = Release|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x64.Build.0 = Release|x64 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x86.ActiveCfg = Release|Win32 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1}.Release|x86.Build.0 = Release|Win32 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|Any CPU.ActiveCfg = Debug|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|Any CPU.Build.0 = Debug|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|ARM64.ActiveCfg = Debug|ARM64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|ARM64.Build.0 = Debug|ARM64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x64.ActiveCfg = Debug|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x64.Build.0 = Debug|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x86.ActiveCfg = Debug|Win32 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Debug|x86.Build.0 = Debug|Win32 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|Any CPU.ActiveCfg = Release|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|Any CPU.Build.0 = Release|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|ARM64.ActiveCfg = Release|ARM64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|ARM64.Build.0 = Release|ARM64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x64.ActiveCfg = Release|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x64.Build.0 = Release|x64 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x86.ActiveCfg = Release|Win32 + {14560FF9-B7AC-45B5-A120-2B49380B0D0D}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -2612,6 +2657,9 @@ Global {48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38} = {448ED2E5-0B37-4D97-9E6B-8C10A507976A} {B5798CEB-4E60-4D2D-B456-7C406B5F5B67} = {48948EF9-8B91-4F7A-98AD-0F8FA3EFAA38} {57E6CCBE-EDEB-4300-8334-98A591D11B3F} = {716C26A0-E6B0-4981-8412-D14A4D410531} + {6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E} = {8630F7AA-2969-4DC9-8700-9B468C1DC21D} + {E0BD4D47-AA5C-4354-961D-032E2AB612E1} = {6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E} + {14560FF9-B7AC-45B5-A120-2B49380B0D0D} = {6FFE9EEB-E20C-427A-A3C9-1E48D6904E1E} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4B3D7591-CFEC-4762-9A07-ABE99938FB77} diff --git a/dev/Common/IsWindowsVersion.h b/dev/Common/IsWindowsVersion.h index 88ca801918..8f2bbd3f23 100644 --- a/dev/Common/IsWindowsVersion.h +++ b/dev/Common/IsWindowsVersion.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #ifndef __ISWINDOWSVERSION_H @@ -31,30 +31,57 @@ inline bool IsExportPresent( return true; } +inline bool IsMinVersion( + uint64_t minVersion) +{ + PCWSTR subkey{ L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion" }; + auto regkey{ wil::reg::open_unique_key(HKEY_LOCAL_MACHINE, subkey) }; + const uint64_t major{ wil::reg::get_value_dword(regkey.get(), L"CurrentMajorVersionNumber") }; + const uint64_t minor{ wil::reg::get_value_dword(regkey.get(), L"CurrentMinorVersionNumber") }; + const std::wstring buildAsString{ wil::reg::get_value_string(regkey.get(), L"CurrentBuildNumber") }; + const uint64_t build{ std::stoul(buildAsString.c_str(), nullptr, 10) }; + const uint64_t revision{ wil::reg::get_value_dword(regkey.get(), L"BaseBuildRevisionNumber") }; + const uint64_t version{ (major << 48) | (minor << 32) | (build << 16) | revision }; + return version >= minVersion; +} + +constexpr uint64_t ToVersion64(uint32_t major, uint32_t minor=0, uint32_t build=0, uint32_t revision=0) +{ + return (static_cast(major) << 48) | + (static_cast(minor) << 32) | + (static_cast(build) << 16) | + static_cast(revision); +} + inline bool IsWindows10_19H1OrGreater() { - // GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka 19H1) + // GetPackageInfo2() added to kernelbase.dll in NTDDI_WIN10_19H1 (aka Windows 10 19H1 aka 10.0.18363.0) return IsExportPresent(L"kernelbase.dll", "GetPackageInfo2"); } inline bool IsWindows10_20H1OrGreater() { - // GetPackageInfo3() added to kernelbase.dll in NTDDI_WIN10_VB (aka 20H1) + // GetPackageInfo3() added to kernelbase.dll in NTDDI_WIN10_VB (aka Windows 10 20H1 aka 10.0.19041.0) return IsExportPresent(L"kernelbase.dll", "GetPackageInfo3"); } inline bool IsWindows11_21H2OrGreater() { - // GetMachineTypeAttributes() added to kernelbase.dll in NTDDI_WIN10_CO (aka Windows 11 21H2) + // GetMachineTypeAttributes() added to kernelbase.dll in NTDDI_WIN10_CO (aka Windows 11 21H2 aka 10.0.22021.0) return IsExportPresent(L"kernelbase.dll", "GetMachineTypeAttributes"); } inline bool IsWindows11_22H2OrGreater() { - // GetPackageGraphRevisionId() added to kernelbase.dll in NTDDI_WIN10_NI (aka Windows 11 22H2) + // GetPackageGraphRevisionId() added to kernelbase.dll in NTDDI_WIN10_NI (aka Windows 11 22H2 aka 10.0.22621.0) return IsExportPresent(L"kernelbase.dll", "GetPackageGraphRevisionId"); } -inline bool IsWindows11_23H1OrGreater() +inline bool IsWindows11_23H2OrGreater() +{ + // No good symbol to probe so version check (Windows 11 23H2 aka 10.0.22631.0) + return IsMinVersion(ToVersion64(10, 0, 22631, 0)); +} +inline bool IsWindows11_24H2OrGreater() { - // TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 23H1) + // TryCreatePackageDependency2() added to in NTDDI_WIN10_GE (aka Windows 11 24H2 aka TBD) return IsExportPresent(L"api-ms-win-appmodel-runtime-l1-1-7.dll", "TryCreatePackageDependency2"); } } diff --git a/dev/Common/Security.IntegrityLevel.h b/dev/Common/Security.IntegrityLevel.h index 90ee0759e0..43b4a4db99 100644 --- a/dev/Common/Security.IntegrityLevel.h +++ b/dev/Common/Security.IntegrityLevel.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #ifndef __SECURITY_INTEGRITYLEVEL_H @@ -8,7 +8,7 @@ namespace Security::IntegrityLevel { inline DWORD GetIntegrityLevel(HANDLE token = nullptr) { - wistd::unique_ptr tokenMandatoryLabel{ + auto tokenMandatoryLabel{ wil::get_token_information_failfast( !token ? GetCurrentThreadEffectiveToken() : token) }; return *GetSidSubAuthority((*tokenMandatoryLabel).Label.Sid, diff --git a/dev/Common/Security.User.h b/dev/Common/Security.User.h index 87e7d0d8c2..b3e11b0588 100644 --- a/dev/Common/Security.User.h +++ b/dev/Common/Security.User.h @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #ifndef __SECURITY_USER_H @@ -13,7 +13,7 @@ inline bool IsLocalSystem(HANDLE token = nullptr) DWORD localSystemSidBufferSize{ ARRAYSIZE(localSystemSidBuffer) }; THROW_IF_WIN32_BOOL_FALSE(CreateWellKnownSid(WinLocalSystemSid, nullptr, localSystemSid, &localSystemSidBufferSize)); - wistd::unique_ptr user{ wil::get_token_information(!token ? GetCurrentThreadEffectiveToken() : token) }; + const auto user{ wil::get_token_information(!token ? GetCurrentThreadEffectiveToken() : token) }; PSID userSid{ user->User.Sid }; return !!EqualSid(userSid, localSystemSid); diff --git a/dev/Common/WindowsAppRuntime.VersionInfo.cpp b/dev/Common/WindowsAppRuntime.VersionInfo.cpp index 2dda2aae1d..1aec8a4650 100644 --- a/dev/Common/WindowsAppRuntime.VersionInfo.cpp +++ b/dev/Common/WindowsAppRuntime.VersionInfo.cpp @@ -122,8 +122,8 @@ STDAPI WindowsAppRuntime_VersionInfo_TestInitialize( const bool mainPackageFamilyNameIsEmpty{ !mainPackageFamilyName || (*mainPackageFamilyName == L'0') }; if (MddCore::Win11::IsSupported()) { - // Framework is optional but Main is never specified - FAIL_FAST_HR_IF(E_UNEXPECTED, !mainPackageFamilyNameIsEmpty); + // Framework is optional but Main is never used + mainPackageFamilyName = nullptr; } else { diff --git a/dev/DeploymentAgent/packages.config b/dev/DeploymentAgent/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/dev/DeploymentAgent/packages.config +++ b/dev/DeploymentAgent/packages.config @@ -1,5 +1,5 @@  - + diff --git a/dev/Kozani/KozaniAppGraph/packages.config b/dev/Kozani/KozaniAppGraph/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniAppGraph/packages.config +++ b/dev/Kozani/KozaniAppGraph/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniHostRuntime/packages.config b/dev/Kozani/KozaniHostRuntime/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniHostRuntime/packages.config +++ b/dev/Kozani/KozaniHostRuntime/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniManager/packages.config b/dev/Kozani/KozaniManager/packages.config index 8d63d7f888..9a109a4765 100644 --- a/dev/Kozani/KozaniManager/packages.config +++ b/dev/Kozani/KozaniManager/packages.config @@ -4,6 +4,6 @@ - + diff --git a/dev/Kozani/KozaniManagerRuntime/packages.config b/dev/Kozani/KozaniManagerRuntime/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniManagerRuntime/packages.config +++ b/dev/Kozani/KozaniManagerRuntime/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniPackage/packages.config b/dev/Kozani/KozaniPackage/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniPackage/packages.config +++ b/dev/Kozani/KozaniPackage/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniRemoteManager/KozaniDvcServer.cpp b/dev/Kozani/KozaniRemoteManager/KozaniDvcServer.cpp index 36af192dac..c89a6bfcff 100644 --- a/dev/Kozani/KozaniRemoteManager/KozaniDvcServer.cpp +++ b/dev/Kozani/KozaniRemoteManager/KozaniDvcServer.cpp @@ -18,7 +18,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager { if (timerOrWaitFired) { - // Timer timed out. This shouldn't happen as we wait infinite time. + // Timer timed out. This shouldn't happen as we wait infinite time. LOG_HR_MSG(E_UNEXPECTED, "Wait timed out tracking process lifetime."); return; } @@ -56,7 +56,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager } { - // Acquire lock to make sure no other threads are using the m_dvcHandle so we can safely close it. + // Acquire lock to make sure no other threads are using the m_dvcHandle so we can safely close it. auto lock{ std::unique_lock(m_dvcLock) }; m_dvcHandle.reset(); } @@ -96,12 +96,12 @@ namespace Microsoft::Kozani::KozaniRemoteManager { auto lock{ std::unique_lock(m_dvcLock) }; - wil::unique_channel_handle wtsHandle{ + wil::unique_channel_handle wtsHandle{ ::WTSVirtualChannelOpenEx(WTS_CURRENT_SESSION, const_cast(DvcChannelName), WTS_CHANNEL_OPTION_DYNAMIC) }; - // If wtsHandle is nullptr, the DVC channel doesn't exist. It could mean the current session is not a remote session or - // the client of this remote session has not created a listener of this DVC channel. It is required that the client has - // created a DVC channel listener to listen to this specific channel name before the server can open the named DVC channel. + // If wtsHandle is nullptr, the DVC channel doesn't exist. It could mean the current session is not a remote session or + // the client of this remote session has not created a listener of this DVC channel. It is required that the client has + // created a DVC channel listener to listen to this specific channel name before the server can open the named DVC channel. // Otherwise, ERROR_GEN_FAILURE (31) may be returned. THROW_LAST_ERROR_IF_NULL(wtsHandle); @@ -137,10 +137,10 @@ namespace Microsoft::Kozani::KozaniRemoteManager RETURN_HR(hr); } - // CHANNEL_PDU_LENGTH is the max amount of data sent/received in one DVC operation. Data larger than that is segmented into chunks of + // CHANNEL_PDU_LENGTH is the max amount of data sent/received in one DVC operation. Data larger than that is segmented into chunks of // that size and sent/received as multiple operations. BYTE readBuffer[CHANNEL_PDU_LENGTH]; - + std::vector pduBuffer; UINT32 pduSize{}; bool isPartialData{}; @@ -190,7 +190,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager if (GetOverlappedResult(m_dvcHandle.get(), &overlappedRead, &bytesRead, FALSE)) { const BYTE* pdu{}; - // Failing to process DVC data will not bubble up the failure, which will end the DVC listener thread. + // Failing to process DVC data will not bubble up the failure, which will end the DVC listener thread. // As a server, it should be robust to mal-formatted data. if (SUCCEEDED_LOG(ProcessDvcDataChunk(readBuffer, bytesRead, isPartialData, pduBuffer, pduSize, &pdu))) { @@ -246,7 +246,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager return S_OK; case CHANNEL_FLAG_FIRST: - // First chunk of the Kozani PDU - the data can span multiple Virtual Channel data chunks and the individual chunks will need + // First chunk of the Kozani PDU - the data can span multiple Virtual Channel data chunks and the individual chunks will need // to be reassembled in that case. The pduBuffer is used to reassemble the Kozani PDU. Reserve the total size needed. pduSize = header->length; pduBuffer.clear(); @@ -314,7 +314,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager auto activateAppThread{ std::thread(&KozaniDvcServer::ProcessActivateAppRequestThreadFunc, this, std::move(pdu)) }; activateAppThread.detach(); } - + break; case Dvc::ProtocolDataUnit::AppTerminationNotice: @@ -336,14 +336,14 @@ namespace Microsoft::Kozani::KozaniRemoteManager std::string errorMessage; const HRESULT hr{ LOG_IF_FAILED(ProcessActivateAppRequest(pdu, appActivatedAndTracked, errorMessage)) }; - // If ProcessActivateAppRequest failed but appActivatedAndTracked is true, it means there was failure after the app was activated and + // If ProcessActivateAppRequest failed but appActivatedAndTracked is true, it means there was failure after the app was activated and // its process lifetime tracked. Such failure is benign and we should not send failure ActivateAppResult to client. if (FAILED(hr) && !appActivatedAndTracked) { SendActivateAppResult(pdu.activity_id(), hr, 0, false, errorMessage); - // ERROR_ALREADY_EXISTS is due to the activity Id being the same as an existing activity already tracked in the m_activityMap. - // Do not remove it from the map. + // ERROR_ALREADY_EXISTS is due to the activity Id being the same as an existing activity already tracked in the m_activityMap. + // Do not remove it from the map. if (hr != HRESULT_FROM_WIN32(ERROR_ALREADY_EXISTS)) { ConnectionManager& connectionManager{ KozaniRemoteManagerModule::GetConnectionManagerInstance() }; @@ -364,8 +364,8 @@ namespace Microsoft::Kozani::KozaniRemoteManager CATCH_LOG_RETURN() HRESULT KozaniDvcServer::ProcessActivateAppRequest( - _In_ Dvc::ProtocolDataUnit& pdu, - _Out_ bool& appActivatedAndTracked, + _In_ Dvc::ProtocolDataUnit& pdu, + _Out_ bool& appActivatedAndTracked, _Out_ std::string& errorMessage) noexcept try { appActivatedAndTracked = false; @@ -385,7 +385,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager } { - // Acquire lock before adding the activity Id to the m_activityMap but do not hold the lock while activating the app as + // Acquire lock before adding the activity Id to the m_activityMap but do not hold the lock while activating the app as // that can take some time and we do not want one app activation to block others. ConnectionManager& connectionManager{ KozaniRemoteManagerModule::GetConnectionManagerInstance() }; auto lock{ connectionManager.m_activityMapLock.lock_exclusive() }; @@ -404,9 +404,9 @@ namespace Microsoft::Kozani::KozaniRemoteManager wil::com_ptr appLauncher; { - // Lock and assign m_appLauncher to local com_ptr appLauncher, which adds ref count of the IKozaniApplicationLauncher object to + // Lock and assign m_appLauncher to local com_ptr appLauncher, which adds ref count of the IKozaniApplicationLauncher object to // keep it alive through this method. m_appLauncher can be replaced with a different object and deref in another thread when there is another - // client connection coming in. Do not hold the lock during app activation so if the current activation takes a long time it will not block + // client connection coming in. Do not hold the lock during app activation so if the current activation takes a long time it will not block // subsequent activation requests. auto lock{ m_appLauncherLock.lock_shared() }; appLauncher = m_appLauncher; @@ -450,7 +450,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager FAIL_FAST_MSG("Logic error - should have handled all supported launch contracts."); break; } - + // When we reach here, activation is successful. bool isNewInstance{}; { @@ -461,7 +461,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager auto iter{ connectionManager.m_activityMap.find(pdu.activity_id()) }; if (iter == connectionManager.m_activityMap.end()) { - // Rare case - the app is terminated right after launch and the activity has been removed from the map from the other thread tracking + // Rare case - the app is terminated right after launch and the activity has been removed from the map from the other thread tracking // the lifetime of the process, before reaching here. There is nothing to do after that. return S_OK; } @@ -469,7 +469,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager AppActivationInfo& appInfo{ iter->second }; if (appInfo.activationStatus == AppActivationStatus::TerminationRequestedFromClient) { - // The client has already requested termination of the app. Honor it now. + // The client has already requested termination of the app. Honor it now. wil::unique_handle process{ OpenProcess(PROCESS_TERMINATE, FALSE, processId) }; if (process) { @@ -518,7 +518,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager else { // The process Id is already in the m_processIdMap, which means the app activation does not create a new process. - // Apps can be single instance, which will use the same process to respond to multiple activations. + // Apps can be single instance, which will use the same process to respond to multiple activations. // Remove the activity entry from the m_activityMap as we will not track duplicated activities backed by the same process. connectionManager.m_activityMap.erase(iter); } @@ -564,11 +564,11 @@ namespace Microsoft::Kozani::KozaniRemoteManager for (int i = 0; i < filePathsCount; i++) { std::wstring clientLocalPath{ ::Microsoft::Utf8::ToUtf16(args.file_paths(i)) }; - + filePathArray.emplace_back(GetRedirectedClientPath(clientLocalPath)); pFilePaths[i] = filePathArray.back().c_str(); } - + KozaniAppType appType{ GetAppType(appUserModelId) }; std::wstring verb{ ::Microsoft::Utf8::ToUtf16(args.verb()) }; HRESULT hrActivateApp{ appLauncher->LaunchFiles(appUserModelId.c_str(), verb.c_str(), filePathsCount, pFilePaths, &appType, &processId) }; @@ -641,8 +641,8 @@ namespace Microsoft::Kozani::KozaniRemoteManager if (appInfo.pid == 0) { - // The app activation has not finished yet. It will be terminated immediately upon activation since it is - // marked with AppActivationStatus::TerminationRequestedFromClient. + // The app activation has not finished yet. It will be terminated immediately upon activation since it is + // marked with AppActivationStatus::TerminationRequestedFromClient. return S_OK; } @@ -661,7 +661,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager } CATCH_RETURN() - // Convert local path from the remote client to a path that can be addressed by the remote desktop server. Local drives of the client have been + // Convert local path from the remote client to a path that can be addressed by the remote desktop server. Local drives of the client have been // rediected to the server so the server can directly access them. For example, local path "C:\data\MyFile.txt" will be redirected to the server // side with addressable path "\\tsclient\C\data\MyFile.txt" std::wstring KozaniDvcServer::GetRedirectedClientPath(const std::wstring& localPath) @@ -712,7 +712,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager HANDLE events[] = { m_dvcThreadStarted.get(), m_dvcThreadExit.get() }; LOG_HR_MSG(KOZANI_E_INFO, "[StartDvcListenerThread] Waiting for listener thread starting status"); - // Wait for listerner thread to start successfully. Wait no longer than 5s. + // Wait for listerner thread to start successfully. Wait no longer than 5s. DWORD result = WaitForMultipleObjects(ARRAYSIZE(events), events, FALSE, 5000); THROW_LAST_ERROR_IF_MSG(result == WAIT_FAILED, "[StartDvcListenerThread] WaitForMultipleObjects() failed."); @@ -750,7 +750,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager } m_errorFromDvcListener = errorCode; - LOG_HR_MSG(errorCode, "DVC listener thread exiting. Error message: %s", erroMessage); + LOG_HR_MSG(errorCode, "DVC listener thread exiting. Error message: %hs", erroMessage); m_dvcThreadExit.SetEvent(); @@ -789,13 +789,13 @@ namespace Microsoft::Kozani::KozaniRemoteManager ReportDvcWriterError(HRESULT_FROM_WIN32(error)); THROW_WIN32_MSG(error, "DVC WriteFile failed."); } - + if (bytesWritten != size) { ReportDvcWriterError(E_UNEXPECTED); THROW_HR_MSG(E_UNEXPECTED, "DVC WriteFile only writes %u bytes while %u bytes are expected.", bytesWritten, size); } - + return; } @@ -809,7 +809,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager m_dvcThreadExit.SetEvent(); { - // Close the DVC handle as this DVC server is going to be shut down. + // Close the DVC handle as this DVC server is going to be shut down. auto lockDvc{ std::unique_lock(m_dvcLock) }; m_dvcHandle.reset(); } @@ -823,7 +823,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager void KozaniDvcServer::SendConnectionAck(PCSTR connectionId) { uint64_t activityId{ KozaniRemoteManagerModule::GetConnectionManagerInstance().GetNewActivityId() }; - + std::string pdu{ CreateConnectionAckPdu(connectionId, activityId) }; SendDvcProtocolData(pdu.c_str(), static_cast(pdu.size())); } @@ -845,7 +845,7 @@ namespace Microsoft::Kozani::KozaniRemoteManager SendDvcProtocolData(pdu.c_str(), static_cast(pdu.size())); } - // Look up the type of the app from the m_appTypeMap as an optimization, as the launcher finds the type of the app (UWP or packaged desktop app) + // Look up the type of the app from the m_appTypeMap as an optimization, as the launcher finds the type of the app (UWP or packaged desktop app) // by different activation API behaviors. At first, the app type is unknown for a particular AUMID. Once it is activated for file or protocol, // the appLauncher returns the app type, so we can cache in the map for faster activation next time. KozaniAppType KozaniDvcServer::GetAppType(const std::wstring& appUserModelId) diff --git a/dev/Kozani/KozaniRemoteManager/packages.config b/dev/Kozani/KozaniRemoteManager/packages.config index 8d63d7f888..9a109a4765 100644 --- a/dev/Kozani/KozaniRemoteManager/packages.config +++ b/dev/Kozani/KozaniRemoteManager/packages.config @@ -4,6 +4,6 @@ - + diff --git a/dev/Kozani/KozaniRemoteManagerLauncher/packages.config b/dev/Kozani/KozaniRemoteManagerLauncher/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniRemoteManagerLauncher/packages.config +++ b/dev/Kozani/KozaniRemoteManagerLauncher/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniSendToLocal/packages.config b/dev/Kozani/KozaniSendToLocal/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniSendToLocal/packages.config +++ b/dev/Kozani/KozaniSendToLocal/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniSendToRemote/packages.config b/dev/Kozani/KozaniSendToRemote/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniSendToRemote/packages.config +++ b/dev/Kozani/KozaniSendToRemote/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/KozaniSettings/packages.config b/dev/Kozani/KozaniSettings/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/KozaniSettings/packages.config +++ b/dev/Kozani/KozaniSettings/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/Kozani/MakeMSIX/packages.config b/dev/Kozani/MakeMSIX/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/Kozani/MakeMSIX/packages.config +++ b/dev/Kozani/MakeMSIX/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/MRTCore/mrt/Core/src/packages.config b/dev/MRTCore/mrt/Core/src/packages.config index e9fecf8c0b..cd737de612 100644 --- a/dev/MRTCore/mrt/Core/src/packages.config +++ b/dev/MRTCore/mrt/Core/src/packages.config @@ -3,5 +3,5 @@ - + diff --git a/dev/MRTCore/mrt/mrm/UnitTests/packages.config b/dev/MRTCore/mrt/mrm/UnitTests/packages.config index 3a3c1cd7e9..c4ab02ac24 100644 --- a/dev/MRTCore/mrt/mrm/UnitTests/packages.config +++ b/dev/MRTCore/mrt/mrm/UnitTests/packages.config @@ -1,5 +1,5 @@  - + diff --git a/dev/MRTCore/mrt/mrm/mrmex/packages.config b/dev/MRTCore/mrt/mrm/mrmex/packages.config index a63e6c97b3..20783ec656 100644 --- a/dev/MRTCore/mrt/mrm/mrmex/packages.config +++ b/dev/MRTCore/mrt/mrm/mrmex/packages.config @@ -1,4 +1,4 @@  - + diff --git a/dev/MRTCore/mrt/mrm/mrmmin/packages.config b/dev/MRTCore/mrt/mrm/mrmmin/packages.config index a63e6c97b3..20783ec656 100644 --- a/dev/MRTCore/mrt/mrm/mrmmin/packages.config +++ b/dev/MRTCore/mrt/mrm/mrmmin/packages.config @@ -1,4 +1,4 @@  - + diff --git a/dev/PackageManager/API/pch.h b/dev/PackageManager/API/pch.h index 3dcd1b1b1a..d1c43b3fde 100644 --- a/dev/PackageManager/API/pch.h +++ b/dev/PackageManager/API/pch.h @@ -28,5 +28,6 @@ #include #include +#include #include "MsixPackageManager.h" diff --git a/dev/PushNotifications/PushNotificationsLongRunningTask.StartupTask/packages.config b/dev/PushNotifications/PushNotificationsLongRunningTask.StartupTask/packages.config index d7178814bc..859d3c626c 100644 --- a/dev/PushNotifications/PushNotificationsLongRunningTask.StartupTask/packages.config +++ b/dev/PushNotifications/PushNotificationsLongRunningTask.StartupTask/packages.config @@ -1,7 +1,7 @@  - + - \ No newline at end of file + diff --git a/dev/PushNotifications/PushNotificationsLongRunningTask/packages.config b/dev/PushNotifications/PushNotificationsLongRunningTask/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/PushNotifications/PushNotificationsLongRunningTask/packages.config +++ b/dev/PushNotifications/PushNotificationsLongRunningTask/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/RestartAgent/packages.config b/dev/RestartAgent/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/dev/RestartAgent/packages.config +++ b/dev/RestartAgent/packages.config @@ -1,5 +1,5 @@  - + diff --git a/dev/WindowsAppRuntime_BootstrapDLL/framework.h b/dev/WindowsAppRuntime_BootstrapDLL/framework.h index 7fb011d015..9ec9b7c6bb 100644 --- a/dev/WindowsAppRuntime_BootstrapDLL/framework.h +++ b/dev/WindowsAppRuntime_BootstrapDLL/framework.h @@ -16,6 +16,7 @@ #include #include #include +#include #include #include diff --git a/dev/WindowsAppRuntime_BootstrapDLL/packages.config b/dev/WindowsAppRuntime_BootstrapDLL/packages.config index e9fecf8c0b..cd737de612 100644 --- a/dev/WindowsAppRuntime_BootstrapDLL/packages.config +++ b/dev/WindowsAppRuntime_BootstrapDLL/packages.config @@ -3,5 +3,5 @@ - + diff --git a/dev/WindowsAppRuntime_DLL/dllmain.cpp b/dev/WindowsAppRuntime_DLL/dllmain.cpp index 60c61157c6..8a7665a3f3 100644 --- a/dev/WindowsAppRuntime_DLL/dllmain.cpp +++ b/dev/WindowsAppRuntime_DLL/dllmain.cpp @@ -13,8 +13,33 @@ #include <../Detours/detours.h> +static bool g_isDetoursInitialized{}; + static HRESULT DetoursInitialize() { + // We only use Detours for downlevel support for RegFree WinRT, + // Dynamic Dependencies and (some) Package Graph functionality. + // + // URFW is required where OS RegFree WinRT doesn't exist (RS5). + // + // Detours is required by Dynamic Dependency's polyfill implementation. + // Unecessary when delegating to the OS Dynamic Dependency API + // (discoverable via MddCore::Win11::IsSupported() in dev\DynamicDependency\API\MddWin11.h). + // + // PackageGraph detours are required by Dynamic Dependency's polyfill implementation. + // + // QED IsDetoursNeeded == (OS <= RS5) or (not MddCore::Win11::IsSupported()) + // + // BUT as we've always run with URFW enabled we'll be paranoid for now and always use Detours + // and URFW when Dynamic Dependency doesn't delegate to the OS API (i.e. when WinAppSDK Dynamic Dependency + // implementation does polyfill, which will never be on systems lacking OS RegFree WinRT). + // + if (MddCore::Win11::IsSupported()) + { + // No need for Detours + return S_OK; + } + // Only detour APIs for not-packaged processes if (AppModel::Identity::IsPackagedProcess()) { @@ -33,11 +58,18 @@ static HRESULT DetoursInitialize() FAIL_FAST_IF_FAILED(MddDetourPackageGraphInitialize()); FAIL_FAST_IF_FAILED(UrfwInitialize()); FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit()); + g_isDetoursInitialized = true; return S_OK; } static HRESULT DetoursShutdown() { + // Did we detour APIs? + if (!g_isDetoursInitialized) + { + return S_OK; + } + // Only detour APIs for not-packaged processes if (AppModel::Identity::IsPackagedProcess()) { @@ -56,6 +88,7 @@ static HRESULT DetoursShutdown() UrfwShutdown(); MddDetourPackageGraphShutdown(); FAIL_FAST_IF_WIN32_ERROR(DetourTransactionCommit()); + g_isDetoursInitialized = false; return S_OK; } diff --git a/dev/WindowsAppRuntime_DLL/packages.config b/dev/WindowsAppRuntime_DLL/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/dev/WindowsAppRuntime_DLL/packages.config +++ b/dev/WindowsAppRuntime_DLL/packages.config @@ -4,5 +4,5 @@ - + diff --git a/dev/WindowsAppRuntime_DLL/pch.h b/dev/WindowsAppRuntime_DLL/pch.h index ec070ce0f0..c4c4147ace 100644 --- a/dev/WindowsAppRuntime_DLL/pch.h +++ b/dev/WindowsAppRuntime_DLL/pch.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/eng/Version.Dependencies.xml b/eng/Version.Dependencies.xml index fba4803c9f..044fc3050f 100644 --- a/eng/Version.Dependencies.xml +++ b/eng/Version.Dependencies.xml @@ -32,6 +32,6 @@ - + diff --git a/installer/dev/packages.config b/installer/dev/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/installer/dev/packages.config +++ b/installer/dev/packages.config @@ -1,5 +1,5 @@  - + diff --git a/installer/test/InstallerFunctionalTests/packages.config b/installer/test/InstallerFunctionalTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/installer/test/InstallerFunctionalTests/packages.config +++ b/installer/test/InstallerFunctionalTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/AccessControlTests/APITests.cpp b/test/AccessControlTests/APITests.cpp index 53c80e5aa7..4dc8926420 100644 --- a/test/AccessControlTests/APITests.cpp +++ b/test/AccessControlTests/APITests.cpp @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation and Contributors. +// Copyright (c) Microsoft Corporation and Contributors. // Licensed under the MIT License. #include "pch.h" @@ -17,6 +17,8 @@ namespace winrt using namespace Microsoft::Windows::Security::AccessControl; } +namespace TB = ::Test::Bootstrap; +namespace TP = ::Test::Packages; namespace Test::AccessControl { @@ -32,7 +34,7 @@ namespace Test::AccessControl static PCWSTR GetTestPackageFullName() { - return L"AccessControlTestPackage_1.0.0.0_" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE "8wekyb3d8bbwe"; + return L"AccessControlTestAppPackage_1.0.0.0_" MSIX_PACKAGE_ARCHITECTURE "__8wekyb3d8bbwe"; } static PCWSTR GetTestPackageFamilyName() @@ -58,21 +60,16 @@ namespace Test::AccessControl 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_PROPERTY(L"RunAs", 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; - } + ::TP::RemovePackageIfNecessary(GetTestPackageFullName()); + ::TB::CleanupPackages(); + + ::TB::Setup(); + ::TP::WapProj::AddPackage(TAEF::GetDeploymentDir(), GetTestPackageFile(), L".msix"); m_testAppLauncher = winrt::create_instance(CLSID_ApplicationActivationManager, CLSCTX_ALL); return true; @@ -80,24 +77,18 @@ namespace Test::AccessControl 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, 0u); - } - // Remove in reverse order to avoid conflicts between inter-dependent packages. - ::Test::Packages::RemovePackage(GetTestPackageFamilyName()); - ::Test::Bootstrap::Cleanup(); - } - catch (...) + if (m_processHandle.is_valid()) { - return false; + 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, 0u); } + + // Remove in reverse order to avoid conflicts between inter-dependent packages. + ::TP::RemovePackage(GetTestPackageFullName()); + ::TB::Cleanup(); return true; } diff --git a/test/AppLifecycle/packages.config b/test/AppLifecycle/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/AppLifecycle/packages.config +++ b/test/AppLifecycle/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/AppNotificationBuilderTests/packages.config b/test/AppNotificationBuilderTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/AppNotificationBuilderTests/packages.config +++ b/test/AppNotificationBuilderTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/AppNotificationTests/packages.config b/test/AppNotificationTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/AppNotificationTests/packages.config +++ b/test/AppNotificationTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/Common/packages.config b/test/Common/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/Common/packages.config +++ b/test/Common/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/Deployment/API/packages.config b/test/Deployment/API/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/Deployment/API/packages.config +++ b/test/Deployment/API/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Default/packages.config b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Default/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Default/packages.config +++ b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Default/packages.config @@ -1,5 +1,5 @@  - + diff --git a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Default/packages.config b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Default/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Default/packages.config +++ b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Default/packages.config @@ -1,5 +1,5 @@  - + diff --git a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Defined/packages.config b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Defined/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Defined/packages.config +++ b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_Defined/packages.config @@ -1,5 +1,5 @@  - + diff --git a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_None/packages.config b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_None/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_None/packages.config +++ b/test/Deployment/Test_DeploymentManagerAutoInitialize/CPP/Test_DeploymentManagerAutoInitialize_CPP_Options_None/packages.config @@ -1,5 +1,5 @@  - + diff --git a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Default/packages.config b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Default/packages.config index 3d9798ef5e..20783ec656 100644 --- a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Default/packages.config +++ b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Default/packages.config @@ -1,4 +1,4 @@  - - \ No newline at end of file + + diff --git a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Default/packages.config b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Default/packages.config index 3d9798ef5e..20783ec656 100644 --- a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Default/packages.config +++ b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Default/packages.config @@ -1,4 +1,4 @@  - - \ No newline at end of file + + diff --git a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Defined/packages.config b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Defined/packages.config index 3d9798ef5e..20783ec656 100644 --- a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Defined/packages.config +++ b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_Defined/packages.config @@ -1,4 +1,4 @@  - - \ No newline at end of file + + diff --git a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_None/packages.config b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_None/packages.config index 3d9798ef5e..20783ec656 100644 --- a/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_None/packages.config +++ b/test/DynamicDependency/Test_BootstrapAutoInitialize/CPP/Test_BootstrapAutoInitialize_CPP_Options_None/packages.config @@ -1,4 +1,4 @@  - - \ No newline at end of file + + diff --git a/test/DynamicDependency/Test_Win32/Test_Win32.cpp b/test/DynamicDependency/Test_Win32/Test_Win32.cpp index f3a63da257..33317c36d3 100644 --- a/test/DynamicDependency/Test_Win32/Test_Win32.cpp +++ b/test/DynamicDependency/Test_Win32/Test_Win32.cpp @@ -19,7 +19,7 @@ wil::unique_hmodule Test::DynamicDependency::Test_Win32::m_bootstrapDll; bool Test::DynamicDependency::Test_Win32::Setup() { - if (/*TODO ::WindowsVersion::IsWindows11_23H1OrGreater() &&*/ !::Test::TAEF::IsEnabled(L"DynamicDependency.23H1")) + if (!::Test::TAEF::IsEnabled(L"Bug.48525090.Skip", true)) { WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Skipping tests to avoid https://task.ms/48525090"); return true; @@ -423,7 +423,7 @@ int Test::DynamicDependency::Test_Win32::FindPackageFullNameInPackageInfoArray( { if (CompareStringOrdinal(packageFullName.c_str(), -1, packageInfo->packageFullName, -1, TRUE) == CSTR_EQUAL) { - return true; + return index; } } return -1; diff --git a/test/DynamicDependency/Test_Win32/pch.h b/test/DynamicDependency/Test_Win32/pch.h index d234fcbbc9..285aed1342 100644 --- a/test/DynamicDependency/Test_Win32/pch.h +++ b/test/DynamicDependency/Test_Win32/pch.h @@ -18,6 +18,7 @@ #include #include #include +#include #include #include diff --git a/test/DynamicDependency/Test_WinRT/Test_WinRT.cpp b/test/DynamicDependency/Test_WinRT/Test_WinRT.cpp index 7d3cf6c2fb..149aa71b56 100644 --- a/test/DynamicDependency/Test_WinRT/Test_WinRT.cpp +++ b/test/DynamicDependency/Test_WinRT/Test_WinRT.cpp @@ -21,7 +21,7 @@ wil::unique_hmodule Test::DynamicDependency::Test_WinRT::m_bootstrapDll; bool Test::DynamicDependency::Test_WinRT::Setup() { - if (/*TODO ::WindowsVersion::IsWindows11_23H1OrGreater() &&*/ !::Test::TAEF::IsEnabled(L"DynamicDependency.23H1")) + if (!::Test::TAEF::IsEnabled(L"Bug.48525090.Skip", true)) { WEX::Logging::Log::Result(WEX::Logging::TestResults::Skipped, L"Skipping tests to avoid https://task.ms/48525090"); return true; diff --git a/test/DynamicDependency/Test_WinRT/pch.h b/test/DynamicDependency/Test_WinRT/pch.h index fbd1232817..aea9d4e41f 100644 --- a/test/DynamicDependency/Test_WinRT/pch.h +++ b/test/DynamicDependency/Test_WinRT/pch.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include diff --git a/test/DynamicDependency/data/Framework.Widgets/packages.config b/test/DynamicDependency/data/Framework.Widgets/packages.config index 9ba3aa91dd..7aa0bd4402 100644 --- a/test/DynamicDependency/data/Framework.Widgets/packages.config +++ b/test/DynamicDependency/data/Framework.Widgets/packages.config @@ -1,5 +1,5 @@  - + diff --git a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/Microsoft.WindowsAppRuntime.Framework.vcxproj b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/Microsoft.WindowsAppRuntime.Framework.vcxproj index bb88b8070e..c595080891 100644 --- a/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/Microsoft.WindowsAppRuntime.Framework.vcxproj +++ b/test/DynamicDependency/data/Microsoft.WindowsAppRuntime.Framework/Microsoft.WindowsAppRuntime.Framework.vcxproj @@ -91,6 +91,7 @@ + diff --git a/test/EnvironmentManagerTests/packages.config b/test/EnvironmentManagerTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/EnvironmentManagerTests/packages.config +++ b/test/EnvironmentManagerTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/Kozani/KozaniAppGraphTests/packages.config b/test/Kozani/KozaniAppGraphTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniAppGraphTests/packages.config +++ b/test/Kozani/KozaniAppGraphTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniHostRuntimeTests/packages.config b/test/Kozani/KozaniHostRuntimeTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniHostRuntimeTests/packages.config +++ b/test/Kozani/KozaniHostRuntimeTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniManagerRuntimeTests/packages.config b/test/Kozani/KozaniManagerRuntimeTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniManagerRuntimeTests/packages.config +++ b/test/Kozani/KozaniManagerRuntimeTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniManagerTests/packages.config b/test/Kozani/KozaniManagerTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniManagerTests/packages.config +++ b/test/Kozani/KozaniManagerTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniPackageTests/packages.config b/test/Kozani/KozaniPackageTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniPackageTests/packages.config +++ b/test/Kozani/KozaniPackageTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniRemoteManagerTests/packages.config b/test/Kozani/KozaniRemoteManagerTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniRemoteManagerTests/packages.config +++ b/test/Kozani/KozaniRemoteManagerTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniSendToLocalTests/packages.config b/test/Kozani/KozaniSendToLocalTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniSendToLocalTests/packages.config +++ b/test/Kozani/KozaniSendToLocalTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniSendToRemoteTests/packages.config b/test/Kozani/KozaniSendToRemoteTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniSendToRemoteTests/packages.config +++ b/test/Kozani/KozaniSendToRemoteTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/KozaniSettingsTests/packages.config b/test/Kozani/KozaniSettingsTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/KozaniSettingsTests/packages.config +++ b/test/Kozani/KozaniSettingsTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/Kozani/MakeMSIXTests/packages.config b/test/Kozani/MakeMSIXTests/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/Kozani/MakeMSIXTests/packages.config +++ b/test/Kozani/MakeMSIXTests/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/LRPTests/packages.config b/test/LRPTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/LRPTests/packages.config +++ b/test/LRPTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/PackageManager/API/packages.config b/test/PackageManager/API/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/test/PackageManager/API/packages.config +++ b/test/PackageManager/API/packages.config @@ -5,5 +5,5 @@ - + diff --git a/test/PackageManager/API/pch.h b/test/PackageManager/API/pch.h index 9ae9d75ea8..fe35853e72 100644 --- a/test/PackageManager/API/pch.h +++ b/test/PackageManager/API/pch.h @@ -7,6 +7,7 @@ #include #include +#include #include #include diff --git a/test/PowerNotifications/packages.config b/test/PowerNotifications/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/PowerNotifications/packages.config +++ b/test/PowerNotifications/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/PushNotificationTests/packages.config b/test/PushNotificationTests/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/PushNotificationTests/packages.config +++ b/test/PushNotificationTests/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/AccessControlTestApp/packages.config b/test/TestApps/AccessControlTestApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/AccessControlTestApp/packages.config +++ b/test/TestApps/AccessControlTestApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/AppLifecycleTestApp/packages.config b/test/TestApps/AppLifecycleTestApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/AppLifecycleTestApp/packages.config +++ b/test/TestApps/AppLifecycleTestApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/ManualTestApp/packages.config b/test/TestApps/ManualTestApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/ManualTestApp/packages.config +++ b/test/TestApps/ManualTestApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/PushNotificationsDemoApp/packages.config b/test/TestApps/PushNotificationsDemoApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/PushNotificationsDemoApp/packages.config +++ b/test/TestApps/PushNotificationsDemoApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/PushNotificationsTestApp/packages.config b/test/TestApps/PushNotificationsTestApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/PushNotificationsTestApp/packages.config +++ b/test/TestApps/PushNotificationsTestApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/ToastNotificationsDemoApp/packages.config b/test/TestApps/ToastNotificationsDemoApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/ToastNotificationsDemoApp/packages.config +++ b/test/TestApps/ToastNotificationsDemoApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/TestApps/ToastNotificationsTestApp/packages.config b/test/TestApps/ToastNotificationsTestApp/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/TestApps/ToastNotificationsTestApp/packages.config +++ b/test/TestApps/ToastNotificationsTestApp/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj new file mode 100644 index 0000000000..a1ba9002ac --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj @@ -0,0 +1,170 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + 16.0 + {14560FF9-B7AC-45b5-A120-2B49380B0D0D} + Win32Proj + URFW_ExeUsingWinAppSDK + 10.0 + NativeUnitTestProject + URFW_ExeUsingWinAppSDK + + + Application + false + v143 + Unicode + + + true + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + Use + true + pch.h + $(RepoRoot)\test\inc;$(RepoRoot)\dev\common;$(VCInstallDir)UnitTest\include;$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories) + $(RepoRoot);%(AdditionalIncludeDirectories) + _CONSOLE;%(PreprocessorDefinitions) + + + Console + onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + + + + + _DEBUG;%(PreprocessorDefinitions) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + + + WIN32;%(PreprocessorDefinitions) + + + + + Create + + + + + + + + + + + + + {f76b776e-86f5-48c5-8fc7-d2795ecc9746} + + + + + + + + + + + + + + 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}. + + + + + + + + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj.filters b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj.filters new file mode 100644 index 0000000000..755522d805 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/URFW_ExeUsingWinAppSDK.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/main.cpp b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/main.cpp new file mode 100644 index 0000000000..759e20a038 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/main.cpp @@ -0,0 +1,451 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" + +#ifdef MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE +#pragma message("MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is defined") +constexpr bool c_buildIsBootstrapAutoInitialize{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is NOT defined") +constexpr bool c_buildIsBootstrapAutoInitialize{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED +#pragma message("MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is defined") +constexpr bool c_buildIsSelfContained{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is NOT defined") +constexpr bool c_buildIsSelfContained{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitialize{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is NOT defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitialize{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is NOT defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary{}; +#endif + +#include + +#include +#include +#include +#include + +namespace TB = ::Test::Bootstrap; +namespace TF = ::Test::FileSystem; + +wil::unique_hmodule Setup(); +void Dump(); +HRESULT VerifyRoActivateInstance(); +HRESULT VerifyRoGetActivationFactory(); +HRESULT Test_Activation(); +HRESULT Test_Metadata(); +bool IsTaefLoggingEnabled(); +HRESULT TaefInitializeLogging(const std::wstring& taefConnectionData); +void TaefLog(PCWSTR message); +void LogError(PCWSTR message); +void LogComment(PCWSTR message); +int Help(); +HRESULT ParseCommandLine(int argc, wchar_t* argv[], std::wstring& taefConnectionData, bool& testActivation, bool& testMetadata); + +// Setup our logging to route through our calling TAEF test's log +// See https://www.osgwiki.com/wiki/WexLogger#Remote_Logging_From_Child_Processes +// or https://docs.microsoft.com/en-us/windows-hardware/drivers/taef/wexlogger#remote-logging-from-child-processes +std::wstring g_taefConnectionData{}; + +wil::unique_hmodule Setup() +{ + Dump(); + +#if !defined(MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED) + LogComment(WEX::Common::String().Format(L"::TB::SetupBootstrap()...")); + ::TB::SetupBootstrap(); + LogComment(WEX::Common::String().Format(L"::TB::SetupBootstrap(): Done")); +#endif + + const auto dllFilename{ L"Microsoft.WindowsAppRuntime.dll" }; + wil::unique_hmodule dll{ LoadLibraryExW(dllFilename, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH) }; + const auto lastError{ GetLastError() }; + LogComment(WEX::Common::String().Format(L"LoadLibraryEx('%s'): %p LastError:0x%X", dllFilename, dll.get(), lastError)); + THROW_HR_IF_NULL(HRESULT_FROM_WIN32(lastError), dll); + auto moduleFileName{ wil::GetModuleFileNameW(dll.get()) }; + LogComment(WEX::Common::String().Format(L"ModuleFileName: %s", moduleFileName.get())); + return dll; +} + +void Dump() +{ + LogComment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is%s defined\n", c_buildIsBootstrapAutoInitialize ? L"" : L" NOT")); + LogComment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is%s defined\n", c_buildIsSelfContained ? L"" : L" NOT")); + LogComment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is%s defined\n", c_buildIsUndockedRegFreeWinRTAutoInitialize ? L"" : L" NOT")); + LogComment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is%s defined\n", c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary ? L"" : L" NOT")); + + auto pathEnvironmentVariable{ wil::TryGetEnvironmentVariableW(L"PATH") }; + auto pathEnvironmentVariableString{ !pathEnvironmentVariable ? L"" : pathEnvironmentVariable.get() }; + LogComment(WEX::Common::String().Format(L"PATH: %s\n", pathEnvironmentVariableString)); + + wchar_t currentDirectory[1024]{}; + auto currentDirectoryLength{ GetCurrentDirectoryW(ARRAYSIZE(currentDirectory), currentDirectory) }; + THROW_LAST_ERROR_IF(currentDirectoryLength == 0); + THROW_HR_IF(HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER), currentDirectoryLength > ARRAYSIZE(currentDirectory)); + LogComment(WEX::Common::String().Format(L"CurrentDirectory: %s", currentDirectory)); + + auto exeFileName{ wil::GetModuleFileNameW() }; + LogComment(WEX::Common::String().Format(L"ExeFileName: %s", exeFileName.get())); +} + +HRESULT VerifyRoActivateInstance() try +{ + LogComment(L"Verify:RoActivateInstance..."); + + // Keep in sync with app.manifest + PCWSTR acids[]{ + L"Microsoft.Windows.ApplicationModel.DynamicDependency.AddPackageDependencyOptions", + L"Microsoft.Windows.Management.Deployment.PackageSet" + }; + for (auto acid : acids) + { + LogComment(WEX::Common::String().Format(L"ACID: %s", acid)); + auto hacid{ wil::make_unique_string(acid) }; + wil::com_ptr_nothrow inspectable; + const auto hr{ RoActivateInstance(hacid.get(), &inspectable) }; + LogComment(WEX::Common::String().Format(L" HRESULT: 0x%X Ptr: %p RoActivateInstance: %s", hr, inspectable.get(), acid)); + RETURN_IF_FAILED_MSG(hr, "RoActivateInstance: %ls", acid); + } + + LogComment(L"Verify:RoActivateInstance...OK!"); + return S_OK; +} +CATCH_RETURN() + +HRESULT VerifyRoGetActivationFactory() try +{ + LogComment(L"Verify:RoGetAtivationFactory..."); + + PCWSTR factoryAcids[]{ + L"Microsoft.Windows.ApplicationModel.DynamicDependency.PackageDependency", + L"Microsoft.Windows.Management.Deployment.PackageDeploymentManager" + }; + for (auto acid : factoryAcids) + { + LogComment(WEX::Common::String().Format(L"ACID: %s", acid)); + auto hacid{ wil::make_unique_string(acid) }; + wil::com_ptr_nothrow inspectable; + const auto hr{ RoGetActivationFactory(hacid.get(), __uuidof(inspectable), (void**)&inspectable) }; + LogComment(WEX::Common::String().Format(L" HRESULT: 0x%X Ptr: %p RoGetActivationFactory: %s", hr, inspectable.get(), acid)); + RETURN_IF_FAILED_MSG(hr, "RoGetActivationFactory: %ls", acid); + } + + LogComment(L"Verify:RoGetAtivationFactory...OK!"); + return S_OK; +} +CATCH_RETURN() + +HRESULT Test_Activation() try +{ + LogComment(L"Test_Activation..."); + RETURN_IF_FAILED(VerifyRoActivateInstance()); + RETURN_IF_FAILED(VerifyRoGetActivationFactory()); + LogComment(L"Test_Activation...OK!"); + return S_OK; +} +CATCH_RETURN() + +HRESULT VerifyApiInformationIsContractPresent() try +{ + LogComment(L"Verify:ApiInformation.IsContractPresent..."); + + struct Contracts + { + PCWSTR name; + uint16_t majorVersion; + } contracts[]{ + { L"Windows.Foundation.UniversalApiContract", 1 }, + { L"Microsoft.Windows.ApplicationModel.DynamicDependency.DynamicDependencyContract", 1 }, + { L"Microsoft.Windows.AppLifecycle.AppLifecycleContract", 1 }, + { L"Microsoft.Windows.AppLifecycle.AppLifecycleContract", 2 }, + { L"Microsoft.Windows.Management.Deployment.PackageDeploymentContract", 1 } + }; + for (auto contract : contracts) + { + LogComment(WEX::Common::String().Format(L"Contract: %s v%hu", contract.name, contract.majorVersion)); + const winrt::hstring contractName{ contract.name }; + boolean found{}; + HRESULT hr{}; + try + { +#if 1 + BOOL present{}; + hr = LOG_IF_FAILED(::RoIsApiContractMajorVersionPresent(contract.name, contract.majorVersion, &present)); + found = !!present; +#else + found = winrt::Windows::Foundation::Metadata::ApiInformation::IsApiContractPresent(contractName, contract.majorVersion); +#endif + if (found) + { + LogComment(WEX::Common::String().Format(L" HRESULT: 0x%X Found IsContractPresent: %s v%hu", hr, contract.name, contract.majorVersion)); + } + else + { + LogError(WEX::Common::String().Format(L" HRESULT: 0x%X **NOT-FOUND** IsContractPresent: %s v%hu", hr, contract.name, contract.majorVersion)); + } + } + catch (winrt::hresult_error& e) + { + hr = e.code(); + LogError(WEX::Common::String().Format(L" HRESULT: 0x%X IsContractPresent: %s v%hu", hr, contract.name, contract.majorVersion)); + } + RETURN_IF_FAILED_MSG(hr, "ApiInformation.IsContractPresent: %ls v%hu", contract.name, contract.majorVersion); + RETURN_HR_IF_MSG(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), !found, "ApiInformation.IsContractPresent: %ls v%hu", contract.name, contract.majorVersion); + } + + LogComment(L"Verify:ApiInformation.IsContractPresent...OK!"); + return S_OK; +} +CATCH_RETURN() + +HRESULT VerifyApiInformationIsTypePresent() try +{ + LogComment(L"Verify:ApiInformation.IsTypePresent..."); + + PCWSTR types[]{ + L"Microsoft.Windows.ApplicationModel.DynamicDependency.AddPackageDependencyOptions", + L"Microsoft.Windows.System.EnvironmentManager", + L"Microsoft.Windows.Management.Deployment.PackageDeploymentManager" + }; + for (auto type : types) + { + LogComment(WEX::Common::String().Format(L"Type: %s", type)); + const winrt::hstring htype{ type }; + boolean found{}; + HRESULT hr{}; + try + { + found = winrt::Windows::Foundation::Metadata::ApiInformation::IsTypePresent(htype); + if (found) + { + LogComment(WEX::Common::String().Format(L" HRESULT: 0x%X Found IsTypePresent: %s", hr, type)); + } + else + { + LogError(WEX::Common::String().Format(L" HRESULT: 0x%X **NOT-FOUND** IsTypePresent: %s", hr, type)); + } + } + catch (winrt::hresult_error& e) + { + hr = e.code(); + LogError(WEX::Common::String().Format(L" HRESULT: 0x%X IsTypePresent: %s", hr, type)); + } + RETURN_IF_FAILED_MSG(hr, "ApiInformation.IsTypePresent: %ls", type); + RETURN_HR_IF_MSG(HRESULT_FROM_WIN32(ERROR_NOT_FOUND), !found, "ApiInformation.IsTypePresent: %ls", type); + } + + LogComment(L"Verify:ApiInformation.IsTypePresent...OK!"); + return S_OK; +} +CATCH_RETURN() + +HRESULT Test_Metadata() try +{ + LogComment(L"Test_Metadata..."); + RETURN_IF_FAILED(VerifyApiInformationIsContractPresent()); + RETURN_IF_FAILED(VerifyApiInformationIsTypePresent()); + LogComment(L"Test_Metadata...OK!"); + return S_OK; +} +CATCH_RETURN() + +bool IsTaefLoggingEnabled() +{ + return !g_taefConnectionData.empty(); +} + +HRESULT TaefInitializeLogging(const std::wstring& taefConnectionData) +{ + wprintf(L"TAEFConnectionData: %s\n", taefConnectionData.c_str()); + if (taefConnectionData.empty()) + { + return S_OK; + } + + auto taefEnvironmentVariableCommand{ WEX::Common::String(WEX::Logging::c_szWexLoggerRemoteConnectionData).Append(taefConnectionData.c_str()) }; + PCWSTR c_environmentVariable{ L"urfw_exeusingwinappsdk_cmd" }; + wprintf(L"Setting environment variable %s=%s\n", c_environmentVariable, static_cast(taefEnvironmentVariableCommand)); + RETURN_IF_WIN32_BOOL_FALSE(::SetEnvironmentVariableW(c_environmentVariable, taefEnvironmentVariableCommand)); + + g_taefConnectionData = taefConnectionData; + RETURN_IF_FAILED(WEX::Logging::LogController::InitializeLogging(g_taefConnectionData.c_str())); + return S_OK; +} + +void TaefLog(PCWSTR message) +{ + if (IsTaefLoggingEnabled()) + { + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"URFW_EXE: %s", message)); + } +} + +void LogError(PCWSTR message) +{ + std::fputws(WEX::Common::String().Format(L"%s\n", message), stdout); + TaefLog(message); +} + +void LogComment(PCWSTR message) +{ + std::fputws(WEX::Common::String().Format(L"%s\n", message), stdout); + TaefLog(message); +} + +int Help() +{ + wprintf(L"Usage: URFW_ExeUsingWinAppSDK.exe [options] [test [test...]]\n" + L"options:\n" + L" --help, -? ==> Display help\n" + L" --taef:connectiondata= ==> TAEF connection data for remote logging\n" + L" -- ==> End options\n" + L"test (omit to run all):\n" + L" Activation\n" + L" Metadata\n"); + ExitProcess(1); +} + +HRESULT ParseCommandLine(int argc, wchar_t* argv[], std::wstring& taefConnectionData, bool& testActivation, bool& testMetadata) +{ + int argn = 1; + std::wstring arg; + for (; argn < argc; ++argn) + { + arg = argv[argn]; + if (arg[0] != L'-') + { + break; + } + if (arg == L"--") + { + ++argn; + break; + } + else if ((arg == L"--help") || (arg == L"-?")) + { + Help(); + } + else if (arg.rfind(L"--taef:connectiondata=", 0) == 0) + { + const auto c_taefConnectionDataLength{ ARRAYSIZE(L"--taef:connectiondata=") - 1 }; + taefConnectionData = arg.substr(c_taefConnectionDataLength); + + // We expect valid TAEF connection data e.g. "{LogManagerGuid=4E46F9E4-B8A3-4258-B5DF-20A959332795,LogSessionId=1}" + if (taefConnectionData.empty() || (taefConnectionData[0] != L'{')) + { + wprintf(L"ERROR: Invalid parameter argv[%d]: %s, aborting...\n", argn, arg.c_str()); + ExitProcess(LOG_HR_MSG(E_INVALIDARG, "argv[%d]: %s", argn, arg.c_str())); + } + } + else + { + wprintf(L"ERROR: Invalid parameter argv[%d]: %s, aborting...\n", argn, arg.c_str()); + ExitProcess(LOG_HR_MSG(E_INVALIDARG, "argv[%d]: %s", argn, arg.c_str())); + } + } + + if (argn >= argc) + { + testActivation = true; + testMetadata = true; + } + else + { + for (; argn < argc; ++argn) + { + PCWSTR argp{ argv[argn] }; + if (CompareStringOrdinal(argp, -1, L"Activation", -1, TRUE) == CSTR_EQUAL) + { + testActivation = true; + } + else if (CompareStringOrdinal(argp, -1, L"Metadata", -1, TRUE) == CSTR_EQUAL) + { + testMetadata = true; + } + else + { + wprintf(L"ERROR: Invalid parameter argv[%d]: %s, aborting...\n", argn, argp); + ExitProcess(LOG_HR_MSG(E_INVALIDARG, "argv[%d]: %s", argn, argp)); + } + } + } + return S_OK; +} + +int wmain(int argc, wchar_t *argv[]) try +{ + PCWSTR commandLine{ ::GetCommandLineW() }; + wprintf(L"CommandLine: %s\n", (!commandLine ? L"" : commandLine)); + for (int argn = 0; argn < argc; ++argn) + { + wprintf(L"argv[%d]: %s\n", argn, argv[argn]); + } + + WCHAR envvalue[1024]{}; + ::GetEnvironmentVariableW(L"urfw_exeusingwinappsdk_cmd", envvalue, ARRAYSIZE(envvalue)); + wprintf(L"env: %s\n", envvalue); + + wil::SetResultLoggingCallback([](wil::FailureInfo const& failure) noexcept + { + constexpr std::size_t sizeOfLogMessageWithNul{ 2048 }; + wchar_t logMessage[sizeOfLogMessageWithNul]{}; + if (SUCCEEDED(wil::GetFailureLogString(logMessage, sizeOfLogMessageWithNul, failure))) + { + LogError(logMessage); + } + }); + + auto roinit{ wil::RoInitialize() }; + + std::wstring taefConnectionData; + bool testActivation{}; + bool testMetadata{}; + RETURN_IF_FAILED(ParseCommandLine(argc, argv, taefConnectionData, testActivation, testMetadata)); + + RETURN_IF_FAILED(TaefInitializeLogging(taefConnectionData)); + auto taefFinalizeLogging = wil::scope_exit([&] + { + if (IsTaefLoggingEnabled()) + { + (void)LOG_IF_FAILED(WEX::Logging::LogController::FinalizeLogging()); + } + }); + + auto dll{ Setup() }; + + if (testActivation) + { + RETURN_IF_FAILED(Test_Activation()); + } + if (testMetadata) + { + RETURN_IF_FAILED(Test_Metadata()); + } + +#if !defined(MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED) + LogComment(WEX::Common::String().Format(L"::TB::CleanupBootstrap()...")); + ::TB::CleanupBootstrap(); + LogComment(WEX::Common::String().Format(L"::TB::SetupBootstrap(): Done")); +#endif + + LogComment(WEX::Common::String().Format(L"Success!")); + return 0; +} +CATCH_RETURN() diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/packages.config b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/packages.config new file mode 100644 index 0000000000..9b993e39b0 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.cpp b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.cpp new file mode 100644 index 0000000000..9d52d14340 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.cpp @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" diff --git a/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.h b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.h new file mode 100644 index 0000000000..a5bf6cba1f --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_ExeUsingWinAppSDK/pch.h @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#ifndef PCH_H +#define PCH_H + +#include + +#include + +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include +#include + +#include +#include + +#endif //PCH_H diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/Test.testdef b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/Test.testdef new file mode 100644 index 0000000000..0bfbf52f6b --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/Test.testdef @@ -0,0 +1,11 @@ +{ + "Tests": [ + { + "Description": "UndockedRegFreeWinRT (URFW) tests (arm64 not currently enabled)", + "Filename": "URFW_WinAppSDK.dll", + "Parameters": "", + "Architectures": ["x86", "x64"], + "Status": "Enabled" + } + ] +} diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_Test.cpp b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_Test.cpp new file mode 100644 index 0000000000..a381c1348b --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_Test.cpp @@ -0,0 +1,151 @@ +// 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 + +namespace TB = ::Test::Bootstrap; + +#ifdef MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE +#pragma message("MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is defined") +constexpr bool c_buildIsBootstrapAutoInitialize{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is NOT defined") +constexpr bool c_buildIsBootstrapAutoInitialize{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED +#pragma message("MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is defined") +constexpr bool c_buildIsSelfContained{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is NOT defined") +constexpr bool c_buildIsSelfContained{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitialize{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is NOT defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitialize{}; +#endif + +#ifdef MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary{ true }; +#else +#pragma message("MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is NOT defined") +constexpr bool c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary{}; +#endif + +namespace Test::UndockedRegFreeWinRT +{ + class WinAppSDKIsSelfContained + { + public: + BEGIN_TEST_CLASS(WinAppSDKIsSelfContained) + TEST_CLASS_PROPERTY(L"ThreadingModel", L"MTA") + TEST_CLASS_PROPERTY(L"RunAs", L"RestrictedUser") + END_TEST_CLASS() + + TEST_CLASS_SETUP(ClassSetup) + { + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_BOOTSTRAP_AUTO_INITIALIZE is%s defined\n", c_buildIsBootstrapAutoInitialize ? L"" : L" NOT")); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_SELFCONTAINED is%s defined\n", c_buildIsSelfContained ? L"" : L" NOT")); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE is%s defined\n", c_buildIsUndockedRegFreeWinRTAutoInitialize ? L"" : L" NOT")); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"MICROSOFT_WINDOWSAPPSDK_UNDOCKEDREGFREEWINRT_AUTO_INITIALIZE_LOADLIBRARY is%s defined\n", c_buildIsUndockedRegFreeWinRTAutoInitializeLoadLibrary ? L"" : L" NOT")); + + ::TB::SetupPackages(); + return true; + } + + TEST_CLASS_CLEANUP(ClassCleanup) + { + ::TB::CleanupPackages(); + return true; + } + + TEST_METHOD(Activation) + { + // Setup logging so the child process can log its results through our TAEF log + // See https://www.osgwiki.com/wiki/WexLogger#Remote_Logging_From_Child_Processes + // or https://docs.microsoft.com/en-us/windows-hardware/drivers/taef/wexlogger#remote-logging-from-child-processes + WEX::Common::NoThrowString taefConnectionData; + VERIFY_SUCCEEDED(WEX::Logging::RemoteLogController::GenerateConnectionData(taefConnectionData)); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"RemoteLogController:ConnectionData: %s", static_cast(taefConnectionData))); + + auto executable{ GetTargetExecutable() }; + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"TargetExecutable %s", executable.c_str())); + + // NOTE: CreateProcess("foo.exe", "bar") and CreateProcess(NULL, "foo.exe bar") produce very different child behavior + // + // CreateProcess("foo.exe", "bar") and in child process... + // GetCommandLine(): "bar" + // main argc: 1 + // main argv[0]: "bar" + // main argv[1]: N/A + // + // CreateProcess(NULL, "foo.exe bar") and in child process... + // GetCommandLine(): "foo.exe bar" + // main argc: 2 + // main argv[0]: "foo.exe" + // main argv[1]: "bar" + // To ensure expected behavior we'll do the latter. + + const auto cmdLine{ std::wstring(executable) + L" --taef:connectiondata=" + static_cast(taefConnectionData) }; + PWSTR commandLine{ const_cast(cmdLine.c_str()) }; + STARTUPINFOW startupInfo{ sizeof(startupInfo) }; + wil::unique_process_information processInformation; + WEX::Logging::Log::Comment(L"Creating test process..."); + VERIFY_WIN32_BOOL_SUCCEEDED(CreateProcessW(nullptr, commandLine, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &startupInfo, &processInformation), + WEX::Common::String().Format(L"Executable: %s", executable.c_str())); + + VERIFY_SUCCEEDED(WEX::Logging::RemoteLogController::InitializeLogging(taefConnectionData)); + + const auto rc{ WaitForSingleObject(processInformation.hProcess, INFINITE) }; + VERIFY_ARE_EQUAL(WAIT_OBJECT_0, rc); + DWORD exitCode{}; + VERIFY_WIN32_BOOL_SUCCEEDED(GetExitCodeProcess(processInformation.hProcess, &exitCode)); + VERIFY_ARE_EQUAL(0u, exitCode, WEX::Common::String().Format(L"ExitCode: 0x%X", exitCode)); + } + + private: + std::filesystem::path GetTargetExecutable() const + { + const auto dllFilename{ L"URFW_WinAppSDK.dll" }; + const auto dllPath{ GetModulePath(dllFilename) }; + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"DllPath(%s): %s", dllFilename, dllPath.c_str())); + + auto target{ dllPath.parent_path() / L"URFW_ExeUsingWinAppSDK\\URFW_ExeUsingWinAppSDK.exe" }; + return target; + } + + std::filesystem::path GetModulePath(PCWSTR dllFilename) const + { + if (!dllFilename) + { + return GetExePath(); + } + + wil::unique_hmodule dll{ LoadLibraryExW(dllFilename, nullptr, LOAD_WITH_ALTERED_SEARCH_PATH) }; + VERIFY_IS_NOT_NULL(dll, WEX::Common::String().Format(L"LoadLibraryEx('%s'): %p", dllFilename, dll.get())); + auto moduleFileName{ wil::GetModuleFileNameW(dll.get()) }; + VERIFY_IS_NOT_NULL(moduleFileName, WEX::Common::String().Format(L"ModuleFileName: %s", moduleFileName.get())); + return std::filesystem::path{ moduleFileName.get() }.parent_path(); + } + + std::filesystem::path GetExePath() const + { + const auto exeFileName{ GetExecutable() }; + return exeFileName.parent_path(); + } + + std::filesystem::path GetExecutable() const + { + std::filesystem::path exeFileName{ wil::GetModuleFileNameW().get() }; + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"ExeFileName: %s", exeFileName.c_str())); + return exeFileName; + } + }; +} diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj new file mode 100644 index 0000000000..653bb53d07 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj @@ -0,0 +1,172 @@ + + + + + + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + Debug + ARM64 + + + Release + ARM64 + + + + 16.0 + {E0BD4D47-AA5C-4354-961D-032E2AB612E1} + Win32Proj + URFW_WinAppSDK + 10.0 + NativeUnitTestProject + URFW_WinAppSDK + + + DynamicLibrary + false + v143 + Unicode + + + true + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + Use + true + pch.h + $(RepoRoot)\test\inc;$(RepoRoot)\dev\common;$(VCInstallDir)UnitTest\include;$(OutDir)\..\WindowsAppRuntime_DLL;$(OutDir)\..\WindowsAppRuntime_BootstrapDLL;%(AdditionalIncludeDirectories) + $(RepoRoot);%(AdditionalIncludeDirectories) + + + Windows + onecore.lib;onecoreuap.lib;Microsoft.WindowsAppRuntime.lib;wex.common.lib;wex.logger.lib;te.common.lib;%(AdditionalDependencies) + $(VCInstallDir)UnitTest\lib;%(AdditionalLibraryDirectories);$(OutDir)\..\WindowsAppRuntime_DLL + Microsoft.WindowsAppRuntime.Bootstrap.dll;%(DelayLoadDLLs) + + + + + _DEBUG;%(PreprocessorDefinitions) + + + + + NDEBUG;%(PreprocessorDefinitions) + + + + + WIN32;%(PreprocessorDefinitions) + + + + + Create + + + + + + + + + + + + + + + + {f76b776e-86f5-48c5-8fc7-d2795ecc9746} + + + + + + + + + + + + + + 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}. + + + + + + + + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj.filters b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj.filters new file mode 100644 index 0000000000..c4eb84e491 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/URFW_WinAppSDK.vcxproj.filters @@ -0,0 +1,33 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Source Files + + + Source Files + + + + + Header Files + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/packages.config b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/packages.config new file mode 100644 index 0000000000..9b993e39b0 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.cpp b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.cpp new file mode 100644 index 0000000000..9d52d14340 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.cpp @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include "pch.h" diff --git a/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.h b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.h new file mode 100644 index 0000000000..09d74a3ae1 --- /dev/null +++ b/test/UndockedRegFreeWinRT/URFW_WinAppSDK/pch.h @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#ifndef PCH_H +#define PCH_H + +#include + +#include + +#include +#include +#include + +#include + +#include +#include + +#include +#include + +#include + +#endif //PCH_H diff --git a/test/VersionInfo/packages.config b/test/VersionInfo/packages.config index 1117ac430f..5472ccf598 100644 --- a/test/VersionInfo/packages.config +++ b/test/VersionInfo/packages.config @@ -2,5 +2,5 @@ - + diff --git a/test/inc/WindowsAppRuntime.Test.Diagnostics.h b/test/inc/WindowsAppRuntime.Test.Diagnostics.h index d9097663c4..62db375e5b 100644 --- a/test/inc/WindowsAppRuntime.Test.Diagnostics.h +++ b/test/inc/WindowsAppRuntime.Test.Diagnostics.h @@ -13,6 +13,8 @@ #include #include +#include + namespace Test::Diagnostics { inline PCWSTR IntegrityLevelToString(DWORD integrityLevel) @@ -38,9 +40,7 @@ inline void DumpUser(PCWSTR context, _In_ HANDLE token, PSID userSid) VERIFY_WIN32_BOOL_SUCCEEDED(ConvertSidToStringSidW(userSid, &userSidAsString)); WEX::Logging::Log::Comment(WEX::Common::String().Format(L"UserSid:%s %s", context, userSidAsString.get())); - wistd::unique_ptr tokenMandatoryLabel; - VERIFY_SUCCEEDED(wil::get_token_information_nothrow(tokenMandatoryLabel, token)); - const DWORD integrityLevel{ *GetSidSubAuthority((*tokenMandatoryLabel).Label.Sid, static_cast(static_cast(*GetSidSubAuthorityCount((*tokenMandatoryLabel).Label.Sid) - 1))) }; + const auto integrityLevel{ ::Security::IntegrityLevel::GetIntegrityLevel(token) }; WEX::Logging::Log::Comment(WEX::Common::String().Format(L"IntegrityLevel: 0x%08X (%s)", integrityLevel, IntegrityLevelToString(integrityLevel))); } else diff --git a/test/inc/WindowsAppRuntime.Test.Package.h b/test/inc/WindowsAppRuntime.Test.Package.h index cebfd74e4e..b542ffc594 100644 --- a/test/inc/WindowsAppRuntime.Test.Package.h +++ b/test/inc/WindowsAppRuntime.Test.Package.h @@ -38,16 +38,17 @@ #define MSIX_PACKAGE_ARCHITECTURE_X64 L"x64" #define MSIX_PACKAGE_ARCHITECTURE_X86 L"x86" #if defined(_M_X64) -#define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_X64 +#define MSIX_PACKAGE_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_X64 #elif defined(_M_IX86) -#define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_X86 +#define MSIX_PACKAGE_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_X86 #elif defined(_M_ARM64) -#define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_ARM64 +#define MSIX_PACKAGE_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_ARM64 #elif defined(_M_ARM) -#define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_ARM +#define MSIX_PACKAGE_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE_ARM #else # error "Unknown processor architecture" #endif +#define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE MSIX_PACKAGE_ARCHITECTURE #define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_NAME WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_NAMEPREFIX L"-" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_VERSION_STRING L"-" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_ARCHITECTURE #define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_PUBLISHERID WINDOWSAPPRUNTIME_TEST_MSIX_PUBLISHERID #define WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_FAMILYNAME WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_NAME L"_" WINDOWSAPPRUNTIME_TEST_PACKAGE_DDLM_PUBLISHERID @@ -314,11 +315,29 @@ inline void StagePackageIfNecessary(PCWSTR packageDirName, PCWSTR packageFullNam inline void RemovePackage(PCWSTR packageFullName) { - winrt::Windows::Management::Deployment::PackageManager packageManager; - auto deploymentResult{ packageManager.RemovePackageAsync(packageFullName).get() }; - if (!deploymentResult) + try + { + winrt::Windows::Management::Deployment::PackageManager packageManager; + auto result{ packageManager.RemovePackageAsync(packageFullName) }; + auto deploymentResult{ result.get() }; + if (result.Status() == winrt::Windows::Foundation::AsyncStatus::Completed) + { + VERIFY_IS_NOT_NULL(deploymentResult); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"RemovePackageAsync('%s') = 0x%0X %s", packageFullName, deploymentResult.ExtendedErrorCode(), deploymentResult.ErrorText().c_str())); + } + else if (result.Status() == winrt::Windows::Foundation::AsyncStatus::Error) + { + VERIFY_IS_NOT_NULL(deploymentResult); + WEX::Logging::Log::Comment(WEX::Common::String().Format(L"RemovePackageAsync('%s') = 0x%0X %s", packageFullName, deploymentResult.ExtendedErrorCode(), deploymentResult.ErrorText().c_str())); + } + else + { + VERIFY_FAIL(WEX::Common::String().Format(L"RemovePackageAsync('%s') Status=%d", packageFullName, result.Status())); + } + } + catch (winrt::hresult_error& e) { - VERIFY_FAIL(WEX::Common::String().Format(L"RemovePackageAsync('%s') = 0x%0X %s", packageFullName, deploymentResult.ExtendedErrorCode(), deploymentResult.ErrorText().c_str())); + VERIFY_ARE_EQUAL(S_OK, e.code(), WEX::Common::String().Format(L"0x%X %s", e.code(), e.message().c_str())); } } diff --git a/tools/ProjectTemplates/dev.cpp.dll.winrt-client-server/packages.config b/tools/ProjectTemplates/dev.cpp.dll.winrt-client-server/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.dll.winrt-client-server/packages.config +++ b/tools/ProjectTemplates/dev.cpp.dll.winrt-client-server/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/dev.cpp.dll.winrt-client/packages.config b/tools/ProjectTemplates/dev.cpp.dll.winrt-client/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.dll.winrt-client/packages.config +++ b/tools/ProjectTemplates/dev.cpp.dll.winrt-client/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/dev.cpp.exe+dll.com-oopserver/PurojekutoTenpuret/packages.config b/tools/ProjectTemplates/dev.cpp.exe+dll.com-oopserver/PurojekutoTenpuret/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.exe+dll.com-oopserver/PurojekutoTenpuret/packages.config +++ b/tools/ProjectTemplates/dev.cpp.exe+dll.com-oopserver/PurojekutoTenpuret/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/dev.cpp.exe.com-oopserver-main/packages.config b/tools/ProjectTemplates/dev.cpp.exe.com-oopserver-main/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.exe.com-oopserver-main/packages.config +++ b/tools/ProjectTemplates/dev.cpp.exe.com-oopserver-main/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/dev.cpp.exe.console-winrt-client/packages.config b/tools/ProjectTemplates/dev.cpp.exe.console-winrt-client/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.exe.console-winrt-client/packages.config +++ b/tools/ProjectTemplates/dev.cpp.exe.console-winrt-client/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/dev.cpp.exe.winmain-winrt-client/packages.config b/tools/ProjectTemplates/dev.cpp.exe.winmain-winrt-client/packages.config index cd05427e9c..c7f5504d8f 100644 --- a/tools/ProjectTemplates/dev.cpp.exe.winmain-winrt-client/packages.config +++ b/tools/ProjectTemplates/dev.cpp.exe.winmain-winrt-client/packages.config @@ -4,5 +4,5 @@ - + diff --git a/tools/ProjectTemplates/test.cpp.dll.taef/packages.config b/tools/ProjectTemplates/test.cpp.dll.taef/packages.config index ecebfdd18e..9b993e39b0 100644 --- a/tools/ProjectTemplates/test.cpp.dll.taef/packages.config +++ b/tools/ProjectTemplates/test.cpp.dll.taef/packages.config @@ -5,5 +5,5 @@ - +