Beispiel #1
0
        private void MenuItemContextOpenFileLocation_Click(object sender, EventArgs e)
        {
            int    pid  = (int)listViewInternetConnectedProcesses.SelectedItems[0].Tag;
            string path = ProcessMainModuleFilePath.GetPath(pid);

            if (File.Exists(path))
            {
                Process.Start("explorer.exe", "/select," + path);
            }
        }
Beispiel #2
0
        private void Block(int PID)
        {
            string path = ProcessMainModuleFilePath.GetPath(PID);

            if (path == null)
            {
                Logger.Write("Block(): Can't find path for the process. Probably an internal Windows process.");
                new MessageBoxEx("ProgCop Warning", "Can't find path for the process. Probably an internal Windows process.",
                                 MessageBoxExType.Warning).ShowDialog(this);

                return;
            }

            var rule = FirewallManager.Instance.CreateApplicationRule(FirewallProfiles.Domain | FirewallProfiles.Private | FirewallProfiles.Public,
                                                                      @"ProgCop Rule " + Guid.NewGuid().ToString("B"),
                                                                      FirewallAction.Block, path);;

            rule.Direction = FirewallDirection.Outbound;
            rule.Protocol  = FirewallProtocol.Any;

            FirewallManager.Instance.Rules.Add(rule);
            string processName = Process.GetProcessById(PID).ProcessName;

            ListViewItem itemNew = new ListViewItem(new string[] { path, processName, "BLOCKED" });

            itemNew.Tag = rule;

            //We use this in unblock to be able to remove item from blocked list
            itemNew.Name      = processName;
            itemNew.ForeColor = Color.Green;
            listView1BlockedApplications.Items.Add(itemNew);



            if (!pBlockedProcessList.ContainsProcessNamed(processName))
            {
                pBlockedProcessList.Add(new BlockedProcess(path, processName, true));
            }
        }