コード例 #1
0
 // Token: 0x06000235 RID: 565 RVA: 0x00016980 File Offset: 0x00014B80
 private static void GetAndroidDevices(TreeViewUsbItem item, ref List <UsbNodeConnectionInformation> outItems)
 {
     try
     {
         if (item.Children != null && item.Children.Count > 0)
         {
             List <TreeViewUsbItem> children = item.Children;
             using (List <TreeViewUsbItem> .Enumerator enumerator = children.GetEnumerator())
             {
                 while (enumerator.MoveNext())
                 {
                     TreeViewUsbItem item2 = enumerator.Current;
                     UsbDevice.GetAndroidDevices(item2, ref outItems);
                 }
                 goto IL_1DF;
             }
         }
         UsbNodeConnectionInformation item3 = (UsbNodeConnectionInformation)item.Data;
         if (item3.DeviceDescriptor.Manufacturer != null && (item3.DeviceDescriptor.Product.ToLower() == "android" || item3.DeviceDescriptor.Product.ToLower() == "fastboot" || item3.DeviceDescriptor.Product.ToLower() == "intel android ad" || item3.DeviceDescriptor.Manufacturer.ToLower().IndexOf("xiaomi inc") >= 0 || Convert.ToInt32(item3.DeviceDescriptor.idVendor).ToString("x4") == "8087" || Convert.ToInt32(item3.DeviceDescriptor.idVendor).ToString("x4") == "0955" || Convert.ToInt32(item3.DeviceDescriptor.idVendor).ToString("x4").ToLower() == "05c6" || Convert.ToInt32(item3.DeviceDescriptor.idVendor).ToString("x4").ToLower() == "18d1" || Convert.ToInt32(item3.DeviceDescriptor.idVendor).ToString("x4") == "2717"))
         {
             outItems.Add(item3);
         }
         IL_1DF :;
     }
     catch (Exception ex)
     {
         Log.w(ex.Message + " " + ex.StackTrace);
     }
 }
