Пример #1
0
        public static ushort How_Many_Of_MyDevices_Are_Attached(ushort ProductID)
        {
            IntPtr zero       = IntPtr.Zero;
            IntPtr zero2      = IntPtr.Zero;
            Guid   empty      = Guid.Empty;
            string text       = "";
            ushort p_VendorID = 1240;

            return(USB.Count_Attached_PKSA(p_VendorID, ProductID, 29, ref zero, ref zero2, ref text, false, ref empty));
        }
Пример #2
0
        public static ushort How_Many_Of_MyDevices_Are_Attached(ushort ProductID)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr ptr2  = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string str   = "";
            ushort num   = 0x4d8;

            return(USB.Count_Attached_PKSA(num, ProductID, 0x1d, ref zero, ref ptr2, ref str, false, ref empty));
        }
Пример #3
0
        /*
         * [DllImport("hid.dll")]
         * public static extern void HidD_GetHidGuid(ref Guid HidGuid);
         *
         * [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
         * public static extern IntPtr SetupDiGetClassDevs(ref Guid ClassGuid, string Enumerator, int hwndParent, int Flags);
         *
         * [DllImport("setupapi.dll")]
         * public static extern int SetupDiEnumDeviceInterfaces(IntPtr DeviceInfoSet, int DeviceInfoData, ref Guid InterfaceClassGuid, int MemberIndex, ref USB.SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
         *
         * [DllImport("setupapi.dll", CharSet = CharSet.Auto)]
         * public static extern bool SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet, ref USB.SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IntPtr DeviceInterfaceDetailData, int DeviceInterfaceDetailDataSize, ref int RequiredSize, IntPtr DeviceInfoData);
         *
         * [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
         * public static extern IntPtr CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, ref USB.SECURITY_ATTRIBUTES lpSecurityAttributes, int dwCreationDisposition, uint dwFlagsAndAttributes, int hTemplateFile);
         *
         * [DllImport("hid.dll")]
         * public static extern int HidD_GetAttributes(IntPtr HidDeviceObject, ref USB.HIDD_ATTRIBUTES Attributes);
         *
         * [DllImport("hid.dll")]
         * public static extern bool HidD_GetPreparsedData(IntPtr HidDeviceObject, ref IntPtr PreparsedData);
         *
         * [DllImport("hid.dll")]
         * public static extern int HidP_GetCaps(IntPtr PreparsedData, ref USB.HIDP_CAPS Capabilities);
         *
         * [DllImport("setupapi.dll")]
         * public static extern int SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
         *
         * [DllImport("hid.dll")]
         * public static extern bool HidD_FreePreparsedData(ref IntPtr PreparsedData);
         *
         * [DllImport("kernel32.dll")]
         * public static extern int CloseHandle(IntPtr hObject);
         *
         * [DllImport("hid.dll")]
         * public static extern bool HidD_GetNumInputBuffers(IntPtr HidDeviceObject, ref int NumberBuffers);
         *
         * [DllImport("hid.dll")]
         * public static extern bool HidD_SetNumInputBuffers(IntPtr HidDeviceObject, int NumberBuffers);
         *
         * [DllImport("kernel32.dll")]
         * public static extern int GetLastError();
         *
         * [DllImport("kernel32.dll", SetLastError = true)]
         * public static extern bool GetOverlappedResult(IntPtr hFile, ref Utilities.OVERLAPPED lpOverlapped, ref int lpNumberOfBytesTransferred, int bWait);
         */

        public static bool Find_Our_Device(ushort p_VendorID, ushort p_PoductID)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr zero2 = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string text  = "";
            ushort num   = 0;

            return(USB.Get_This_Device(p_VendorID, p_PoductID, 0, ref zero, ref zero2, ref text, false, ref empty, ref num));
        }
Пример #4
0
        private static void Read_USB_Thread()
        {
            Utilities.SECURITY_ATTRIBUTES security_attributes;
            int num = 0;
            int pNumberOfBytesRead = 0;

            m_we_are_in_read_loop = true;
            Utilities.OVERLAPPED pOverlapped = new Utilities.OVERLAPPED();
            security_attributes = new Utilities.SECURITY_ATTRIBUTES {
                lpSecurityDescriptor = 0,
                bInheritHandle       = Convert.ToInt32(true),
                nLength = Marshal.SizeOf(typeof(SECURITY_ATTRIBUTES))
            };
            int num3 = Utilities.CreateEvent(ref security_attributes, Convert.ToInt32(false), Convert.ToInt32(false), "");

            pOverlapped.hEvent = num3;
            while (m_we_are_in_read_loop)
            {
                Array.Clear(m_read_buffer, 0, m_read_buffer.Length);
                pOverlapped.Offset     = 0;
                pOverlapped.OffsetHigh = 0;
                if (ReadFile(Utilities.m_flags.HID_read_handle, m_read_buffer, Utilities.m_flags.irbl, ref pNumberOfBytesRead, ref pOverlapped))
                {
                    if (USBDataAvailable != null)
                    {
                        USBDataAvailable();
                        m_packet_is_copied.WaitOne(0x3e8, false);
                    }
                }
                else
                {
                    switch (USB.GetLastError())
                    {
                    case 0x26:
                    {
                        num++;
                        continue;
                    }

                    case 0x3e5:
                    {
                        Utilities.WaitForSingleObject(pOverlapped.hEvent, 0x7d0);
                        if (USB.GetOverlappedResult(Utilities.m_flags.HID_read_handle, ref pOverlapped, ref pNumberOfBytesRead, 0) && (USBDataAvailable != null))
                        {
                            USBDataAvailable();
                            m_packet_is_copied.WaitOne(0x3e8, false);
                        }
                        continue;
                    }
                    }
                    num++;
                }
            }
            num++;
        }
