Exemple #1
0
 /// <summary>
 /// Receives binary data of specified size sent from the xbox.
 /// </summary>
 /// <param name="size"></param>
 /// <returns></returns>
 public byte[] ReceiveBinaryData(int size)
 {
     XboxConsole.Wait(size);
     byte[] binData = new byte[size];
     XboxClient.XboxName.Client.Receive(binData, binData.Length, SocketFlags.None);
     return(binData);
 }
Exemple #2
0
 public void QueryGamepadQueue(UserIndex Index, out uint QueueLength, out uint ItemsInQueue, out uint TimedDurationRemaining, out uint CountDurationRemaining)
 {
     QueueLength            = 0;
     ItemsInQueue           = 0;
     TimedDurationRemaining = 0;
     CountDurationRemaining = 0;
     XboxConsole.SendTextCommand("autoinput user="******" queryqueue");
 }
Exemple #3
0
        /// <summary>
        /// Creates a file on the xbox.
        /// </summary>
        /// <param name="fileName">File to create.</param>
        /// <param name="createDisposition">Creation options.</param>
        public void CreateFile(string fileName, FileMode createDisposition)
        {
            XboxConsole Xbox = new XboxConsole();

            if (createDisposition == FileMode.Open)
            {
                if (!File.Exists(fileName))
                {
                    throw new FileNotFoundException("File does not exist.");
                }
            }
            else if (createDisposition == FileMode.Create)
            {
                Xbox.SendTextCommand("fileeof name=\"" + fileName + "\" size=0 cancreate");
            }
            else if (createDisposition == FileMode.CreateNew)
            {
                Xbox.SendTextCommand("fileeof name=\"" + fileName + "\" size=0 mustcreate");
            }
            // else throw "Unsupported FileMode.";
        }
Exemple #4
0
        /// <summary>
        /// Sends a file to the xbox.
        /// </summary>
        /// <param name="localName">PC file name.</param>
        /// <param name="remoteName">Xbox file name.</param>
        public void SendFile(string localName, string remoteName)
        {
            XboxConsole Xbox = new XboxConsole();
            FileStream  lfs  = new FileStream(localName, FileMode.Open);

            byte[] fileData = new byte[XboxClient.XboxName.Client.SendBufferSize];
            XboxConsole.SendTextCommand("sendfile name=\"{0}\" length={1}" + remoteName + lfs.Length);

            int mainIterations = (int)lfs.Length / XboxClient.XboxName.Client.SendBufferSize;
            int remainder      = (int)lfs.Length % XboxClient.XboxName.Client.SendBufferSize;

            for (int i = 0; i < mainIterations; i++)
            {
                lfs.Read(fileData, 0, fileData.Length);
                Xbox.SendBinaryData(fileData);
            }
            lfs.Read(fileData, 0, remainder);
            Xbox.SendBinaryData(fileData, remainder);

            lfs.Close();
        }
Exemple #5
0
        /// <summary>
        /// Receives a file from the xbox.
        /// </summary>
        /// <param name="localName">PC file name.</param>
        /// <param name="remoteName">Xbox file name.</param>
        public void ReceiveFile(string localName, string remoteName)
        {
            XboxConsole Xbox = new XboxConsole();

            XboxConsole.SendTextCommand("getfile name=\"{0}\"" + remoteName);
            int fileSize = BitConverter.ToInt32(Xbox.ReceiveBinaryData(4), 0);

            using (var lfs = new System.IO.FileStream(localName, FileMode.Create))
            {
                byte[] fileData = new byte[XboxClient.XboxName.Client.ReceiveBufferSize];

                int mainIterations = fileSize / XboxClient.XboxName.Client.ReceiveBufferSize;
                int remainder      = fileSize % XboxClient.XboxName.Client.ReceiveBufferSize;

                for (int i = 0; i < mainIterations; i++)
                {
                    fileData = Xbox.ReceiveBinaryData(fileData.Length);
                    lfs.Write(fileData, 0, fileData.Length);
                }
                fileData = Xbox.ReceiveBinaryData(remainder);
                lfs.Write(fileData, 0, remainder);
            }
        }
