Exemplo n.º 1
0
        private void RefreshProcesses()
        {
            WinformsProcessesCombobox.Enabled = false;

            m_Pid = new Dictionary <uint, uint>();
            NM.EnumWindowsProc WindowsGetProcessesCallback = new NM.EnumWindowsProc(EnumProcToGetProcesses);
            NM.EnumWindows(WindowsGetProcessesCallback, IntPtr.Zero);

            Process[] pc = Process.GetProcesses();

            ListOfProcesses = new Dictionary <Process, string>();
            ListOfProcesses.Add(Process.GetCurrentProcess(), "");

            foreach (Process p in pc)
            {
                if (p.Id != Process.GetCurrentProcess().Id)
                {
                    if (m_Pid.ContainsKey((uint)p.Id))
                    {
                        Dictionary <string, string> ProcessModules = Modules.Get(p);

                        foreach (KeyValuePair <string, string> Module in ProcessModules)
                        {
                            // Does the process reference winforms
                            if (Module.Value == "System.Windows.Forms" || Module.Value == "System.Windows.Forms.ni")
                            {
                                // Does the process use .NET 4.x
                                if (Module.Key.Contains(@"\v4.") || Module.Key.Contains(@"\NativeImages_v4."))
                                {
                                    ListOfProcesses.Add(p, p.ProcessName);
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            WinformsProcessesCombobox.DataSource    = new BindingSource(ListOfProcesses, null);
            WinformsProcessesCombobox.DisplayMember = "Value";
            WinformsProcessesCombobox.ValueMember   = "Key";

            foreach (KeyValuePair <Process, string> cbi in WinformsProcessesCombobox.Items)
            {
                if (cbi.Key.Id == m_CurrentAttached.Key.Id)
                {
                    WinformsProcessesCombobox.SelectedItem = cbi;
                    break;
                }
            }
            WinformsProcessesCombobox.Enabled = true;
        }
Exemplo n.º 2
0
        private unsafe void GetToolTip(Message *ptrMessage, int messageNumber)
        {
            //must be first message
            if (messageNumber != 1)
            {
                throw new Exception("GetToolTip must be first message");
            }

            // p1  = handle
            IntPtr handle = GetParameterIntPtr(ptrMessage, 0);

            CleanUpMessage(ptrMessage);

            NM.EnumWindowsProc windowsToGetToolTipsCallback = new NM.EnumWindowsProc(EnumWindowsToGetToolTips);

            m_ToolTipWindows = new List <IntPtr>();
            NM.EnumWindows(windowsToGetToolTipsCallback, IntPtr.Zero);

            IntPtr    toolTipHandle    = IntPtr.Zero;
            string    toolTipTitle     = null;
            Rectangle toolTipRectangle = new Rectangle(0, 0, 0, 0);

            foreach (IntPtr hWnd in m_ToolTipWindows)
            {
                NM.ToolInfo info = NM.GetToolInfo(hWnd, TimeOut);

                if (info.hWnd == handle)
                {
                    //we have the tooltip so return infomation about it
                    toolTipHandle = hWnd;
                    toolTipTitle  = GetWindowTextViaWindowMessage(toolTipHandle);

                    NM.tagRect windowPosition;
                    NM.tagRect windowSize;
                    NM.GetWindowRect(toolTipHandle, out windowPosition);
                    windowSize = NM.GetClipBox(toolTipHandle);

                    toolTipRectangle = new Rectangle(windowPosition.left, windowPosition.top, windowSize.right, windowSize.bottom);
                    break;
                }
            }

            AddReturnValue(new Parameter(this, toolTipHandle));
            AddReturnValue(new Parameter(this, toolTipTitle));
            AddReturnValue(new Parameter(this, toolTipRectangle.X));
            AddReturnValue(new Parameter(this, toolTipRectangle.Y));
            AddReturnValue(new Parameter(this, toolTipRectangle.Width));
            AddReturnValue(new Parameter(this, toolTipRectangle.Height));
        }
Exemplo n.º 3
0
        private void BuildTree()
        {
            LocateButton.Enabled = false;

            //store a temp copy of m_Identity
            ControlIdentifier temp = m_Identity;

            WindowTree.Nodes.Clear();
            PropertyListbox.Items.Clear();
            m_CurrentAttached = (KeyValuePair <Process, string>)WinformsProcessesCombobox.SelectedItem;

            if (m_CurrentAttached.Key.HasExited)
            {
                WinformsProcessesCombobox.SelectedIndex = 0;
                Populate();
            }
            else
            {
                if (m_CurrentAttached.Key.Id != Process.GetCurrentProcess().Id)
                {
                    ListOfTopLevelWindows = new Dictionary <IntPtr, string>();

                    NM.EnumWindowsProc WindowsCallback = new NM.EnumWindowsProc(EnumProc);

                    if (m_APE != null)
                    {
                        m_APE.RemoveFileMapping();
                    }

                    if (AppDomainComboBox.Enabled)
                    {
                        string NewDomain = AppDomainComboBox.SelectedItem.ToString();
                        m_APE = new APEIPC(m_CurrentAttached.Key, NewDomain);
                    }
                    else
                    {
                        m_APE = new APEIPC(m_CurrentAttached.Key);
                    }
                    m_APE.TimeOut = 0;

                    GC.Collect();
                    GC.WaitForPendingFinalizers();

                    NM.EnumWindows(WindowsCallback, new IntPtr(m_CurrentAttached.Key.Id));
                }
            }
            //restore m_Identity
            m_Identity = temp;
        }