Пример #1
0
        //-------------------------------------------------
        // CNode - Constructor
        //
        // This transfers data for the node information structure
        // into the class and loads the node's icon.
        //-------------------------------------------------
        internal CNode()
        {
            // Zero out all the info out of the structure
            m_sGuid                          = null;
            m_sHelpSection                   = null;
            m_sDisplayName                   = null;
            m_sIDName                        = null;
            m_oResults                       = null;
            m_aPropSheetPage                 = null;
            m_hModule                        = Marshal.GetHINSTANCE(this.GetType().Module);
            m_iResultNum                     = 0;
            m_iHScopeItem                    = 0;
            m_iData                          = 0;
            m_hPropertyPageRouter            = (IntPtr)(-1);
            m_iParentHScopeItem              = -1;
            m_sPropPageTemplate              = "IDD_WFCWRAPPERPROP";
            m_fAllowMultiSelectResults       = false;
            m_fInsertedChildrenOnExpand      = false;
            m_fStartResultRefresh            = false;
            m_fWantToMakePropertyPageVisible = false;
            m_fWantToRefreshResult           = false;

            // Set up the blank icon
            m_hBlankIcon      = CResourceStore.GetHIcon("blank_ico");
            m_iBlankIconIndex = CResourceStore.GetIconCookie(m_hBlankIcon);
        }// CNode
        }// class PropPagePairs

        internal CSharedAssemblies()
        {
            m_sGuid        = "96821C0B-CBE2-4dc9-AC52-756A3361B07F";
            m_sHelpSection = "";
            m_hIcon        = CResourceStore.GetHIcon("sharedassemblies_ico");
            DisplayName    = CResourceStore.GetString("CSharedAssemblies:DisplayName");
            Name           = "Assembly Cache";

            m_taskPad       = new CGenericTaskPad(this, "SHAREDASSEM_HTML");
            m_fReadShowHTML = false;

            m_olAssems = Fusion.ReadFusionCache();

            m_alResultPropPages = new ArrayList();


            // Set up the blank icon
            m_hBlankIcon      = CResourceStore.GetHIcon("blank_ico");
            m_iBlankIconIndex = CResourceStore.GetIconCookie(m_hBlankIcon);

            m_hGACIcon      = CResourceStore.GetHIcon("gac_ico");
            m_iGACIconIndex = CResourceStore.GetIconCookie(m_hGACIcon);

            m_hZAPIcon      = CResourceStore.GetHIcon("zap_ico");
            m_iZAPIconIndex = CResourceStore.GetIconCookie(m_hZAPIcon);

            m_fAllowMultiSelectResults = true;
        }// CSharedAssemblies
Пример #3
0
        internal CApplicationDepends(String sAppFile)
        {
            m_sGuid        = "96821C0B-CBE2-4dc9-AC52-756A3361B07F";
            m_sHelpSection = "";
            m_hIcon        = CResourceStore.GetHIcon("sharedassemblies_ico");
            DisplayName    = CResourceStore.GetString("CApplicationDepends:DisplayName");
            Name           = "Assembly Dependencies";

            m_taskPadWaiting = new CGenericTaskPad(this, "WAITINGDEPENDASSEM_HTML");
            m_taskPad        = new CGenericTaskPad(this, "DEPENDASSEM_HTML");

            m_fIKnowMyDependencies     = false;
            m_fAllowListView           = false;
            m_fAllowMultiSelectResults = true;


            m_fReadShowHTML = false;
            m_oResults      = m_taskPadWaiting;
            m_olAssems      = null;

            m_sAppFile = sAppFile;

            // Get icons for the assemblies we show
            m_hAssemIcon      = CResourceStore.GetHIcon("gac_ico");
            m_iAssemIconIndex = CResourceStore.GetIconCookie(m_hAssemIcon);


            // If we're not managed, then don't bother trying to have our dependencies
            // found
            if (!Fusion.isManaged(m_sAppFile))
            {
                m_taskPad              = new CGenericTaskPad(this, "UNMANAGEDDEPENDASSEM_HTML");
                m_oResults             = m_taskPad;
                m_fIKnowMyDependencies = true;
            }
            else
            {
                // Get ourselves in a queue to have our dependent assemblies discovered....
                if (m_alNodes == null)
                {
                    m_alNodes = ArrayList.Synchronized(new ArrayList());
                }

                m_alNodes.Add(this);

                if (m_thread == null)
                {
                    m_thread = new Thread(new ThreadStart(DependencyFinder));
                }
                if (!m_thread.IsAlive)
                {
                    m_thread.Priority = ThreadPriority.Lowest;
                    m_thread.Start();
                }
            }
        }// CApplicationDepends
