Exemple #1
0
        public void StartCapture(Process[] processes, Softwall.Rule[] softwallRules, Device[] devices, IProgressFeedback progress)
        {
            this.processes = processes;
            this.softwallRules = softwallRules;
            this.devices = devices;
            this.progress = progress;

            Thread th = new Thread(StartCaptureThread);
            th.Start();
        }
Exemple #2
0
        public bool GetSelection (out Process[] processes, out Device[] devices, out bool restartDevices)
        {
            List<Process> procList = new List<Process> ();
            List<Device> devList = new List<Device> ();

            if (ShowDialog() == DialogResult.OK)
            {
                foreach (ListViewItem item in processView.Items)
                {
                    if (item.Checked)
                        procList.Add (item.Tag as Process);
                }

                foreach (ListViewItem item in usbDevView.Items)
                {
                    if (item.Checked)
                        devList.Add (item.Tag as Device);
                }
            }

            processes = procList.ToArray ();
            devices = devList.ToArray ();
            restartDevices = restartDevicesCheckBox.Checked;

            return (processes.Length > 0 || devices.Length > 0);
        }
Exemple #3
-1
        public static Device FromDevInfo (IntPtr devInfo, WinApi.SP_DEVINFO_DATA devInfoData)
        {
            Device device = null;

            string name = null;
            string hardwareId = null;
            string physicalDeviceObjectName = null;
            UInt32 capabilities = 0;

            byte[] buf = new byte[1024];
            uint reqBufSize;

            if (WinApi.SetupDiGetDeviceRegistryProperty (devInfo, ref devInfoData, WinApi.SPDRP_FRIENDLYNAME, IntPtr.Zero, buf, (uint) buf.Length, out reqBufSize))
            {
                name = WinApi.ByteArrayToString (buf);
            }

            if (name == null)
            {
                if (WinApi.SetupDiGetDeviceRegistryProperty (devInfo, ref devInfoData, WinApi.SPDRP_DEVICEDESC, IntPtr.Zero, buf, (uint)buf.Length, out reqBufSize))
                {
                    name = WinApi.ByteArrayToString (buf);
                }
            }

            if (WinApi.SetupDiGetDeviceRegistryProperty (devInfo, ref devInfoData, WinApi.SPDRP_HARDWAREID, IntPtr.Zero, buf, (uint)buf.Length, out reqBufSize))
            {
                string[] tokens = WinApi.MarshalMultiStringToStringArray (buf);
                hardwareId = String.Join (";", tokens);
            }

            if (WinApi.SetupDiGetDeviceRegistryProperty (devInfo, ref devInfoData, WinApi.SPDRP_PHYSICAL_DEVICE_OBJECT_NAME, IntPtr.Zero, buf, (uint)buf.Length, out reqBufSize))
            {
                physicalDeviceObjectName = WinApi.ByteArrayToString (buf);
            }

            if (WinApi.SetupDiGetDeviceRegistryProperty (devInfo, ref devInfoData, WinApi.SPDRP_CAPABILITIES, IntPtr.Zero, buf, (uint)buf.Length, out reqBufSize))
            {
                capabilities = BitConverter.ToUInt32 (buf, 0);
            }

            if (name != null && hardwareId != null)
            {
                device = new Device (devInfo, devInfoData, name, hardwareId, physicalDeviceObjectName, capabilities);
            }

            return device;
        }