public void ProcMonThreadFunc()
 {
     while (__procMonThread_working)
     {
         Console.WriteLine("WRAP_RtProtectionDrv_NewProcMon");
         bool res = __RtProtectionInst.WRAP_RtProtectionDrv_NewProcMon();
         Console.WriteLine(res.ToString());
         if (res)
         {
             int _ParentId  = __RtProtectionInst.Get_ParentId();
             int _ProcessId = __RtProtectionInst.Get_ProcessId();
             int _Create    = __RtProtectionInst.Get_Create();
             if (_Create == 1)
             {
                 Process         newproc     = Process.GetProcessById(_ProcessId);
                 ProcListBoxItem newListItem = new ProcListBoxItem {
                     Name        = newproc.ProcessName,
                     ParentId    = _ParentId,
                     ProcessId   = _ProcessId,
                     procHandler = newproc
                 };
                 RTProtection_checkedListBox_Processes.Items.Insert(0, newListItem);
             }
             else
             {
                 foreach (var item in RTProtection_checkedListBox_Processes.Items.OfType <ProcListBoxItem>().ToList())
                 {
                     Console.WriteLine(item.ProcessId.ToString() + " " + _ProcessId.ToString());
                     if (item.ProcessId == _ProcessId)
                     {
                         RTProtection_checkedListBox_Processes.Items.Remove(item);
                         break;
                     }
                 }
             }
         }
     }
     __RtProtectionInst.WRAP_RtProtectionDrv_UnloadDriver();
     if (__RtProtectionInst.Get_loaded() == false)
     {
         RTProtection_Button_Activate.Text = "Activate";
     }
 }
        private void DynamicAnalyze_Button_UpdateProc_Click(object sender, EventArgs e)
        {
            DynamicAnalyze_checkedListBox_Processes.Items.Clear();

            Process[] processlist = Process.GetProcesses();

            foreach (Process proc in processlist)
            {
                Console.WriteLine("Process: {0} ID: {1}", proc.ProcessName, proc.Id);

                ProcListBoxItem newListItem = new ProcListBoxItem {
                    Name        = proc.ProcessName,
                    ParentId    = 0,
                    ProcessId   = proc.Id,
                    procHandler = proc
                };

                DynamicAnalyze_checkedListBox_Processes.Items.Insert(0, newListItem);
            }
        }
        private void RTProtection_Button_Update_Click(object sender, EventArgs e)
        {
            RTProtection_checkedListBox_Processes.Items.Clear();

            Process[] processlist = Process.GetProcesses();
            string    filtstr     = RTProtection_TextBox_Filter.Text;

            foreach (Process proc in processlist)
            {
                Console.WriteLine("Process: {0} ID: {1}", proc.ProcessName, proc.Id);
                if (filtstr != string.Empty)
                {
                    if (proc.ProcessName.Contains(filtstr))
                    {
                        ProcListBoxItem newListItem = new ProcListBoxItem {
                            Name        = proc.ProcessName,
                            ParentId    = 0,
                            ProcessId   = proc.Id,
                            procHandler = proc
                        };

                        RTProtection_checkedListBox_Processes.Items.Insert(0, newListItem);
                    }
                }
                else
                {
                    ProcListBoxItem newListItem = new ProcListBoxItem {
                        Name        = proc.ProcessName,
                        ParentId    = 0,
                        ProcessId   = proc.Id,
                        procHandler = proc
                    };

                    RTProtection_checkedListBox_Processes.Items.Insert(0, newListItem);
                }
            }
        }