Exemple #6
0
        /// <summary>
        /// Sets the size of a specified file on the xbox.  This method will not zero out any extra bytes that may have been created.
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="size"></param>
        public void SetFileSize(string fileName, int size)
        {
            XboxConsole Xbox = new XboxConsole();

            Xbox.SendTextCommand("fileeof name=\"{0}\" size={1}", fileName, size);
        }
Exemple #7
0
 /// <summary>
 /// Receives binary data of specified size sent from the xbox.
 /// </summary>
 /// <param name="data"></param>
 public void ReceiveBinaryData(byte[] data)
 {
     XboxConsole.Wait(data.Length);
     XboxClient.XboxName.Client.Receive(data, data.Length, SocketFlags.None);
 }
Exemple #8
0
 void UnbindController(UserIndex Index)
 {
     XboxConsole.SendTextCommand("autoinput user="******" unbind");
 }
Exemple #9
0
        /// <summary>
        /// Create the specified directory on the console.
        /// </summary>
        /// <param name="path">Directory name.</param>
        public void MakeDirectory(string path)
        {
            string sdr = string.Concat("mkdir name=\"{0}\"", path);

            XboxConsole.SendTextCommand(sdr, out _);
        }
Exemple #10
0
 void GetUserDefaultProfile(out long Xuid)
 {
     XboxConsole.SendTextCommand("autoprof");
     Xuid = 0;
 }
Exemple #11
0
 void ClearGamepadQueue(UserIndex Index)
 {
     XboxConsole.SendTextCommand("autoinput user="******" clearqueue");
 }
Exemple #12
0
 bool QueueGamepadState(UserIndex Index, ref XBOX_AUTOMATION_GAMEPAD Gamepad, uint TimedDuration, uint CountDuration)
 {
     XboxConsole.SendTextCommand("autoinput user="******" queuepackets count=" + CountDuration);
     return(true);
 }
Exemple #13
0
 void SetGamepadState(UserIndex Index, ref XBOX_AUTOMATION_GAMEPAD Gamepad)
 {
     XboxConsole.SendTextCommand("autoinput user="******" setpacket");
 }
Exemple #14
0
 void DisconnectController(UserIndex Index)
 {
     XboxConsole.SendTextCommand("autoinput user="******" disconnect");
 }
Exemple #15
0
        /// <summary>
        /// Delete the specified folder path from the console.
        /// </summary>
        /// <param name="path"></param>
        public void RemoveDirectory(string path)
        {
            string sdr = string.Concat("delete name=\"{0}\"", path);

            XboxConsole.SendTextCommand(sdr, out _);
        }
Exemple #16
0
        /// <summary>
        /// Renames or moves a file on the xbox.
        /// </summary>
        /// <param name="oldFileName">Old file name.</param>
        /// <param name="newFileName">New file name.</param>
        public void RenameFile(string OldFileName, string NewFileName)
        {
            string ren = string.Concat("rename name=\"{0}\" newname=\"{1}\"", OldFileName, NewFileName);

            XboxConsole.SendTextCommand(ren);
        }
Exemple #17
0
 void SetUserDefaultProfile(long Xuid)
 {
     XboxConsole.SendTextCommand("autoprof xuid=" + Xuid);
 }
Exemple #18
0
 /// <summary>
 /// Get the specified folder path from the console.
 /// </summary>
 /// <param name="path"></param>
 /// <returns></returns>
 public string[] DirectoryFiles(string path)
 {
     return(new[] { XboxConsole.SendTextCommand(string.Concat("dir name=\"{0}\"", path)) });
 }
Exemple #19
0
 static void GetInputProcess(UserIndex Index, out bool SystemProcess)
 {
     SystemProcess = false;
     XboxConsole.SendTextCommand("autoinput user="******" process");
 }
