diff --git a/.github/actions/spelling/allow.txt b/.github/actions/spelling/allow.txt index 92342b3c0e..a9f338aee5 100644 --- a/.github/actions/spelling/allow.txt +++ b/.github/actions/spelling/allow.txt @@ -54,6 +54,7 @@ cguid chrono cin cla +CLASSNOTAVAILABLE CLSCTX cmake cmdlet @@ -355,6 +356,7 @@ OSVERSIONINFOEXW outfile OUTOFDISKSPACE OUTOFMEMORY +OUTOFPROC OWC packagefamilyname packageidentifier @@ -381,7 +383,7 @@ png posix powershell pplx -PPV +ppv pragma PRECONFIG preindexed @@ -486,6 +488,7 @@ sscanf sstream STATFLAG STATSTG +STDAPI stdcall stderr stdexcept diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index e34f3bc6de..5da652bbd1 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -142,6 +142,7 @@ GHS gity Globals Google +guiddef hackathon hashtable helplib diff --git a/src/AppInstallerCLI.sln b/src/AppInstallerCLI.sln index e1e19ecdff..fc3645a93b 100644 --- a/src/AppInstallerCLI.sln +++ b/src/AppInstallerCLI.sln @@ -147,6 +147,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowsPackageManager", "Wi EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COMServer", "COMServer\COMServer.vcxitems", "{409CD681-22A4-469D-88AE-CB5E4836E07A}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Microsoft.Management.Deployment.InProc", "Microsoft.Management.Deployment.InProc\Microsoft.Management.Deployment.InProc.vcxproj", "{9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}" +EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution ManifestSchema\ManifestSchema.vcxitems*{1622da16-914f-4f57-a259-d5169003cc8c}*SharedItemsImports = 4 @@ -1003,6 +1005,40 @@ Global {2046B5AF-666D-4CE8-8D3E-C32C57908A56}.TestRelease|x64.Build.0 = Release|x64 {2046B5AF-666D-4CE8-8D3E-C32C57908A56}.TestRelease|x86.ActiveCfg = Release|Win32 {2046B5AF-666D-4CE8-8D3E-C32C57908A56}.TestRelease|x86.Build.0 = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|Any CPU.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|ARM.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|ARM64.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|x64.ActiveCfg = Debug|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|x64.Build.0 = Debug|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|x86.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Debug|x86.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|Any CPU.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|Any CPU.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|ARM.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|ARM.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|ARM64.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|ARM64.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|x64.ActiveCfg = Debug|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|x64.Build.0 = Debug|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|x86.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Fuzzing|x86.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|Any CPU.ActiveCfg = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|ARM.ActiveCfg = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|ARM64.ActiveCfg = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|x64.ActiveCfg = Release|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|x64.Build.0 = Release|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|x86.ActiveCfg = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.Release|x86.Build.0 = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|Any CPU.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|Any CPU.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|ARM.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|ARM.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|ARM64.ActiveCfg = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|ARM64.Build.0 = Debug|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|x64.ActiveCfg = Release|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|x64.Build.0 = Release|x64 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|x86.ActiveCfg = Release|Win32 + {9AC3C6A4-1875-4D3E-BF9C-C31E81EFF6B4}.TestRelease|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/AppInstallerCLI/AppInstallerCLI.vcxproj b/src/AppInstallerCLI/AppInstallerCLI.vcxproj index ad8607ef85..0789e19a64 100644 --- a/src/AppInstallerCLI/AppInstallerCLI.vcxproj +++ b/src/AppInstallerCLI/AppInstallerCLI.vcxproj @@ -191,7 +191,7 @@ Console false - wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies) + %(AdditionalDependencies) $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) @@ -253,7 +253,7 @@ true true false - wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies) + %(AdditionalDependencies) $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) diff --git a/src/AppInstallerCLICore/COMContext.h b/src/AppInstallerCLICore/COMContext.h index 0508e9981c..5cd9cde1e8 100644 --- a/src/AppInstallerCLICore/COMContext.h +++ b/src/AppInstallerCLICore/COMContext.h @@ -38,6 +38,7 @@ namespace AppInstaller::CLI::Execution // When no Console streams need involvement, construct NullStreams instead to pass to Context COMContext() : NullStream(), CLI::Execution::Context(*m_nullOut, *m_nullIn) { + Reporter.SetChannel(Reporter::Channel::Disabled); Reporter.SetProgressSink(this); SetFlags(CLI::Execution::ContextFlag::AgreementsAcceptedByCaller); } diff --git a/src/AppInstallerCLICore/ExecutionReporter.cpp b/src/AppInstallerCLICore/ExecutionReporter.cpp index 66adad14ad..cf6d59d99b 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.cpp +++ b/src/AppInstallerCLICore/ExecutionReporter.cpp @@ -74,7 +74,7 @@ namespace AppInstaller::CLI::Execution OutputStream Reporter::GetBasicOutputStream() { - return {*m_out, m_channel == Channel::Output }; + return { *m_out, m_channel == Channel::Output }; } void Reporter::SetChannel(Channel channel) diff --git a/src/AppInstallerCLICore/ExecutionReporter.h b/src/AppInstallerCLICore/ExecutionReporter.h index 258d496208..9aac540e43 100644 --- a/src/AppInstallerCLICore/ExecutionReporter.h +++ b/src/AppInstallerCLICore/ExecutionReporter.h @@ -44,6 +44,7 @@ namespace AppInstaller::CLI::Execution { Output, Completion, + Disabled, }; // The level for the Output channel. diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest new file mode 100644 index 0000000000..341f7a73ad --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.dll.manifest @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj new file mode 100644 index 0000000000..3abcd7bc01 --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj @@ -0,0 +1,314 @@ + + + + + true + true + true + 15.0 + Win32Proj + {9ac3c6a4-1875-4d3e-bf9c-c31e81eff6b4} + MicrosoftManagementDeploymentInProc + 10.0.22000.0 + 10.0.17763.0 + true + true + false + + + + + Debug + ARM + + + Debug + ARM64 + + + Debug + Win32 + + + Release + ARM + + + Release + ARM64 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + DynamicLibrary + v140 + v141 + v142 + v143 + Unicode + + + true + true + + + false + true + false + + + Spectre + + + Spectre + + + Spectre + + + Spectre + + + + + + + + + + + + + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + true + ..\CodeAnalysis.ruleset + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + true + ..\CodeAnalysis.ruleset + + + true + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + true + ..\CodeAnalysis.ruleset + + + true + $(SolutionDir)x86\$(Configuration)\$(ProjectName)\ + true + true + ..\CodeAnalysis.ruleset + + + false + $(SolutionDir)x86\$(Configuration)\$(ProjectName)\ + true + false + ..\CodeAnalysis.ruleset + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + false + ..\CodeAnalysis.ruleset + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + false + ..\CodeAnalysis.ruleset + + + false + $(SolutionDir)$(Platform)\$(Configuration)\$(ProjectName)\ + true + false + ..\CodeAnalysis.ruleset + + + + Use + pch.h + $(IntDir)pch.pch + _CONSOLE;%(PreprocessorDefinitions) + Level4 + %(AdditionalOptions) /permissive- /bigobj /D _SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING + + + + + Disabled + _DEBUG;%(PreprocessorDefinitions) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + true + true + true + false + false + false + stdcpp17 + stdcpp17 + stdcpp17 + true + true + true + true + true + true + + + false + Windows + Windows + Windows + Windows + Source.def + Source.def + Source.def + Source.def + wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + + + WIN32;%(PreprocessorDefinitions) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + true + false + stdcpp17 + true + true + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + + + MaxSpeed + true + true + NDEBUG;%(PreprocessorDefinitions) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + $(ProjectDir)..\WindowsPackageManager;%(AdditionalIncludeDirectories) + true + true + true + true + Guard + Guard + Guard + Guard + stdcpp17 + stdcpp17 + stdcpp17 + stdcpp17 + true + true + true + true + false + false + false + false + + + true + true + false + Windows + Windows + Windows + Windows + Source.def + Source.def + Source.def + Source.def + wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + $(ProjectDir)..\manifest\shared.manifest %(AdditionalManifestFiles) + + + + + + + + + Create + + + + + {2046b5af-666d-4ce8-8d3e-c32c57908a56} + + + + + + + + + + true + + + + + + + + + + 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}. + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj.filters b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj.filters new file mode 100644 index 0000000000..3b66a402ed --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/Microsoft.Management.Deployment.InProc.vcxproj.filters @@ -0,0 +1,40 @@ + + + + + {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 + + + + + Header Files + + + + + Source Files + + + Source Files + + + + + + + Source Files + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.InProc/PropertySheet.props b/src/Microsoft.Management.Deployment.InProc/PropertySheet.props new file mode 100644 index 0000000000..c6b0691ddd --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/PropertySheet.props @@ -0,0 +1,16 @@ + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.InProc/Source.def b/src/Microsoft.Management.Deployment.InProc/Source.def new file mode 100644 index 0000000000..a0f6f5cee5 --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/Source.def @@ -0,0 +1,3 @@ +EXPORTS +DllCanUnloadNow PRIVATE +DllGetClassObject PRIVATE diff --git a/src/Microsoft.Management.Deployment.InProc/dllmain.cpp b/src/Microsoft.Management.Deployment.InProc/dllmain.cpp new file mode 100644 index 0000000000..09fa11223e --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/dllmain.cpp @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include + +EXTERN_C BOOL WINAPI DllMain( + HMODULE /* hModule */, + DWORD reason, + LPVOID /* lpReserved */) +{ + switch (reason) + { + case DLL_PROCESS_ATTACH: + { + if (FAILED(WindowsPackageManagerInProcModuleInitialize())) + { + return FALSE; + } + } + break; + + case DLL_PROCESS_DETACH: + { + WindowsPackageManagerInProcModuleTerminate(); + } + break; + + default: + return TRUE; + } + return TRUE; +} + +STDAPI DllGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID* ppv) +{ + RETURN_HR(WindowsPackageManagerInProcModuleGetClassObject(rclsid, riid, ppv)); +} + +STDAPI DllCanUnloadNow() +{ + return WindowsPackageManagerInProcModuleTerminate() ? S_OK : S_FALSE; +} diff --git a/src/Microsoft.Management.Deployment.InProc/packages.config b/src/Microsoft.Management.Deployment.InProc/packages.config new file mode 100644 index 0000000000..5e899619db --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment.InProc/pch.cpp b/src/Microsoft.Management.Deployment.InProc/pch.cpp new file mode 100644 index 0000000000..855ee69a1e --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/pch.cpp @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +#include "pch.h" diff --git a/src/Microsoft.Management.Deployment.InProc/pch.h b/src/Microsoft.Management.Deployment.InProc/pch.h new file mode 100644 index 0000000000..098c04e086 --- /dev/null +++ b/src/Microsoft.Management.Deployment.InProc/pch.h @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#define WIN32_LEAN_AND_MEAN +#include +#include \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment/ComClsids.cpp b/src/Microsoft.Management.Deployment/ComClsids.cpp new file mode 100644 index 0000000000..b02dd3d2ae --- /dev/null +++ b/src/Microsoft.Management.Deployment/ComClsids.cpp @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "Public/ComClsids.h" +#pragma warning( push ) +#pragma warning ( disable : 4467 ) +// 4467 Allow use of uuid attribute for com object creation. +#include "PackageManager.h" +#include "FindPackagesOptions.h" +#include "CreateCompositePackageCatalogOptions.h" +#include "InstallOptions.h" +#include "UninstallOptions.h" +#include "PackageMatchFilter.h" +#pragma warning( pop ) + +namespace winrt::Microsoft::Management::Deployment +{ + CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid) + { + if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_PackageManager)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::PackageManager); + } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_FindPackagesOptions)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::FindPackagesOptions); + } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_CreateCompositePackageCatalogOptions)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::CreateCompositePackageCatalogOptions); + } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_InstallOptions)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::InstallOptions); + } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_UninstallOptions)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::UninstallOptions); + } + else if (IsEqualCLSID(clsid, WINGET_INPROC_COM_CLSID_PackageMatchFilter)) + { + return __uuidof(winrt::Microsoft::Management::Deployment::implementation::PackageMatchFilter); + } + else + { + return CLSID_NULL; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment/CreateCompositePackageCatalogOptions.h b/src/Microsoft.Management.Deployment/CreateCompositePackageCatalogOptions.h index 5bdfe28ab4..dc880ffc16 100644 --- a/src/Microsoft.Management.Deployment/CreateCompositePackageCatalogOptions.h +++ b/src/Microsoft.Management.Deployment/CreateCompositePackageCatalogOptions.h @@ -2,14 +2,11 @@ // Licensed under the MIT License. #pragma once #include "CreateCompositePackageCatalogOptions.g.h" +#include "Public/ComClsids.h" namespace winrt::Microsoft::Management::Deployment::implementation { -#if USE_PROD_CLSIDS - [uuid("526534B8-7E46-47C8-8416-B1685C327D37")] -#else - [uuid("EE160901-B317-4EA7-9CC6-5355C6D7D8A7")] -#endif + [uuid(WINGET_OUTOFPROC_COM_CLSID_CreateCompositePackageCatalogOptions)] struct CreateCompositePackageCatalogOptions : CreateCompositePackageCatalogOptionsT { CreateCompositePackageCatalogOptions() = default; diff --git a/src/Microsoft.Management.Deployment/FindPackagesOptions.h b/src/Microsoft.Management.Deployment/FindPackagesOptions.h index a3cb2af30a..d9c3bc6a63 100644 --- a/src/Microsoft.Management.Deployment/FindPackagesOptions.h +++ b/src/Microsoft.Management.Deployment/FindPackagesOptions.h @@ -2,14 +2,11 @@ // Licensed under the MIT License. #pragma once #include "FindPackagesOptions.g.h" +#include "Public/ComClsids.h" namespace winrt::Microsoft::Management::Deployment::implementation { -#if USE_PROD_CLSIDS - [uuid("572DED96-9C60-4526-8F92-EE7D91D38C1A")] -#else - [uuid("1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96")] -#endif + [uuid(WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions)] struct FindPackagesOptions : FindPackagesOptionsT { FindPackagesOptions() = default; diff --git a/src/Microsoft.Management.Deployment/Helpers.cpp b/src/Microsoft.Management.Deployment/Helpers.cpp index 9490dc0074..5c228082b6 100644 --- a/src/Microsoft.Management.Deployment/Helpers.cpp +++ b/src/Microsoft.Management.Deployment/Helpers.cpp @@ -21,13 +21,21 @@ namespace winrt::Microsoft::Management::Deployment::implementation callAttributes.Flags = RPC_QUERY_CLIENT_PID; rpcStatus = RpcServerInqCallAttributes(nullptr, &callAttributes); - if ((rpcStatus != RPC_S_NO_CALL_ACTIVE) && - !((rpcStatus == RPC_S_OK) && HandleToULong(callAttributes.ClientPID) == GetCurrentProcessId())) + if (rpcStatus == RPC_S_NO_CALL_ACTIVE || + (rpcStatus == RPC_S_OK && HandleToULong(callAttributes.ClientPID) == GetCurrentProcessId())) { - DWORD callerProcessId = HandleToULong(callAttributes.ClientPID); - return { S_OK, callerProcessId }; + // in-proc is supported now. + return { S_OK, GetCurrentProcessId() }; + } + else if (rpcStatus == RPC_S_OK) + { + // out-of-proc case. + return { S_OK, HandleToULong(callAttributes.ClientPID) }; + } + else + { + return { E_ACCESSDENIED, 0 }; } - return { E_ACCESSDENIED, 0 }; } std::wstring_view GetStringForCapability(Capability capability) diff --git a/src/Microsoft.Management.Deployment/InstallOptions.h b/src/Microsoft.Management.Deployment/InstallOptions.h index e95fab3813..9d38f4cacd 100644 --- a/src/Microsoft.Management.Deployment/InstallOptions.h +++ b/src/Microsoft.Management.Deployment/InstallOptions.h @@ -2,14 +2,11 @@ // Licensed under the MIT License. #pragma once #include "InstallOptions.g.h" +#include "Public/ComClsids.h" namespace winrt::Microsoft::Management::Deployment::implementation { -#if USE_PROD_CLSIDS - [uuid("1095F097-EB96-453B-B4E6-1613637F3B14")] -#else - [uuid("44FE0580-62F7-44D4-9E91-AA9614AB3E86")] -#endif + [uuid(WINGET_OUTOFPROC_COM_CLSID_InstallOptions)] struct InstallOptions : InstallOptionsT { InstallOptions(); diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj index 1345c5a64f..4613289587 100644 --- a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj @@ -154,11 +154,13 @@ + + diff --git a/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters new file mode 100644 index 0000000000..18aa3e0a7b --- /dev/null +++ b/src/Microsoft.Management.Deployment/Microsoft.Management.Deployment.vcxproj.filters @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Public + + + + + + + + + + + + + {9c3907ed-84d9-4485-9b15-04c50717f0ab} + + + \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment/PackageManager.h b/src/Microsoft.Management.Deployment/PackageManager.h index 2d3086c7c9..bc40538b59 100644 --- a/src/Microsoft.Management.Deployment/PackageManager.h +++ b/src/Microsoft.Management.Deployment/PackageManager.h @@ -2,14 +2,11 @@ // Licensed under the MIT License. #pragma once #include "PackageManager.g.h" +#include "Public/ComClsids.h" namespace winrt::Microsoft::Management::Deployment::implementation { -#if USE_PROD_CLSIDS - [uuid("C53A4F16-787E-42A4-B304-29EFFB4BF597")] -#else - [uuid("74CB3139-B7C5-4B9E-9388-E6616DEA288C")] -#endif + [uuid(WINGET_OUTOFPROC_COM_CLSID_PackageManager)] struct PackageManager : PackageManagerT { PackageManager() = default; diff --git a/src/Microsoft.Management.Deployment/PackageMatchFilter.h b/src/Microsoft.Management.Deployment/PackageMatchFilter.h index e6d25b602b..94d75a8031 100644 --- a/src/Microsoft.Management.Deployment/PackageMatchFilter.h +++ b/src/Microsoft.Management.Deployment/PackageMatchFilter.h @@ -2,14 +2,18 @@ // Licensed under the MIT License. #pragma once #include "PackageMatchFilter.g.h" +#include "Public/ComClsids.h" -namespace winrt::Microsoft::Management::Deployment::implementation +#if !defined(INCLUDE_ONLY_INTERFACE_METHODS) +namespace AppInstaller::Repository { -#if USE_PROD_CLSIDS - [uuid("D02C9DAF-99DC-429C-B503-4E504E4AB000")] -#else - [uuid("3F85B9F4-487A-4C48-9035-2903F8A6D9E8")] + struct PackageMatchFilter; +} #endif + +namespace winrt::Microsoft::Management::Deployment::implementation +{ + [uuid(WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter)] struct PackageMatchFilter : PackageMatchFilterT { PackageMatchFilter() = default; diff --git a/src/Microsoft.Management.Deployment/Public/ComClsids.h b/src/Microsoft.Management.Deployment/Public/ComClsids.h new file mode 100644 index 0000000000..aa04828bc6 --- /dev/null +++ b/src/Microsoft.Management.Deployment/Public/ComClsids.h @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include + +// clsids for out-of-proc com invocation +#if USE_PROD_CLSIDS +#define WINGET_OUTOFPROC_COM_CLSID_PackageManager "C53A4F16-787E-42A4-B304-29EFFB4BF597" +#define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "572DED96-9C60-4526-8F92-EE7D91D38C1A" +#define WINGET_OUTOFPROC_COM_CLSID_CreateCompositePackageCatalogOptions "526534B8-7E46-47C8-8416-B1685C327D37" +#define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "1095F097-EB96-453B-B4E6-1613637F3B14" +#define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "E1D9A11E-9F85-4D87-9C17-2B93143ADB8D" +#define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "D02C9DAF-99DC-429C-B503-4E504E4AB000" +#else +#define WINGET_OUTOFPROC_COM_CLSID_PackageManager "74CB3139-B7C5-4B9E-9388-E6616DEA288C" +#define WINGET_OUTOFPROC_COM_CLSID_FindPackagesOptions "1BD8FF3A-EC50-4F69-AEEE-DF4C9D3BAA96" +#define WINGET_OUTOFPROC_COM_CLSID_CreateCompositePackageCatalogOptions "EE160901-B317-4EA7-9CC6-5355C6D7D8A7" +#define WINGET_OUTOFPROC_COM_CLSID_InstallOptions "44FE0580-62F7-44D4-9E91-AA9614AB3E86" +#define WINGET_OUTOFPROC_COM_CLSID_UninstallOptions "AA2A5C04-1AD9-46C4-B74F-6B334AD7EB8C" +#define WINGET_OUTOFPROC_COM_CLSID_PackageMatchFilter "3F85B9F4-487A-4C48-9035-2903F8A6D9E8" +#endif + +namespace winrt::Microsoft::Management::Deployment +{ + // clsid constants for in-proc com invocation + const CLSID WINGET_INPROC_COM_CLSID_PackageManager = { 0x2DDE4456, 0x64D9, 0x4673, 0x8F, 0x7E, 0xA4, 0xF1, 0x9A, 0x2E, 0x6C, 0xC3 }; // 2DDE4456-64D9-4673-8F7E-A4F19A2E6CC3 + const CLSID WINGET_INPROC_COM_CLSID_FindPackagesOptions = { 0x96B9A53A, 0x9228, 0x4DA0, 0xB0, 0x13, 0xBB, 0x1B, 0x20, 0x31, 0xAB, 0x3D }; // 96B9A53A-9228-4DA0-B013-BB1B2031AB3D + const CLSID WINGET_INPROC_COM_CLSID_CreateCompositePackageCatalogOptions = { 0x768318A6, 0x2EB5, 0x400D, 0x84, 0xD0, 0xDF, 0x35, 0x34, 0xC3, 0x0F, 0x5D }; // 768318A6-2EB5-400D-84D0-DF3534C30F5D + const CLSID WINGET_INPROC_COM_CLSID_InstallOptions = { 0xE2AF3BA8, 0x8A88, 0x4766, 0x9D, 0xDA, 0xAE, 0x40, 0x13, 0xAD, 0xE2, 0x86 }; // E2AF3BA8-8A88-4766-9DDA-AE4013ADE286 + const CLSID WINGET_INPROC_COM_CLSID_UninstallOptions = { 0x869CB959, 0xEB54, 0x425C, 0xA1, 0xE4, 0x1A, 0x1C, 0x29, 0x1C, 0x64, 0xE9 }; // 869CB959-EB54-425C-A1E4-1A1C291C64E9 + const CLSID WINGET_INPROC_COM_CLSID_PackageMatchFilter = { 0x57DC8962, 0x7343, 0x42CD, 0xB9, 0x1C, 0x04, 0xF6, 0xA2, 0x5D, 0xB1, 0xD0 }; // 57DC8962-7343-42CD-B91C-04F6A25DB1D0 + + CLSID GetRedirectedClsidFromInProcClsid(REFCLSID clsid); +} \ No newline at end of file diff --git a/src/Microsoft.Management.Deployment/UninstallOptions.h b/src/Microsoft.Management.Deployment/UninstallOptions.h index d56ecae072..24ef9677dc 100644 --- a/src/Microsoft.Management.Deployment/UninstallOptions.h +++ b/src/Microsoft.Management.Deployment/UninstallOptions.h @@ -2,14 +2,11 @@ // Licensed under the MIT License. #pragma once #include "UninstallOptions.g.h" +#include "Public/ComClsids.h" namespace winrt::Microsoft::Management::Deployment::implementation { -#if USE_PROD_CLSIDS - [uuid("E1D9A11E-9F85-4D87-9C17-2B93143ADB8D")] -#else - [uuid("AA2A5C04-1AD9-46C4-B74F-6B334AD7EB8C")] -#endif + [uuid(WINGET_OUTOFPROC_COM_CLSID_UninstallOptions)] struct UninstallOptions : UninstallOptionsT { UninstallOptions(); diff --git a/src/WinGetServer/WinGetServer.vcxproj b/src/WinGetServer/WinGetServer.vcxproj index 3d3a06e9b9..6490cbd0b6 100644 --- a/src/WinGetServer/WinGetServer.vcxproj +++ b/src/WinGetServer/WinGetServer.vcxproj @@ -107,7 +107,7 @@ Windows false $(OutDir)..\Microsoft.Management.Deployment;$(OutDir)..\AppInstallerCLICore;$(OutDir)..\JsonCppLib;$(OutDir)..\AppInstallerRepositoryCore;$(OutDir)..\YamlCppLib;$(OutDir)..\AppInstallerCommonCore;$(OutDir)..\cpprestsdk;%(AdditionalLibraryDirectories) - Microsoft.Management.Deployment.Server.lib;AppInstallerCLICore.lib;AppInstallerCommonCore.lib;AppInstallerRepositoryCore.lib;JsonCppLib.lib;YamlCppLib.lib;cpprestsdk.lib;wininet.lib;shell32.lib;winsqlite3.lib;shlwapi.lib;icuuc.lib;icuin.lib;urlmon.lib;Advapi32.lib;winhttp.lib;onecoreuap.lib;msi.lib;%(AdditionalDependencies) + %(AdditionalDependencies) diff --git a/src/WindowsPackageManager/Source.def b/src/WindowsPackageManager/Source.def index c4fb834177..c57681a3f9 100644 --- a/src/WindowsPackageManager/Source.def +++ b/src/WindowsPackageManager/Source.def @@ -5,3 +5,6 @@ EXPORTS WindowsPackageManagerServerModuleCreate WindowsPackageManagerServerModuleRegister WindowsPackageManagerServerModuleUnregister + WindowsPackageManagerInProcModuleInitialize + WindowsPackageManagerInProcModuleTerminate + WindowsPackageManagerInProcModuleGetClassObject diff --git a/src/WindowsPackageManager/WindowsPackageManager.h b/src/WindowsPackageManager/WindowsPackageManager.h index 023197c9ed..a7850f3a75 100644 --- a/src/WindowsPackageManager/WindowsPackageManager.h +++ b/src/WindowsPackageManager/WindowsPackageManager.h @@ -23,4 +23,16 @@ extern "C" // Unregisters the server module class factories. WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerServerModuleUnregister(); + + // Creates module for in-proc COM invocation. + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleInitialize(); + + // Try to terminate the module for in-proc COM. Returns false if there's still active objects. + bool WINDOWS_PACKAGE_MANAGER_API_CALLING_CONVENTION WindowsPackageManagerInProcModuleTerminate(); + + // DllGetClassObject for in-proc COM for cpp winrt runtime classes. + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID* ppv); } diff --git a/src/WindowsPackageManager/WindowsPackageManager.vcxproj b/src/WindowsPackageManager/WindowsPackageManager.vcxproj index 84dfdc61bc..9279588e1f 100644 --- a/src/WindowsPackageManager/WindowsPackageManager.vcxproj +++ b/src/WindowsPackageManager/WindowsPackageManager.vcxproj @@ -163,9 +163,9 @@ Disabled _DEBUG;%(PreprocessorDefinitions) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) true true true @@ -207,7 +207,7 @@ WIN32;%(PreprocessorDefinitions) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\JsonCppLib\json;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) true false stdcpp17 @@ -224,10 +224,10 @@ true true NDEBUG;%(PreprocessorDefinitions) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories) - $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) + $(ProjectDir);$(ProjectDir)..\AppInstallerCLICore\Public\;$(ProjectDir)..\AppInstallerCommonCore;$(ProjectDir)..\AppInstallerRepositoryCore;$(ProjectDir)..\AppInstallerCommonCore\Public;$(ProjectDir)..\Microsoft.Management.Deployment\Public;%(AdditionalIncludeDirectories) true true true diff --git a/src/WindowsPackageManager/main.cpp b/src/WindowsPackageManager/main.cpp index 972176038a..9dc5cb4485 100644 --- a/src/WindowsPackageManager/main.cpp +++ b/src/WindowsPackageManager/main.cpp @@ -10,9 +10,11 @@ #include "WindowsPackageManager.h" #include +#include using namespace winrt::Microsoft::Management::Deployment; +// CreatorMap for out-of-proc com registration CoCreatableClassWrlCreatorMapInclude(PackageManager); CoCreatableClassWrlCreatorMapInclude(FindPackagesOptions); CoCreatableClassWrlCreatorMapInclude(CreateCompositePackageCatalogOptions); @@ -54,4 +56,34 @@ extern "C" RETURN_HR(::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::OutOfProc>::GetModule().UnregisterObjects()); } CATCH_RETURN(); + + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleInitialize() try + { + ::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::Create(); + return S_OK; + } + CATCH_RETURN(); + + bool WINDOWS_PACKAGE_MANAGER_API_CALLING_CONVENTION WindowsPackageManagerInProcModuleTerminate() + { + try + { + return ::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::GetModule().Terminate(); + } + catch (...) + { + return false; + } + } + + WINDOWS_PACKAGE_MANAGER_API WindowsPackageManagerInProcModuleGetClassObject( + REFCLSID rclsid, + REFIID riid, + LPVOID* ppv) try + { + CLSID redirectedClsid = GetRedirectedClsidFromInProcClsid(rclsid); + RETURN_HR_IF(CLASS_E_CLASSNOTAVAILABLE, IsEqualCLSID(redirectedClsid, CLSID_NULL)); + RETURN_HR(::Microsoft::WRL::Module<::Microsoft::WRL::ModuleType::InProc>::GetModule().GetClassObject(redirectedClsid, riid, ppv)); + } + CATCH_RETURN(); }