Пример #1
0
        public frmMain()
        {
            InitializeComponent();

            m_proc_enum    = new ProcessEnum();
            m_proc_handles = new ProcessHandles();
        }
Пример #2
0
        private void RefreshHandles()
        {
            if (1 != lvwProcesses.SelectedItems.Count)
            {
                return;
            }

            m_proc_handles.RefreshSystemHandles();
            ListViewItem lvi = lvwProcesses.SelectedItems[0];
            int          pid = int.Parse(lvi.SubItems[colPID.Index].Text);
            List <ProcessHandles.SYSTEM_HANDLE_INFORMATION> lst_handles = m_proc_handles.GetProcessHandles(pid);

            lvwHandles.BeginUpdate();
            lvwHandles.Items.Clear();

            foreach (ProcessHandles.SYSTEM_HANDLE_INFORMATION shi in lst_handles)
            {
                ProcessHandles.PROCESS_HANDLE_INFORMATION phi = m_proc_handles.GetProcessHandleInfo(shi.ProcessId, shi.Handle);
                string str_handle_name = ProcessHandles.UnicodeStringToString(phi.m_object_name_info.Name);
                if ("" == str_handle_name)
                {
                    continue;
                }

                ListViewItem lvi_shi = new ListViewItem(shi.ProcessId.ToString());
                lvi_shi.SubItems.Add("0x" + shi.Handle.ToString("X8"));
                lvi_shi.SubItems.Add(ProcessHandles.UnicodeStringToString(phi.m_object_type_info.Name));
                lvi_shi.SubItems.Add(str_handle_name);

                lvwHandles.Items.Add(lvi_shi);
            }

            lvwHandles.EndUpdate();
        }
Пример #3
0
        private void btnFind_Click(object sender, EventArgs e)
        {
            if ("" == txtHandleName.Text)
            {
                return;
            }

            m_proc_handles.RefreshSystemHandles();

            lvwHandles.BeginUpdate();
            lvwHandles.Items.Clear();

            pbStatus.Value   = 0;
            pbStatus.Maximum = m_proc_handles.HandleInfos.Length;
            Application.DoEvents();

            int n = 0;

            foreach (ProcessHandles.SYSTEM_HANDLE_INFORMATION shi in m_proc_handles.HandleInfos)
            {
                n++;
                if (0 == (n % 50))
                {
                    pbStatus.Value = n;
                    lblStatus.Text = n + " / " + pbStatus.Maximum;
                    Application.DoEvents();
                }

                ProcessHandles.PROCESS_HANDLE_INFORMATION phi = m_proc_handles.GetProcessHandleInfo(shi.ProcessId, shi.Handle);

                string handle_name = ProcessHandles.UnicodeStringToString(phi.m_object_name_info.Name);
                if (handle_name.IndexOf(txtHandleName.Text, StringComparison.OrdinalIgnoreCase) >= 0)
                {
                    ListViewItem lvi = new ListViewItem(shi.ProcessId.ToString());
                    lvi.SubItems.Add("0x" + shi.Handle.ToString("X8"));
                    lvi.SubItems.Add(ProcessHandles.UnicodeStringToString(phi.m_object_type_info.Name));
                    lvi.SubItems.Add(ProcessHandles.UnicodeStringToString(phi.m_object_name_info.Name));

                    lvwHandles.Items.Add(lvi);
                }
            }

            lvwHandles.EndUpdate();

            pbStatus.Value = 0;
            lblStatus.Text = n + " / " + pbStatus.Maximum;
        }