Пример #4
0
        }// GetDisplayInfo

        //-------------------------------------------------
        // GetResultDisplayInfo
        //
        // This function will provide MMC with information on how
        // to display data items in the result pane. This function
        // is used to get data both for a column view and a list view.
        //-------------------------------------------------
        internal void GetResultDisplayInfo(ref RESULTDATAITEM ResultDataItem)
        {
            IColumnResultView crv = null;

            // See if we have info to display a column-view result
            if (m_oResults is IColumnResultView)
            {
                crv = (IColumnResultView)m_oResults;
            }

            // If we need a display name
            if ((ResultDataItem.mask & RDI.STR) > 0)
            {
                // See if MMC is requesting an item for the column view
                if (crv != null && (ResultDataItem.lParam >> 16) > 0)
                {
                    ResultDataItem.str = Marshal.StringToCoTaskMemUni(crv.getValues((ResultDataItem.lParam >> 16) - 1, ResultDataItem.nCol));
                }
                // Nope, it's just looking for the display name for the node
                else
                {
                    ResultDataItem.str = Marshal.StringToCoTaskMemUni(m_sDisplayName);
                }
            }
            // This snapin was set up so the node's image index is the
            // same as the node's cookie unless we're getting an image for a listview
            if ((ResultDataItem.mask & RDI.IMAGE) > 0)
            {
                if (crv != null && (ResultDataItem.lParam >> 16) > 0)
                {
                    ResultDataItem.nImage = crv.GetImageIndex((ResultDataItem.lParam >> 16) - 1);
                }
                else
                {
                    ResultDataItem.nImage = CResourceStore.GetIconCookie(IconHandle);
                }
            }

            if ((ResultDataItem.mask & RDI.PARAM) > 0)
            {
                ResultDataItem.lParam = m_iCookie;
            }

            // Don't know what this field is for, MSDN isn't clear
            // on it... just set it to 0 if we need to
            if ((ResultDataItem.mask & (uint)RDI.INDEX) > 0)
            {
                ResultDataItem.nIndex = 0;
            }

            // Reserved
            if ((ResultDataItem.mask & (uint)RDI.INDENT) > 0)
            {
                ResultDataItem.iIndent = 0;
            }
        }// GetResultDisplayInfo