Exemple #20
0
        private static object CallArgs(bool SystemThread, uint Type, Type t, string module, int ordinal, uint Address, uint ArraySize, params object[] Arguments)
        {
            uint Void        = 0;
            uint Int         = 1;
            uint Float       = 3;
            uint ByteArray   = 7;
            uint Uint64      = 8;
            uint Uint64Array = 9;
            uint Version     = 2;

            XboxConsole.ConnectTimeout = XboxConsole.ConversationTimeout = (int)4000000U; //ConversationTimeout
            object[] objArray1 = new object[13];
            objArray1[0] = "consolefeatures ver=";
            objArray1[1] = Version;
            objArray1[2] = " type=";
            objArray1[3] = Type;
            objArray1[4] = SystemThread ? " system" : "";
            object[] objArray2 = objArray1;
            string   str1;

            if (module == null)
            {
                str1 = "";
            }
            else
            {
                str1 = " module=\"" + module + "\" ord=" + ordinal;
            }
            objArray2[5]  = str1;
            objArray1[6]  = " as=";
            objArray1[7]  = ArraySize;
            objArray1[8]  = " params=\"A\\";
            objArray1[9]  = Address.ToString("X");
            objArray1[10] = "\\A\\";
            objArray1[11] = Arguments.Length;
            objArray1[12] = "\\";
            string str2 = string.Concat(objArray1);

            if (Arguments.Length > 37)
            {
                throw new Exception("Can not use more than 37 paramaters in a call");
            }
            foreach (object o in Arguments)
            {
                bool flag1 = false;
                if (o is uint num)
                {
                    str2  = str2 + Int + "\\" + UIntToInt(num) + "\\";
                    flag1 = true;
                }
                if (o is int || o is bool || o is byte)
                {
                    if (o is bool flag)
                    {
                        str2 = str2 + Int + "/" + System.Convert.ToInt32(flag) + "\\";
                    }
                    else
                    {
                        str2 = str2 + Int + "\\" + (o is byte?System.Convert.ToByte(o).ToString() : System.Convert.ToInt32(o).ToString()) + "\\";
                    }
                    flag1 = true;
                }
                else if (o is int[] || o is uint[])
                {
                    byte[] numArray = IntArrayToByte((int[])o);
                    string str3     = str2 + ByteArray.ToString() + "/" + numArray.Length + "\\";
                    for (int index = 0; index < numArray.Length; ++index)
                    {
                        str3 += numArray[index].ToString("X2");
                    }
                    str2  = str3 + "\\";
                    flag1 = true;
                }
                else if (o is string)
                {
                    string str3 = (string)o;
                    str2  = str2 + ByteArray.ToString() + "/" + str3.Length + "\\" + ((string)o).ToHexString() + "\\";
                    flag1 = true;
                }
                else if (o is double)
                {
                    str2  = str2 + Float.ToString() + "\\" + o.ToString() + "\\";
                    flag1 = true;
                }
                else if (o is float)
                {
                    str2  = str2 + Float.ToString() + "\\" + o.ToString() + "\\";
                    flag1 = true;
                }
                else if (o is float[])
                {
                    float[] numArray = (float[])o;
                    string  str3     = str2 + ByteArray.ToString() + "/" + (numArray.Length * 4).ToString() + "\\";
                    for (int index1 = 0; index1 < numArray.Length; ++index1)
                    {
                        byte[] bytes = BitConverter.GetBytes(numArray[index1]);
                        Array.Reverse(bytes);
                        for (int index2 = 0; index2 < 4; ++index2)
                        {
                            str3 += bytes[index2].ToString("X2");
                        }
                    }
                    str2  = str3 + "\\";
                    flag1 = true;
                }
                else if (o is byte[])
                {
                    byte[] numArray = (byte[])o;
                    string str3     = str2 + ByteArray.ToString() + "/" + numArray.Length + "\\";
                    for (int index = 0; index < numArray.Length; ++index)
                    {
                        str3 += numArray[index].ToString("X2");
                    }
                    str2  = str3 + "\\";
                    flag1 = true;
                }
                if (!flag1)
                {
                    str2 = str2 + Uint64.ToString() + "\\" + ConvertToUInt64(o).ToString() + "\\";
                }
            }
            string Command = str2 + "\"";
            string String  = XboxConsole.SendTextCommand(Command);
            uint   num1;

            for (string _Ptr = "buf_addr="; String.Contains(_Ptr); String = XboxConsole.SendTextCommand("consolefeatures " + _Ptr + "0x" + num1.ToString("X")))
            {
                Thread.Sleep(250);
                num1 = uint.Parse(String.Substring(String.find(_Ptr) + _Ptr.Length), NumberStyles.HexNumber);
            }
            XboxConsole.ConnectTimeout      = (int)2000U;
            XboxConsole.ConversationTimeout = (int)5000U;
            switch (Type)
            {
            case 1:
                uint num2 = uint.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber);
                if (t == typeof(uint))
                {
                    return(num2);
                }
                if (t == typeof(int))
                {
                    return(UIntToInt(num2));
                }
                if (t == typeof(short))
                {
                    return(short.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber));
                }
                if (t == typeof(ushort))
                {
                    return(ushort.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber));
                }
                break;

            case 2:
                string str4 = String.Substring(String.find(" ") + 1);
                if (t == typeof(string))
                {
                    return(str4);
                }
                if (t == typeof(char[]))
                {
                    return(str4.ToCharArray());
                }
                break;

            case 3:
                if (t == typeof(double))
                {
                    return(double.Parse(String.Substring(String.find(" ") + 1)));
                }
                if (t == typeof(float))
                {
                    return(float.Parse(String.Substring(String.find(" ") + 1)));
                }
                break;

            case 4:
                byte num3 = byte.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber);
                if (t == typeof(byte))
                {
                    return(num3);
                }
                if (t == typeof(char))
                {
                    return((char)num3);
                }
                break;

            case 8:
                if (t == typeof(long))
                {
                    return(long.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber));
                }
                if (t == typeof(ulong))
                {
                    return(ulong.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber));
                }
                break;
            }
            switch (Type)
            {
            case 5:
                string str5      = String.Substring(String.find(" ") + 1);
                int    index3    = 0;
                string s1        = "";
                uint[] numArray1 = new uint[8];
                foreach (char ch in str5)
                {
                    switch (ch)
                    {
                    case ',':
                    case ';':
                        numArray1[index3] = uint.Parse(s1, NumberStyles.HexNumber);
                        ++index3;
                        s1 = "";
                        break;

                    default:
                        s1 += ch.ToString();
                        break;
                    }
                    if (ch == ';')
                    {
                        break;
                    }
                }
                return(numArray1);

            case 6:
                string  str6      = String.Substring(String.find(" ") + 1);
                int     index4    = 0;
                string  s2        = "";
                float[] numArray2 = new float[ArraySize];
                foreach (char ch in str6)
                {
                    switch (ch)
                    {
                    case ',':
                    case ';':
                        numArray2[index4] = float.Parse(s2);
                        ++index4;
                        s2 = "";
                        break;

                    default:
                        s2 += ch.ToString();
                        break;
                    }
                    if (ch == ';')
                    {
                        break;
                    }
                }
                return(numArray2);

            case 7:
                string str7      = String.Substring(String.find(" ") + 1);
                int    index5    = 0;
                string s3        = "";
                byte[] numArray3 = new byte[ArraySize];
                foreach (char ch in str7)
                {
                    switch (ch)
                    {
                    case ',':
                    case ';':
                        numArray3[index5] = byte.Parse(s3);
                        ++index5;
                        s3 = "";
                        break;

                    default:
                        s3 += ch.ToString();
                        break;
                    }
                    if (ch == ';')
                    {
                        break;
                    }
                }
                return(numArray3);

            default:
                if ((int)Type == (int)Uint64Array)
                {
                    string  str3      = String.Substring(String.find(" ") + 1);
                    int     index1    = 0;
                    string  s4        = "";
                    ulong[] numArray4 = new ulong[ArraySize];
                    foreach (char ch in str3)
                    {
                        switch (ch)
                        {
                        case ',':
                        case ';':
                            numArray4[index1] = ulong.Parse(s4);
                            ++index1;
                            s4 = "";
                            break;

                        default:
                            s4 += ch.ToString();
                            break;
                        }
                        if (ch == ';')
                        {
                            break;
                        }
                    }
                    if (t == typeof(ulong))
                    {
                        return(numArray4);
                    }
                    if (t == typeof(long))
                    {
                        long[] numArray5 = new long[ArraySize];
                        for (int index2 = 0; index2 < ArraySize; ++index2)
                        {
                            numArray5[index2] = BitConverter.ToInt64(BitConverter.GetBytes(numArray4[index2]), 0);
                        }
                        return(numArray5);
                    }
                }
                return((int)Type == (int)Void ? 0 : ulong.Parse(String.Substring(String.find(" ") + 1), NumberStyles.HexNumber));
            }
        }
Exemple #21
0
 void BindController(UserIndex Index, uint QueueLength)
 {
     XboxConsole.SendTextCommand("autoinput user="******" bind queuelen=" + QueueLength);
 }