Пример #5
0
        public static ushort How_Many_PICkitSerials_Are_Attached()
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr ptr2  = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string str   = "";
            ushort num   = 0x36;
            ushort num2  = 0x4d8;

            return(USB.Count_Attached_PKSA(num2, num, 0x1d, ref zero, ref ptr2, ref str, false, ref empty));
        }
Пример #6
0
        public static ushort How_Many_PICkitSerials_Are_Attached()
        {
            IntPtr zero       = IntPtr.Zero;
            IntPtr zero2      = IntPtr.Zero;
            Guid   empty      = Guid.Empty;
            string text       = "";
            ushort p_PoductID = 54;
            ushort p_VendorID = 1240;

            return(USB.Count_Attached_PKSA(p_VendorID, p_PoductID, 29, ref zero, ref zero2, ref text, false, ref empty));
        }
Пример #7
0
        public static bool Find_ThisDevice(ushort VendorID, ushort ProductID)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr zero2 = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string text  = "";
            ushort num   = 0;
            bool   flag  = USB.Get_This_Device(VendorID, ProductID, 0, ref zero, ref zero2, ref text, false, ref empty, ref num);

            if (flag)
            {
                flag = USBRead.Kick_Off_Read_Thread();
                if (flag)
                {
                    flag = USBWrite.kick_off_write_thread();
                }
            }
            return(flag);
        }
Пример #8
0
        public static bool Initialize_PICkitSerial(ushort USBIndex)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr ptr2  = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string str   = "";
            ushort num   = 0x36;
            ushort num2  = 0x4d8;
            ushort num3  = 0;
            bool   flag  = USB.Get_This_Device(num2, num, USBIndex, ref zero, ref ptr2, ref str, false, ref empty, ref num3);

            if (flag)
            {
                flag = USBRead.Kick_Off_Read_Thread();
                if (flag)
                {
                    flag = USBWrite.kick_off_write_thread();
                }
            }
            return(flag);
        }
Пример #9
0
        public static bool Initialize_PICkitSerial(ushort USBIndex)
        {
            IntPtr zero       = IntPtr.Zero;
            IntPtr zero2      = IntPtr.Zero;
            Guid   empty      = Guid.Empty;
            string text       = "";
            ushort p_PoductID = 54;
            ushort p_VendorID = 1240;
            ushort num        = 0;
            bool   flag       = USB.Get_This_Device(p_VendorID, p_PoductID, USBIndex, ref zero, ref zero2, ref text, false, ref empty, ref num);

            if (flag)
            {
                flag = USBRead.Kick_Off_Read_Thread();
                if (flag)
                {
                    flag = USBWrite.kick_off_write_thread();
                }
            }
            return(flag);
        }
Пример #10
0
        public static bool Initialize_MyDevice(ushort USBIndex, ushort ProductID)
        {
            IntPtr zero  = IntPtr.Zero;
            IntPtr ptr2  = IntPtr.Zero;
            Guid   empty = Guid.Empty;
            string str   = "";
            ushort num   = 0x4d8;
            ushort num2  = 0;
            bool   flag  = USB.Get_This_Device(num, ProductID, USBIndex, ref zero, ref ptr2, ref str, false, ref empty, ref num2);

            if (flag)
            {
                flag = USBRead.Kick_Off_Read_Thread();
                if (flag)
                {
                    flag = USBWrite.kick_off_write_thread();
                    if (ProductID == 80)
                    {
                        Utilities.g_comm_mode = Utilities.COMM_MODE.MTOUCH2;
                    }
                }
            }
            return(flag);
        }
Пример #11
0
        public static bool Find_Our_Device(ushort p_VendorID, ushort p_PoductID, ushort p_index, ref IntPtr p_ReadHandle, ref IntPtr p_WriteHandle, ref string p_devicepath, ref Guid p_HidGuid)
        {
            ushort num = 0;

            return(USB.Get_This_Device(p_VendorID, p_PoductID, p_index, ref p_ReadHandle, ref p_WriteHandle, ref p_devicepath, true, ref p_HidGuid, ref num));
        }