Пример #5
0
        }// InsertChildren

        internal void InsertSpecificChild(int iChild)
        {
            SCOPEDATAITEM sdi = new SCOPEDATAITEM();

            CNode nChild = CNodeManager.GetNode(iChild);

            sdi.mask = SDI.STR |
                       SDI.PARAM |
                       SDI.PARENT |
                       SDI.IMAGE |
                       SDI.OPENIMAGE |
                       SDI.CHILDREN;

            // The image index is going to be the same as the cookie value
            sdi.nImage = CResourceStore.GetIconCookie(nChild.IconHandle);
            // The open image is the same as the closed image
            sdi.nOpenImage = sdi.nImage;
            sdi.relativeID = m_iHScopeItem;
            // We set displayname to -1 to initiate a callback for the string
            // (We need to do it this way... it's an MMCism)
            sdi.displayname = (IntPtr)(-1);

            sdi.lParam = nChild.Cookie;

            // The children field is set to either 0 or 1 (if it has children or not)
            sdi.cChildren = (nChild.NumChildren == 0)?0:1;

            // Once the item has been inserted, we're given the HScopeItem value for the node
            // MMC uses this value to uniquely identify the node. We'll store it for future
            // use.
            nChild.HScopeItem = CNodeManager.InsertItem(sdi);

            // We'll also put in the parent's HScopeItem
            nChild.m_iParentHScopeItem = HScopeItem;

            // Also, we can be slick and expand this child's node too

            // We don't care about perf savings after startup... do the expansion now
            // Also, if we have a non MMC host, we're not sure how it will behave
            // if it doesn't have all the nodes. Let's force the expand if we're not
            // running under MMC
            if (m_fInitialCreationDone || CNodeManager.Console is INonMMCHost)
            {
                // Expand this child
                CNodeManager.ExpandNodeNamespace(nChild.HScopeItem);
            }
            else if (Cookie == 0)
            {
                Thread t = new Thread(new ThreadStart(nChild.LazyExpand));
                t.Start();
            }
        }// InsertSpecificChild
        }// struct CustomPages

        internal CSinglePermissionSet(NamedPermissionSet permSet, PolicyLevel pl, bool fReadOnly)
        {
            base.ReadOnly   = fReadOnly;
            m_sGuid         = "E90A7E88-FB3C-4734-8245-0BEBCB4E6D63";
            m_sHelpSection  = "";
            m_fReadShowHTML = false;
            m_fDeleted      = false;
            m_pl            = pl;

            m_psetWrapper          = new CPSetWrapper();
            m_psetWrapper.PSet     = permSet;
            m_psetWrapper.PolLevel = m_pl;

            m_hIcon        = CResourceStore.GetHIcon("permissionset_ico");
            m_sDisplayName = permSet.Name;

            m_alCustomPropPages = new ArrayList();

            // Set up the icons we'll be displaying for each permission
            m_hRestrictedIcon  = CResourceStore.GetHIcon("permission_ico");
            m_iRestrictedIndex = CResourceStore.GetIconCookie(m_hRestrictedIcon);

            m_hUnRestrictedIcon  = CResourceStore.GetHIcon("permission_ico");
            m_iUnRestrictedIndex = CResourceStore.GetIconCookie(m_hUnRestrictedIcon);

            m_fReadOnlyPermissionSet = false;
            try
            {
                // This line will throw an exception if we're trying to do this with a
                // reserved permission set
                m_pl.ChangeNamedPermissionSet(permSet.Name, permSet);
            }
            catch (Exception)
            {
                m_fReadOnlyPermissionSet = true;
            }

            m_taskpad = new CSinglePermSetTaskPad(this);

            m_oResults       = m_taskpad;
            m_aPropSheetPage = null;

            // Get the permissions
            GenerateGivenPermissionsStringList();

            m_permProps = null;
        }// CSinglePermissionSet
        internal CTrustedAssemblies(PolicyLevel pl, bool fReadOnly)
        {
            ReadOnly = fReadOnly;

            m_sGuid          = "E519DA92-C787-4abc-BF84-60BF9CD6A7E6";
            m_sHelpSection   = "";
            m_hIcon          = CResourceStore.GetHIcon("policyassemblies_ico");
            m_sDisplayName   = CResourceStore.GetString("CTrustedAssemblies:DisplayName");
            m_aPropSheetPage = null;
            m_pl             = pl;
            m_ol             = null;

            m_fReadShowHTML = false;


            // Set up the icon
            m_hTrustedIcon      = CResourceStore.GetHIcon("policyassembly_ico");
            m_iTrustedIconIndex = CResourceStore.GetIconCookie(m_hTrustedIcon);
        }// CTrustedAssemblies
Пример #8
0
        }// CVersionPolicy (String)

        private void Setup(String sConfigFile)
        {
            m_sGuid          = "1F84E89D-6357-47c0-AA50-F1F438A7EA6E";
            m_sHelpSection   = "";
            m_hIcon          = CResourceStore.GetHIcon("configassemblies_ico");
            m_oResults       = this;
            DisplayName      = CResourceStore.GetString("CVersionPolicy:DisplayName");
            Name             = "Configured Assemblies";
            m_aPropSheetPage = null;
            m_taskPad        = new CVersionPolicyTaskPad(this, sConfigFile == null);
            m_fReadShowHTML  = false;

            m_ol          = null;
            m_sConfigFile = sConfigFile;

            m_fAllowMultiSelectResults = true;

            m_alResultPropPages = new ArrayList();

            m_hGACIcon      = CResourceStore.GetHIcon("gac_ico");
            m_iGACIconIndex = CResourceStore.GetIconCookie(m_hGACIcon);
        }// Setup