コード例 #2
0
 // Token: 0x06000237 RID: 567 RVA: 0x00016C24 File Offset: 0x00014E24
 private static TreeViewUsbItem GetLastChild(TreeViewUsbItem item, string[] deviceSn, ref List <UsbNodeConnectionInformation> outItems)
 {
     if (item.Children != null && item.Children.Count > 0)
     {
         List <TreeViewUsbItem> children = item.Children;
         using (List <TreeViewUsbItem> .Enumerator enumerator = children.GetEnumerator())
         {
             while (enumerator.MoveNext())
             {
                 TreeViewUsbItem item2 = enumerator.Current;
                 UsbDevice.GetLastChild(item2, deviceSn, ref outItems);
             }
             return(item);
         }
     }
     try
     {
         UsbNodeConnectionInformation item3 = (UsbNodeConnectionInformation)item.Data;
         if (item.Data != null && deviceSn.ToList <string>().Contains(item3.DeviceDescriptor.SerialNumber))
         {
             outItems.Add(item3);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         Log.w(ex.Message + " " + ex.StackTrace);
     }
     return(item);
 }
コード例 #3
0
        /// <summary>
        /// 增加USB节点连接信息
        /// </summary>
        /// <param name="Items">要增加的列表</param>
        /// <param name="Info">要增加的信息</param>
        private static void Add(ref List <ListViewUsbItem> Items, UsbNodeConnectionInformation Info)
        {
            Items.Add(new ListViewUsbItem("DevicePath", Info.DevicePath));
            Items.Add(new ListViewUsbItem("ConnectionIndex", Info.ConnectionIndex.ToString()));
            Items.Add(new ListViewUsbItem("CurrentConfigurationValue", "0x" + Info.CurrentConfigurationValue.ToString("X2")));
            Items.Add(new ListViewUsbItem("Speed", ((USB_DEVICE_SPEED)Info.Speed).ToString()));
            Items.Add(new ListViewUsbItem("DeviceIsHub", Info.DeviceIsHub.ToString()));
            Items.Add(new ListViewUsbItem("DeviceAddress", Info.DeviceAddress.ToString()));
            Items.Add(new ListViewUsbItem("NumberOfOpenPipes", Info.NumberOfOpenPipes.ToString()));

            // 设备描述符
            Items.Add(new ListViewUsbItem(null, null));
            Items.Add(new ListViewUsbItem("Device Descriptor:", null));
            Items.Add(new ListViewUsbItem("DescriptorType", "0x" + Info.DeviceDescriptor.bDescriptorType.ToString("X2")));
            Items.Add(new ListViewUsbItem("UsbVersion", Info.DeviceDescriptor.UsbVersion));
            Items.Add(new ListViewUsbItem("DeviceClass", "0x" + Info.DeviceDescriptor.bDeviceClass.ToString("X2")));
            Items.Add(new ListViewUsbItem("DeviceSubClass", "0x" + Info.DeviceDescriptor.bDeviceSubClass.ToString("X2")));
            Items.Add(new ListViewUsbItem("DeviceProtocol", "0x" + Info.DeviceDescriptor.bDeviceProtocol.ToString("X2")));
            Items.Add(new ListViewUsbItem("MaxPacketSize0", Info.DeviceDescriptor.bMaxPacketSize0.ToString()));
            Items.Add(new ListViewUsbItem("idVendor", "0x" + Info.DeviceDescriptor.idVendor.ToString("X4")));
            Items.Add(new ListViewUsbItem("idProduct", "0x" + Info.DeviceDescriptor.idProduct.ToString("X4")));
            Items.Add(new ListViewUsbItem("DeviceVersion", Info.DeviceDescriptor.DeviceVersion));
            Items.Add(new ListViewUsbItem("Manufacturer", Info.DeviceDescriptor.Manufacturer));
            Items.Add(new ListViewUsbItem("Product", Info.DeviceDescriptor.Product));
            Items.Add(new ListViewUsbItem("SerialNumber", Info.DeviceDescriptor.SerialNumber));
            Items.Add(new ListViewUsbItem("NumConfigurations", Info.DeviceDescriptor.bNumConfigurations.ToString()));

            // 管道信息
            foreach (UsbPipeInfo Pipe in Info.PipeList)
            {
                Items.Add(new ListViewUsbItem(null, null));
                Items.Add(new ListViewUsbItem("Endpoint Descriptor:", null));
                Items.Add(new ListViewUsbItem("ScheduleOffset", Pipe.ScheduleOffset.ToString()));
                Items.Add(new ListViewUsbItem("DescriptorType", "0x" + Pipe.bDescriptorType.ToString("X2")));
                Items.Add(new ListViewUsbItem("EndpointAddress", "0x" + Pipe.bEndpointAddress.ToString("X2")));
                Items.Add(new ListViewUsbItem("bmAttributes", "0x" + Pipe.bmAttributes.ToString("X2")));
                Items.Add(new ListViewUsbItem("MaxPacketSize", Pipe.wMaxPacketSize.ToString()));
                Items.Add(new ListViewUsbItem("Interval", "0x" + Pipe.bInterval.ToString("X2")));
            }
        }
コード例 #4
0
        /// <summary>
        /// 生成USB属性列表
        /// </summary>
        /// <param name="Data">用于生成列表的USB数据</param>
        /// <returns>属性列表</returns>
        public static List <ListViewUsbItem> UsbDetail(Object Data)
        {
            if (Data is String)
            {   // 机器名
                String Info = Data as String;
                if (!String.IsNullOrEmpty(Info))
                {
                    String[] Content = Info.Split(new Char[] { ':' });
                    if (Content.Length == 2)
                    {
                        return(new List <ListViewUsbItem>(1)
                        {
                            new ListViewUsbItem(Content[0], Content[1])
                        });
                    }
                }
            }
            else if (Data is HostControllerInfo)
            {   // 主控制器信息
                HostControllerInfo Info = (HostControllerInfo)Data;
                return(new List <ListViewUsbItem>(3)
                {
                    new ListViewUsbItem("Name", Info.Name),
                    new ListViewUsbItem("PNPDeviceID", Info.PNPDeviceID),
                    new ListViewUsbItem("HcdDriverKeyName", Info.HcdDriverKeyName)
                });
            }
            else if (Data is UsbNodeInformation)
            {   // USB节点信息
                UsbNodeInformation Info = (UsbNodeInformation)Data;

                List <ListViewUsbItem> Items = new List <ListViewUsbItem>();
                Add(ref Items, Info);
                return(Items);
            }
            else if (Data is UsbNodeConnectionInformation)
            {   // USB节点连接信息
                UsbNodeConnectionInformation Info = (UsbNodeConnectionInformation)Data;
                if (Info.ConnectionStatus != USB_CONNECTION_STATUS.DeviceConnected)
                {
                    return(null);
                }

                List <ListViewUsbItem> Items = new List <ListViewUsbItem>();
                Add(ref Items, Info);
                return(Items);
            }
            else if (Data is ExternalHubInfo)
            {   // 外部Hub信息
                ExternalHubInfo Info = (ExternalHubInfo)Data;

                List <ListViewUsbItem> Items = new List <ListViewUsbItem>();

                // 加入USB节点信息
                Items.Add(new ListViewUsbItem("Node Information:", null));
                Add(ref Items, Info.NodeInfo);

                // 加入USB节点连接信息
                Items.Add(new ListViewUsbItem(null, null));
                Items.Add(new ListViewUsbItem("Node Connection Information:", null));
                Add(ref Items, Info.NodeConnectionInfo);

                return(Items);
            }

            return(null);
        }
コード例 #5
0
 // Token: 0x060000CD RID: 205 RVA: 0x0000B968 File Offset: 0x00009B68
 private static List <TreeViewUsbItem> AddPortNode(string HubPath, int NumberOfPorts)
 {
     UsbNodeConnectionInformation[] usbNodeConnectionInformation = USB.GetUsbNodeConnectionInformation(HubPath, NumberOfPorts);
     if (usbNodeConnectionInformation != null)
     {
         List <TreeViewUsbItem> list = new List <TreeViewUsbItem>(NumberOfPorts);
         foreach (UsbNodeConnectionInformation usbNodeConnectionInformation2 in usbNodeConnectionInformation)
         {
             TreeViewUsbItem treeViewUsbItem = new TreeViewUsbItem();
             treeViewUsbItem.Name = string.Concat(new object[]
             {
                 "[Port",
                 usbNodeConnectionInformation2.ConnectionIndex,
                 "]",
                 usbNodeConnectionInformation2.ConnectionStatus
             });
             treeViewUsbItem.Data     = usbNodeConnectionInformation2;
             treeViewUsbItem.Children = null;
             if (usbNodeConnectionInformation2.ConnectionStatus == USB_CONNECTION_STATUS.DeviceConnected)
             {
                 TreeViewUsbItem.ConnectedDevices++;
                 if (!string.IsNullOrEmpty(usbNodeConnectionInformation2.DeviceDescriptor.Product))
                 {
                     treeViewUsbItem.Name = treeViewUsbItem.Name + ": " + usbNodeConnectionInformation2.DeviceDescriptor.Product;
                 }
                 if (usbNodeConnectionInformation2.DeviceIsHub)
                 {
                     string externalHubPath = USB.GetExternalHubPath(usbNodeConnectionInformation2.DevicePath, usbNodeConnectionInformation2.ConnectionIndex);
                     UsbNodeInformation[] usbNodeInformation = USB.GetUsbNodeInformation(externalHubPath);
                     if (usbNodeInformation != null)
                     {
                         treeViewUsbItem.Data = new ExternalHubInfo
                         {
                             NodeInfo           = usbNodeInformation[0],
                             NodeConnectionInfo = usbNodeConnectionInformation2
                         };
                         if (usbNodeInformation[0].NodeType == USB_HUB_NODE.UsbHub)
                         {
                             treeViewUsbItem.Children = TreeViewUsbItem.AddPortNode(externalHubPath, usbNodeInformation[0].NumberOfPorts);
                             foreach (TreeViewUsbItem treeViewUsbItem2 in treeViewUsbItem.Children)
                             {
                                 try
                                 {
                                     if (treeViewUsbItem2 != null && treeViewUsbItem2.Data != null)
                                     {
                                         UsbNodeConnectionInformation usbNodeConnectionInformation3 = (UsbNodeConnectionInformation)treeViewUsbItem2.Data;
                                         int connectionIndex = usbNodeConnectionInformation2.ConnectionIndex;
                                         usbNodeConnectionInformation3.ConnectionIndex = Convert.ToInt32(connectionIndex.ToString() + usbNodeConnectionInformation3.ConnectionIndex.ToString());
                                         treeViewUsbItem2.Data = usbNodeConnectionInformation3;
                                         treeViewUsbItem2.Name = string.Concat(new object[]
                                         {
                                             "[Port",
                                             usbNodeConnectionInformation3.ConnectionIndex,
                                             "]",
                                             usbNodeConnectionInformation2.ConnectionStatus
                                         });
                                     }
                                 }
                                 catch (Exception ex)
                                 {
                                     Log.w(ex.Message + ":" + ex.StackTrace);
                                 }
                             }
                         }
                         if (string.IsNullOrEmpty(usbNodeConnectionInformation2.DeviceDescriptor.Product) && !string.IsNullOrEmpty(usbNodeInformation[0].Name))
                         {
                             treeViewUsbItem.Name = treeViewUsbItem.Name + ": " + usbNodeInformation[0].Name;
                         }
                     }
                     TreeViewUsbItem.ConnectedHubs++;
                 }
             }
             list.Add(treeViewUsbItem);
         }
         return(list);
     }
     return(null);
 }