diff --git a/src/powershell-native/nativemsh/pwrshcommon/pwrshcommon.cpp b/src/powershell-native/nativemsh/pwrshcommon/pwrshcommon.cpp index d68bbff390..198d9e7482 100644 --- a/src/powershell-native/nativemsh/pwrshcommon/pwrshcommon.cpp +++ b/src/powershell-native/nativemsh/pwrshcommon/pwrshcommon.cpp @@ -669,28 +669,52 @@ namespace NativeMsh // NOTE: The names must not include the .dll extension because it will be added programmatically. static PCSTR trustedAssemblies[] = { + "Microsoft.ApplicationInsights", + "Microsoft.CodeAnalysis", + "Microsoft.CodeAnalysis.CSharp", "Microsoft.CSharp", + "Microsoft.Management.Infrastructure", + "Microsoft.Management.Infrastructure.CimCmdlets", + "Microsoft.Management.Infrastructure.Native", + "Microsoft.PowerShell.Commands.Diagnostics", + "Microsoft.PowerShell.Commands.Management", + "Microsoft.PowerShell.Commands.Utility", + "Microsoft.PowerShell.ConsoleHost", + "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext", + "Microsoft.PowerShell.CoreCLR.Eventing", + "Microsoft.PowerShell.LocalAccounts", + "Microsoft.PowerShell.PSReadLine", + "Microsoft.PowerShell.SDK", + "Microsoft.PowerShell.Security", "Microsoft.VisualBasic", "Microsoft.Win32.Primitives", - "Microsoft.Win32.Registry.AccessControl", "Microsoft.Win32.Registry", + "Microsoft.Win32.Registry.AccessControl", + "Microsoft.WSMan.Management", + "Microsoft.WSMan.Runtime", "mscorlib", + "netstandard", + "Newtonsoft.Json", + "System", "System.AppContext", "System.Buffers", - "System.Collections.Concurrent", "System.Collections", + "System.Collections.Concurrent", "System.Collections.Immutable", "System.Collections.NonGeneric", "System.Collections.Specialized", - "System.ComponentModel.Annotations", - "System.ComponentModel.DataAnnotations", "System.ComponentModel", + "System.ComponentModel.Annotations", + "System.ComponentModel.Composition", + "System.ComponentModel.DataAnnotations", "System.ComponentModel.EventBasedAsync", "System.ComponentModel.Primitives", "System.ComponentModel.TypeConverter", "System.Console", "System.Core", + "System.Data", "System.Data.Common", + "System.Data.SqlClient", "System.Diagnostics.Contracts", "System.Diagnostics.Debug", "System.Diagnostics.DiagnosticSource", @@ -701,19 +725,22 @@ namespace NativeMsh "System.Diagnostics.Tools", "System.Diagnostics.TraceSource", "System.Diagnostics.Tracing", - "System", + "System.Drawing", + "System.Drawing.Primitives", "System.Dynamic.Runtime", - "System.Globalization.Calendars", "System.Globalization", + "System.Globalization.Calendars", "System.Globalization.Extensions", - "System.IO.Compression", - "System.IO.Compression.ZipFile", "System.IO", - "System.IO.FileSystem.AccessControl", + "System.IO.Compression", + "System.IO.Compression.FileSystem", + "System.IO.Compression.ZipFile", "System.IO.FileSystem", + "System.IO.FileSystem.AccessControl", "System.IO.FileSystem.DriveInfo", "System.IO.FileSystem.Primitives", "System.IO.FileSystem.Watcher", + "System.IO.IsolatedStorage", "System.IO.MemoryMappedFiles", "System.IO.Packaging", "System.IO.Pipes", @@ -722,19 +749,25 @@ namespace NativeMsh "System.Linq.Expressions", "System.Linq.Parallel", "System.Linq.Queryable", + "System.Management.Automation", "System.Net", "System.Net.Http", "System.Net.Http.WinHttpHandler", + "System.Net.HttpListener", + "System.Net.Mail", "System.Net.NameResolution", "System.Net.NetworkInformation", "System.Net.Ping", "System.Net.Primitives", "System.Net.Requests", "System.Net.Security", + "System.Net.ServicePoint", "System.Net.Sockets", + "System.Net.WebClient", "System.Net.WebHeaderCollection", - "System.Net.WebSockets.Client", + "System.Net.WebProxy", "System.Net.WebSockets", + "System.Net.WebSockets.Client", "System.Numerics", "System.Numerics.Vectors", "System.ObjectModel", @@ -742,8 +775,10 @@ namespace NativeMsh "System.Private.DataContractSerialization", "System.Private.ServiceModel", "System.Private.Uri", - "System.Reflection.DispatchProxy", + "System.Private.Xml", + "System.Private.Xml.Linq", "System.Reflection", + "System.Reflection.DispatchProxy", "System.Reflection.Emit", "System.Reflection.Emit.ILGeneration", "System.Reflection.Emit.Lightweight", @@ -753,15 +788,18 @@ namespace NativeMsh "System.Reflection.TypeExtensions", "System.Resources.Reader", "System.Resources.ResourceManager", - "System.Runtime.CompilerServices.VisualC", + "System.Resources.Writer", "System.Runtime", + "System.Runtime.CompilerServices.VisualC", "System.Runtime.Extensions", "System.Runtime.Handles", "System.Runtime.InteropServices", "System.Runtime.InteropServices.RuntimeInformation", + "System.Runtime.InteropServices.WindowsRuntime", "System.Runtime.Loader", "System.Runtime.Numerics", "System.Runtime.Serialization", + "System.Runtime.Serialization.Formatters", "System.Runtime.Serialization.Json", "System.Runtime.Serialization.Primitives", "System.Runtime.Serialization.Xml", @@ -778,7 +816,6 @@ namespace NativeMsh "System.Security.Principal", "System.Security.Principal.Windows", "System.Security.SecureString", - "System.ServiceModel", "System.ServiceModel.Duplex", "System.ServiceModel.Http", "System.ServiceModel.NetTcp", @@ -786,21 +823,26 @@ namespace NativeMsh "System.ServiceModel.Security", "System.ServiceModel.Web", "System.ServiceProcess.ServiceController", - "System.Text.Encoding.CodePages", "System.Text.Encoding", + "System.Text.Encoding.CodePages", "System.Text.Encoding.Extensions", "System.Text.Encodings.Web", "System.Text.RegularExpressions", - "System.Threading.AccessControl", "System.Threading", + "System.Threading.AccessControl", "System.Threading.Overlapped", - "System.Threading.Tasks.Dataflow", "System.Threading.Tasks", + "System.Threading.Tasks.Dataflow", "System.Threading.Tasks.Extensions", "System.Threading.Tasks.Parallel", "System.Threading.Thread", "System.Threading.ThreadPool", "System.Threading.Timer", + "System.Transactions", + "System.Transactions.Local", + "System.ValueTuple", + "System.Web", + "System.Web.HttpUtility", "System.Windows", "System.Xml", "System.Xml.Linq", @@ -810,9 +852,7 @@ namespace NativeMsh "System.Xml.XmlDocument", "System.Xml.XmlSerializer", "System.Xml.XPath", - "System.Xml.XPath.XDocument", - "System.Xml.XPath.XmlDocument", - "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext" + "System.Xml.XPath.XDocument" }; // Define the function pointer for the CLR entry point diff --git a/src/powershell-native/nativemsh/pwrshexe/CssMainEntry.cpp b/src/powershell-native/nativemsh/pwrshexe/CssMainEntry.cpp index c8a2017604..35497d8922 100644 --- a/src/powershell-native/nativemsh/pwrshexe/CssMainEntry.cpp +++ b/src/powershell-native/nativemsh/pwrshexe/CssMainEntry.cpp @@ -26,9 +26,6 @@ namespace NativeMsh // Define the function pointer for the powershell entry point. typedef int (STDMETHODCALLTYPE *MonadRunHelperFp)(LPCWSTR consoleFilePath, LPCWSTR * args, int argc); // int UnmanagedPSEntry.Start(string consoleFilePath, string[] args, int argc) - // Define the function pointer for AssemblyLoadContext initializer. - typedef void (STDMETHODCALLTYPE *LoaderRunHelperFp)(LPCWSTR appPath); - bool TryRun(const int argc, const wchar_t* argv[], HostEnvironment &hostEnvironment, int &exitCode, bool verbose) { // Assume failure @@ -54,28 +51,10 @@ namespace NativeMsh return false; } - //------------------------------------------------------------- - // Set the powershell custom assembly loader to be the default - LoaderRunHelperFp initDelegate = NULL; - HRESULT hr = hostWrapper.CreateDelegate( - "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", - "System.Management.Automation.PowerShellAssemblyLoadContextInitializer", - "SetPowerShellAssemblyLoadContext", - (void**)&initDelegate); - - if (FAILED(hr)) - { - output->DisplayMessage(false, g_CREATING_MSH_ENTRANCE_FAILED, hr); - } - else - { - initDelegate(hostEnvironment.GetHostDirectoryPathW()); - } - //------------------------------------------------------------- // Start the assembly MonadRunHelperFp pfnDelegate = NULL; - hr = hostWrapper.CreateDelegate( + HRESULT hr = hostWrapper.CreateDelegate( "Microsoft.PowerShell.ConsoleHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "Microsoft.PowerShell.UnmanagedPSEntry", "Start", diff --git a/src/powershell-native/nativemsh/pwrshplugin/pwrshclrhost.cpp b/src/powershell-native/nativemsh/pwrshplugin/pwrshclrhost.cpp index 054e1f1f50..891775193e 100644 --- a/src/powershell-native/nativemsh/pwrshplugin/pwrshclrhost.cpp +++ b/src/powershell-native/nativemsh/pwrshplugin/pwrshclrhost.cpp @@ -32,12 +32,6 @@ typedef DWORD (WINAPI *InitPluginWkrPtrsFuncPtr)(__out PwrshPluginWkr_Ptrs* wkrP #ifdef CORECLR -// Define the function pointer for the powershell entry point. -typedef int (STDMETHODCALLTYPE *MonadRunHelperFp)(int length, LPCWSTR* commands); - -// Define the function pointer for AssemblyLoadContext initializer. -typedef void (STDMETHODCALLTYPE *LoaderRunHelperFp)(LPCWSTR appPath); - unsigned int PowerShellCoreClrWorker::LaunchClr( _In_ LPCWSTR wszMonadVersion, _In_ LPCWSTR wszRuntimeVersion, @@ -54,34 +48,17 @@ unsigned int PowerShellCoreClrWorker::LoadWorkerCallbackPtrs( *pPluginException = NULL; - // Set the powershell custom assembly loader to be the default - LoaderRunHelperFp initDelegate = NULL; - HRESULT hr = hostWrapper->CreateDelegate( - "Microsoft.PowerShell.CoreCLR.AssemblyLoadContext, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", - "System.Management.Automation.PowerShellAssemblyLoadContextInitializer", - "SetPowerShellAssemblyLoadContext", - //(INT_PTR*)&initDelegate); - (void**)&initDelegate); - - if (FAILED(hr)) - { - output->DisplayMessage(false, g_CREATING_MSH_ENTRANCE_FAILED, hr); - } - else - { - initDelegate(hostEnvironment.GetHostDirectoryPathW()); - } - // Call into powershell entry point InitPluginWkrPtrsFuncPtr entryPointDelegate = NULL; // Create the function pointer for the managed entry point // It must be targeted at a static method in the managed code. - hr = hostWrapper->CreateDelegate( + HRESULT hr = hostWrapper->CreateDelegate( "System.Management.Automation, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35", "System.Management.Automation.Remoting.WSManPluginManagedEntryWrapper", "InitPlugin", (void**)&entryPointDelegate); + if (FAILED(hr)) { output->DisplayMessage(false, g_CREATING_MSH_ENTRANCE_FAILED, hr);