Пример #9
0
        }// CData

        //-------------------------------------------------
        // Initialize
        //
        // This function is responsible for recieving the
        // MMC Console interface, and I also have it inserting
        // all the images MMC will need to display the snapin
        //-------------------------------------------------
        public void Initialize(Object pUnknown)
        {
            try
            {
                m_ucsole          = (IConsole2)pUnknown;
                m_ucsoleNameSpace = (IConsoleNameSpace2)pUnknown;
            }
            catch (Exception)
            {
                // If this fails, it's because we're not on MMC 1.2 or later
                MessageBox(0,
                           CResourceStore.GetString("CData:RequireVersionofMMC"),
                           CResourceStore.GetString("CData:RequireVersionofMMCTitle"),
                           MB.ICONEXCLAMATION);
                return;
            }


            CNodeManager.Console = m_ucsole;
            IntPtr hWnd;

            m_ucsole.GetMainWindow(out hWnd);
            CNodeManager.MMChWnd = hWnd;

            CNodeManager.CNamespace = m_ucsoleNameSpace;

            // Now we'll add the images we need for the snapin
            IImageList il = null;

            m_ucsole.QueryScopeImageList(out il);

            // ALL icons that need to be displayed in the lefthand pane MUST be
            // 'registered' here

            if (il != null)
            {
                il.ImageListSetIcon(CResourceStore.GetHIcon("NETappicon_ico"),
                                    CResourceStore.GetIconCookie("NETappicon_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("mycomputer_ico"),
                                    CResourceStore.GetIconCookie("mycomputer_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("configassemblies_ico"),
                                    CResourceStore.GetIconCookie("configassemblies_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("enterprisepolicy_ico"),
                                    CResourceStore.GetIconCookie("enterprisepolicy_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("machinepolicy_ico"),
                                    CResourceStore.GetIconCookie("machinepolicy_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("userpolicy_ico"),
                                    CResourceStore.GetIconCookie("userpolicy_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("codegroups_ico"),
                                    CResourceStore.GetIconCookie("codegroups_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("singlecodegroup_ico"),
                                    CResourceStore.GetIconCookie("singlecodegroup_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("customcodegroup_ico"),
                                    CResourceStore.GetIconCookie("customcodegroup_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("permissionsets_ico"),
                                    CResourceStore.GetIconCookie("permissionsets_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("permissionset_ico"),
                                    CResourceStore.GetIconCookie("permissionset_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("policyassemblies_ico"),
                                    CResourceStore.GetIconCookie("policyassemblies_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("assemblies_ico"),
                                    CResourceStore.GetIconCookie("assemblies_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("sharedassemblies_ico"),
                                    CResourceStore.GetIconCookie("sharedassemblies_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("remoting_ico"),
                                    CResourceStore.GetIconCookie("remoting_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("security_ico"),
                                    CResourceStore.GetIconCookie("security_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("applications_ico"),
                                    CResourceStore.GetIconCookie("applications_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("application_ico"),
                                    CResourceStore.GetIconCookie("application_ico"));

                il.ImageListSetIcon(CResourceStore.GetHIcon("readonlypolicy_ico"),
                                    CResourceStore.GetIconCookie("readonlypolicy_ico"));
            }
        }// Initialize
Пример #10
0
        }// Initialize

        //-------------------------------------------------
        // Notify
        //
        // This is where most of the interesting stuff happens.
        // Whenever MMC needs something from the snapin, it will
        // send a message to Notify, and notify is responsible
        // to take care (or delegate) whatever MMC wants
        //-------------------------------------------------
        public int Notify(IntPtr lpDataObject, uint aevent, IntPtr arg, IntPtr param)
        {
            // We don't handle any of the special data objects here
            if (lpDataObject == (IntPtr)DOBJ.CUSTOMOCX || lpDataObject == (IntPtr)DOBJ.CUSTOMWEB)
            {
                return(HRESULT.S_FALSE);
            }

            IDataObject ido = null;

            if (lpDataObject != (IntPtr)0)
            {
                ido = (IDataObject)Marshal.GetObjectForIUnknown(lpDataObject);
            }

            CDO Data; // This will hold the object MMC wants action performed on

            // lpDataObject is just a CDO... we're going to obtain the CDO interface.
            // if lpDataObject is null, then there needs to be action performed on the root
            // node.
            if (ido != null)
            {
                Data = (CDO)ido;
            }
            else
            {
                CNode node = CNodeManager.GetNode(CNodeManager.RootNodeCookie);
                Data = new CDO(node);
            }

            switch (aevent)
            {
            // The user clicked the 'forward' or 'back' button on the MMC browser.
            // We need to sync up our node to the new result view
            case MMCN.RESTORE_VIEW:
                return(Data.Node.onRestoreView((MMC_RESTORE_VIEW)Marshal.PtrToStructure(arg, typeof(MMC_RESTORE_VIEW)), param));


            // We're being asked if we will accept an item to be pasted
            // (Used here to tell MMC if this node is a valid drag-and-drop
            // location)
            case MMCN.QUERY_PASTE:
                // See if it's asking about result items or scope items
                return(Data.Node.doAcceptPaste((IDataObject)Marshal.GetObjectForIUnknown((IntPtr)arg)));

            // We're being given an item to paste. (Used here to tell MMC that
            // something is being dropped here from a drag and drop operation)
            case MMCN.PASTE:
                return(Data.Node.Paste((IDataObject)Marshal.GetObjectForIUnknown((IntPtr)arg)));

            // The selected item needs to show something in the result pane
            case MMCN.SHOW:
                // If we're selecting this item
                if ((uint)arg == 1)
                {
                    CNodeManager.SelectedNode = Data.Node;
                }
                Data.Node.onShow(m_ucsole, arg, param);
                break;

            // If an item is selected, we should set flags for verbs available
            // for the item (from the dropdown menu)
            case MMCN.SELECT:

                bool fEnablePropPages = false;
                // See if this is selected from the result view
                if (((uint)arg & 0x0000FFFF) == 0)
                {
                    // See if we selected it or de-selected it
                    if (((uint)arg & 0xFFFF0000) == 0)
                    {
                        Data.Node.ResultItemUnSelected(m_ucsole, Data.Data);
                    }
                    else
                    {
                        Data.Node.ResultItemSelected(m_ucsole, Data.Data);
                    }


                    // Let's see if this result item has a property page
                    if (Data.Node.DoesResultHavePropertyPage(Data.Data))
                    {
                        fEnablePropPages = true;
                    }
                }
                // This item was selected in the scope view
                else
                if (Data.Node.HavePropertyPages)
                {
                    fEnablePropPages = true;
                }


                IConsoleVerb icv;
                // Get the IConsoleVerb interface from MMC
                m_ucsole.QueryConsoleVerb(out icv);

                // See if we need to enable then property sheets item on the popup menu
                if (fEnablePropPages)
                {
                    icv.SetVerbState(MMC_VERB.PROPERTIES, MMC_BUTTON_STATE.ENABLED, 1);
                }
                else
                {
                    icv.SetVerbState(MMC_VERB.PROPERTIES, MMC_BUTTON_STATE.ENABLED, 0);
                }


                // We'll only call this onSelect method if the user selected the
                // scope item
                if (((uint)arg & 0x0000FFFF) > 0 && ((uint)arg & 0xFFFF0000) > 0)
                {
                    icv.SetVerbState(MMC_VERB.PASTE, MMC_BUTTON_STATE.ENABLED, 1);
                    Data.Node.onSelect(icv);
                }
                break;

            // This is to add images for the result pane
            case MMCN.ADD_IMAGES:
                // arg actually contains the IImageList interface. We need to tell
                // C# that it is a Object and not a integer.

                IImageList il = (IImageList)Marshal.GetObjectForIUnknown((IntPtr)arg);

                // param contains the HScopeItem. Let's get the node it represents
                CNode nLuckyGuy = CNodeManager.GetNodeByHScope((int)param);

                il.ImageListSetIcon(nLuckyGuy.IconHandle, CResourceStore.GetIconCookie(nLuckyGuy.IconHandle));

                // Now add all the children images
                CNode nChild = null;
                for (int i = 0; i < nLuckyGuy.NumChildren; i++)
                {
                    nChild = CNodeManager.GetNode(nLuckyGuy.Child[i]);
                    il.ImageListSetIcon(nChild.IconHandle, CResourceStore.GetIconCookie(nChild.IconHandle));
                }

                // Now add any images that the node might have for it's listview
                if (nLuckyGuy.m_oResults != null && nLuckyGuy.m_oResults is IColumnResultView)
                {
                    ((IColumnResultView)nLuckyGuy.m_oResults).AddImages(ref il);
                }

                break;

            // The user double clicked on something
            case MMCN.DBLCLICK:
                return(Data.Node.onDoubleClick(Data.Data));

            case MMCN.DELETE:
                return(Data.Node.onDelete(Data.Data));

            default:
                // We don't support the Notification message we got
                return(HRESULT.S_FALSE);
            }
            return(HRESULT.S_OK);
        }// Notify