Ejemplo n.º 1
0
 private static void AddToActivePlugins(IntPtr pluginContext, WSManPluginInstance plugin)
 {
     lock (s_activePlugins)
     {
         if (!s_activePlugins.ContainsKey(pluginContext))
         {
             s_activePlugins.Add(pluginContext, plugin);
             return;
         }
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// static func to take care of unmanaged to managed transitions.
        /// </summary>
        /// <param name="pluginContext"></param>
        /// <param name="requestDetails"></param>
        /// <param name="flags"></param>
        /// <param name="extraInfo"></param>
        /// <param name="startupInfo"></param>
        /// <param name="inboundShellInformation"></param>
        internal static void PerformWSManPluginShell(
            IntPtr pluginContext, // PVOID
            IntPtr requestDetails, // WSMAN_PLUGIN_REQUEST*
            int flags,
            string extraInfo,
            IntPtr startupInfo, // WSMAN_SHELL_STARTUP_INFO*
            IntPtr inboundShellInformation) // WSMAN_DATA*
        {
            WSManPluginInstance pluginToUse = GetFromActivePlugins(pluginContext);

            if (null == pluginToUse)
            {
                lock (s_activePlugins)
                {
                    pluginToUse = GetFromActivePlugins(pluginContext);
                    if (null == pluginToUse)
                    {
                        // create a new plugin
                        WSManPluginInstance mgdPlugin = new WSManPluginInstance();
                        AddToActivePlugins(pluginContext, mgdPlugin);
                        pluginToUse = mgdPlugin;
                    }
                }
            }

            // Marshal the incoming pointers into managed types prior to the call
            WSManNativeApi.WSManPluginRequest requestDetailsInstance = WSManNativeApi.WSManPluginRequest.UnMarshal(requestDetails);
            WSManNativeApi.WSManShellStartupInfo_UnToMan startupInfoInstance = WSManNativeApi.WSManShellStartupInfo_UnToMan.UnMarshal(startupInfo);
            WSManNativeApi.WSManData_UnToMan inboundShellInfo = WSManNativeApi.WSManData_UnToMan.UnMarshal(inboundShellInformation);

            pluginToUse.CreateShell(pluginContext, requestDetailsInstance, flags, extraInfo, startupInfoInstance, inboundShellInfo);
        }