예제 #1
0
        public static void SetOutputReport()
        {
            if (WriteTraces)
            {
                Console.WriteLine(MethodBase.GetCurrentMethod().Name);
            }

            USB_Orig.SetOutputReport();
        }
예제 #2
0
        public static void GetOutputLength()
        {
            if (WriteTraces)
            {
                Console.WriteLine(MethodBase.GetCurrentMethod().Name);
            }

            USB_Orig.GetOutputLength();
        }
예제 #3
0
        public static void GetErrorMsgW()
        {
            if (WriteTraces)
            {
                Console.WriteLine(MethodBase.GetCurrentMethod().Name);
            }

            USB_Orig.GetErrorMsgW();
        }
예제 #4
0
        public static int WriteUSB(int Handle, IntPtr Data, int Len, out int NumberOfBytesWritten)
        {
            if (WriteTraces)
            {
                Console.Write("{0}({1}) = ", MethodBase.GetCurrentMethod().Name, string.Join(", ", Handle, Data, Len));
            }

            byte[] DataArray = new byte[Len];
            for (int i = 0; i < DataArray.Length; i++)
            {
                DataArray[i] = Marshal.ReadByte(Data, i);
            }

            if (DumpWrite)
            {
                const string DumpName = "dump.txt";

                /*if (File.Exists(DumpName))
                 *      File.Delete(DumpName);*/

                //File.AppendAllText(DumpName, Len.ToString() + ";");
                for (int i = 0; i < DataArray.Length; i++)
                {
                    File.AppendAllText(DumpName, DataArray[i].ToString() + ";");
                }

                File.AppendAllText(DumpName, "\n");
            }

            if (SpoofUSB && Handle == SpoofHandle)
            {
                int ReturnCode = 1;
                NumberOfBytesWritten = Len;
                PrintRet(ReturnCode);

                if (WriteTraces)
                {
                    for (int i = 0; i < DataArray.Length; i++)
                    {
                        Console.Write(DataArray[i]);
                        if (i < DataArray.Length - 1)
                        {
                            Console.Write(", ");
                        }
                    }
                    Console.WriteLine();
                }

                return(ReturnCode);
            }

            return(PrintRet(USB_Orig.WriteUSB(Handle, Data, Len, out NumberOfBytesWritten)));
        }
예제 #5
0
        public static int CloseUSBDevice(int Handle)
        {
            if (WriteTraces)
            {
                Console.Write("{0}({1}) = ", MethodBase.GetCurrentMethod().Name, Handle);
            }

            if (SpoofUSB && Handle == SpoofHandle)
            {
                return(PrintRet(0));
            }

            return(PrintRet(USB_Orig.CloseUSBDevice(Handle)));
        }
예제 #6
0
        public static int OpenUSBDevice(int VID, int PID)
        {
            if (WriteTraces)
            {
                Console.Write("{0}({1}) = ", MethodBase.GetCurrentMethod().Name, string.Join(", ", VID, PID));
            }


            if (!SpoofUSB)
            {
                return(PrintRet(USB_Orig.OpenUSBDevice(VID, PID)));
            }

            return(PrintRet(SpoofHandle));
        }
예제 #7
0
        public static int ReadUSB(int Handle, IntPtr Data, int Len, out int NumberOfBytesRead)
        {
            if (WriteTraces)
            {
                Console.Write("{0}({1}) = ", MethodBase.GetCurrentMethod().Name, string.Join(", ", Handle, Data, Len));
            }

            if (SpoofUSB && Handle == SpoofHandle)
            {
                byte[] DataResponse = new byte[] { 0, 0, 128 };
                for (int i = 0; i < Len; i++)
                {
                    Marshal.WriteByte(Data, i, DataResponse[i]);
                }

                NumberOfBytesRead = Len;
                return(PrintRet(1));
            }

            int Res = PrintRet(USB_Orig.ReadUSB(Handle, Data, Len, out NumberOfBytesRead));

            if (WriteTraces)
            {
                for (int i = 0; i < NumberOfBytesRead; i++)
                {
                    Console.Write(Marshal.ReadByte(Data, i));
                    if (i < NumberOfBytesRead - 1)
                    {
                        Console.Write(", ");
                    }
                }
                Console.WriteLine();
            }

            return(Res);
        }