Exemplo n.º 1
0
 public AlteredPatchHeader(EndianIO IO)
 {
     //Go to offset 0
     IO.In.BaseStream.Position = 0;
     //Verify its an RTH Patch
     if (IO.In.ReadAsciiString(4) != HeaderString)
     {
         throw new Exception(
                   "The following Patch is an invalid patch and therefore will not be read/applied/handled.");
     }
     //Verify our version
     if (IO.In.ReadSingle() != Version)
     {
         throw new Exception(
                   "The following RTH Patch is of a different version and it's architecture has most likely been updated, therefore the patch will and most likely cannot be applied.");
     }
     //Read our Author Name
     Author_Name = IO.In.ReadAsciiString(32);
     //Read our patch description
     Patch_Description = IO.In.ReadAsciiString(256);
     //Read our original map checksum
     Original_Map_Checksum = IO.In.ReadInt32();
     //Read our image
     Preview_Image = Image.FromStream(new MemoryStream(IO.In.ReadBytes(0xA000)));
 }
Exemplo n.º 2
0
        public void SaveValue(EndianIO IO, int parentOffset)
        {
            //Go to the required offset
            IO.Out.BaseStream.Position = parentOffset + BitmaskData.Offset;
            //Determine type and write accordingly
            switch (BitmaskData.Attributes)
            {
            case mValue.ObjectAttributes.Bitmask8:
            {
                IO.Out.Write((byte)BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }

            case mValue.ObjectAttributes.Bitmask16:
            {
                IO.Out.Write((short)BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }

            case mValue.ObjectAttributes.Bitmask32:
            {
                IO.Out.Write(BitHelper.ConvertToWriteableInteger(ReturnCheckedList()));
                break;
            }
            }
        }
Exemplo n.º 3
0
        public void SaveValue(EndianIO IO, int parentOffset)
        {
            //Go to the required offset
            IO.Out.BaseStream.Position = (parentOffset + IdentData.Offset) - 12;

            //Get new ident-tag index
            if (cmbxName.Text != "<<null>>")
            {
                //Get the index using the tagname and class
                int index = HMap.GetTagIndexByClassAndName(cmbxClass.Text, cmbxName.Text);
                //If the index is null...
                if (index == -1)
                {
                    goto WriteNullIdent;
                }
                //Write the tagref
                IO.Out.WriteAsciiString(HMap.IndexItems[index].Class, 4);
                //Skip the 8 byte gap.
                IO.Out.BaseStream.Position += 8;
                //Write the ident
                IO.Out.Write(HMap.IndexItems[index].Ident);
                //Returned
                return;
            }
            //Otherwise...

WriteNullIdent:
            ;
            //Jump to the ident offset
            IO.Out.BaseStream.Position += 12;
            //Write the ident
            IO.Out.Write(-1);
        }
Exemplo n.º 4
0
        public byte[] GetCompressedRawDataFromPoolIndex(int raw_pool_index)
        {
            externalMaps.OpenIOs();
            int index      = raw_pool_index;
            int poolOffset = (int)rawPools[index].RawOffset;
            int size       = (int)rawPools[index].CompressedSize;

            // Load our IO
            EndianIO io = (RawPools[index].ExternalMapIndex == -1) ? map.IO :
                          externalMaps[RawPools[index].ExternalMapIndex].io;

            // Open our IO and add our raw table offset
            io.In.SeekTo(0x470);
            int offset = poolOffset + io.In.ReadInt32();

            //Go to our offset
            io.In.BaseStream.Position = offset;
            //Read our raw data.
            byte[] rawData = io.In.ReadBytes(size);

            externalMaps.CloseIOs();

            // Now lets return our data
            return(rawData);
        }
Exemplo n.º 5
0
        private void GET_GUIDE_INFO(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO, EndianWriter structIO)
        {
            entry.client_session = readerIO.Reader.ReadBytes(0x10).BytesToHexString();

            if (conMySQL.getConsole(ref entry, true))
            {
                if (entry.client_dateExpire >= DateTime.Now)
                {
                    GlobalFunc.Write(entry.client_name);
                    TimeSpan timeLeft = Misc.DateTimetoExact(entry.client_dateExpire.ToLocalTime(), DateTime.Now.ToLocalTime());
                    //string s_timeLeft = "fgt\0";//entry.client_days >= 500 ? "Life in prison.\0" : String.Format("D:{0} H:{1} M:{2}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes);//String.Format("Days {0} | Hours {1} | Minutes {2} | Seconds {3}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes, timeLeft.Seconds);

                    int    maxStatusLen = 20, maxTimeLen = 50;
                    byte[] StatusBuff = new byte[maxStatusLen];
                    byte[] timeBuff   = new byte[maxTimeLen];
                    //byte[] serialBuff = new byte[maxSerialLen];

                    string Status     = "Authenticated\0";
                    string s_timeLeft = entry.client_days >= 99999 ? "Life in prison.\0" : String.Format("D:{0} H:{1} M:{2}\0", entry.client_days, timeLeft.Hours, timeLeft.Minutes);

                    Buffer.BlockCopy(Encoding.ASCII.GetBytes(Status), 0, StatusBuff, 0, Status.Length);
                    Buffer.BlockCopy(Encoding.ASCII.GetBytes(s_timeLeft), 0, timeBuff, 0, s_timeLeft.Length);

                    structBuff = new byte[(sizeof(uint) * 4) + StatusBuff.Length + timeBuff.Length];
                    structIO   = new EndianIO(structBuff, EndianStyle.BigEndian).Writer;
                    structIO.Write(StatusBuff);
                    structIO.Write(timeBuff);
                    writerIO.Writer.Write(structBuff);
                    GlobalFunc.Write("GET_GUIDE_INFO: Sent");
                }
            }
        }
Exemplo n.º 6
0
        private RSACryptoServiceProvider LoadConsolePrivateKey(byte[] Exponent, byte[] KeyParams)
        {
            EndianIO nio = new EndianIO(KeyParams, EndianStyle.BigEndian);

            byte[]        buffer     = Reverse8(nio.Reader.ReadBytes(0x80));
            byte[]        buffer2    = Reverse8(nio.Reader.ReadBytes(0x40));
            byte[]        buffer3    = Reverse8(nio.Reader.ReadBytes(0x40));
            byte[]        buffer4    = Reverse8(nio.Reader.ReadBytes(0x40));
            byte[]        buffer5    = Reverse8(nio.Reader.ReadBytes(0x40));
            byte[]        buffer6    = Reverse8(nio.Reader.ReadBytes(0x40));
            RSAParameters parameters = new RSAParameters
            {
                Exponent = Exponent,
                Modulus  = buffer,
                P        = buffer2,
                Q        = buffer3,
                DP       = buffer4,
                DQ       = buffer5,
                InverseQ = buffer6,
                D        = new byte[0x80]
            };

            new Random(Environment.TickCount).NextBytes(parameters.D);
            RSACryptoServiceProvider provider = new RSACryptoServiceProvider();

            provider.ImportParameters(parameters);
            return(provider);
        }
Exemplo n.º 7
0
        private static void ReadFile(string filename)
        {
            Console.WriteLine("FILENAME: " + new FileInfo(filename).Name);
            Console.WriteLine("SIZE: " + Math.Round(Convert.ToDecimal(new FileInfo(filename).Length / 1024 / 1024), 2) + "MB");
            IO             = new EndianIO(filename, EndianType.LittleEndian, true);
            header.magic   = IO.In.ReadString(4);
            header.version = IO.In.ReadUInt64();
            Console.WriteLine("MAGIC NUMBER: " + header.magic);
            Console.WriteLine("VERSION: " + header.version);
            Console.WriteLine("VERSION (HEX): " + "0x" + header.version.ToString("X"));
            header.fileCount  = IO.In.ReadUInt32();
            header.blockCount = IO.In.ReadUInt32();
            header.reserved   = IO.In.ReadBytes(12);
            header.fileEntry  = new file_entry_t[header.fileCount];
            Console.WriteLine("FILE NUMBER: " + header.fileCount);
            Console.WriteLine("BLOCK NUMBER: " + header.blockCount);
            for (int i = 0; i < header.fileCount; i++)
            {
                header.fileEntry[i].offset      = IO.In.ReadUInt32();
                header.fileEntry[i].contentSize = IO.In.ReadUInt32();
                header.fileEntry[i].reserved    = IO.In.ReadUInt64();
                header.fileEntry[i].fileName    = IO.In.ReadString(0x20);
            }

            for (int i = 0; i < header.fileCount; i++)
            {
                uint entryOffset = header.fileEntry[i].offset * blockSize;
                IO.Position = header.fileEntry[i].offset * blockSize;
                header.fileEntry[i].Data = IO.In.ReadBytes(header.fileEntry[i].contentSize);
                Console.WriteLine("FILE " + i + ": " + header.fileEntry[i].fileName + ":    " + header.fileEntry[i].contentSize / 1024 / 1024 + " MB");
            }
            Extract();
        }
Exemplo n.º 8
0
        public void SaveData(Stream stream)
        {
            //Initialize our IO
            EndianIO IO = new EndianIO(stream, EndianType.BigEndian);

            //Open our IO
            IO.Open();
            //Write our header string
            IO.Out.WriteAsciiString(RTHDataHeader.HeaderString, 4);
            //Write our header version
            IO.Out.Write(RTHDataHeader.Version);
            //Write our block count
            IO.Out.Write(RTH_Data_Blocks.Count);
            //Write our patch type
            IO.Out.Write((int)RTH_Data_Header.Patch_Type);
            //Write our author name
            IO.Out.WriteAsciiString(RTH_Data_Header.Author_Name, 32);
            //Write our patch description
            IO.Out.WriteAsciiString(RTH_Data_Header.Patch_Description, 256);
            //Write our author IP
            IO.Out.WriteAsciiString(RTH_Data_Header.Watermark, 16);
            //Loop through our blocks
            for (int index = 0; index < RTH_Data_Blocks.Count; index++)
            {
                //Write our memory offset
                IO.Out.Write(RTH_Data_Blocks[index].Memory_Offset);
                //Write our block size
                IO.Out.Write(RTH_Data_Blocks[index].Block_Size);
                //Write our data block
                IO.Out.Write(RTH_Data_Blocks[index].Data_Block);
            }
            //Close our IO
            IO.Close();
        }
Exemplo n.º 9
0
        public void SaveValue(EndianIO IO, int parentOffset)
        {
            //If no item is selected
            if (cmbxSelections.SelectedIndex == -1)
            {
                //Exit
                return;
            }
            //Go to the required offset
            IO.Out.BaseStream.Position = parentOffset + EnumData.Offset;
            //Determine type and write accordingly
            switch (EnumData.Attributes)
            {
            case mValue.ObjectAttributes.Enum8:
            {
                IO.Out.Write((byte)EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }

            case mValue.ObjectAttributes.Enum16:
            {
                IO.Out.Write((short)EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }

            case mValue.ObjectAttributes.Enum32:
            {
                IO.Out.Write(EnumOptions[cmbxSelections.SelectedIndex].Value);
                break;
            }
            }
        }
Exemplo n.º 10
0
        public static void Update(ref Tmp.Entry Entry, EndianIO WriterIO, EndianIO ReaderIO)
        {
            Entry.Session  = ReaderIO.Reader.ReadBytes(0x10).ToHex();
            Entry.Title    = ReaderIO.Reader.ReadBytes(0x4).ToHex();
            Entry.GamerTag = ReaderIO.Reader.ReadBytes(0x15).ToString();

            if (ClientSQL.Get(ref Entry, true))
            {
                if (Entry.Enabled)
                {
                    WriterIO.Writer.Write((uint)respCode.RESP_SUCCESS);
                }
                else
                {
                    if (ClientSQL.Increment(ref Entry, true))
                    {
                        if (Entry.AutoIncrement)
                        {
                            ClientSQL.Increment(ref Entry);
                        }
                        WriterIO.Writer.Write(Entry.AutoIncrement ? (Entry.noto_DayStarted ? (uint)respCode.RESP_DAY_STARTED : (uint)respCode.RESP_SUCCESS) : (uint)respCode.RESP_REBOOT);
                    }
                    else
                    {
                        WriterIO.Writer.Write((uint)respCode.RESP_ERROR);
                    }
                } ClientSQL.Set(ref Entry);
            }
        }
Exemplo n.º 11
0
        public static void ProcessCPI(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));

            byte[]       DiscordToken = new byte[0xC];
            byte[]       CPIBuffer    = new byte[DiscordToken.Length + 0x4]; // Discord token + size of int unsigned preferble
            EndianWriter Data         = new EndianIO(CPIBuffer, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                int DiscordPopup = 0;

                if (ClientObj.discord != null)
                {
                    Discord discord = JsonConvert.DeserializeObject <Discord>(ClientObj.discord);
                    if (discord.id != "0" && discord.primary && !discord.verified && discord.token != null)
                    {
                        Buffer.BlockCopy(Encoding.ASCII.GetBytes(discord.token), 0, DiscordToken, 0, discord.token.Length);
                        DiscordPopup  = Convert.ToInt32(discord.popup);
                        discord.popup = false;

                        ClientObj.discord = JsonConvert.SerializeObject(discord);
                    }
                }
                Data.Write(DiscordToken);
                Data.Write(DiscordPopup);
                io.writer.Write(CPIBuffer);
            }
            else
            {
                Console.WriteLine("CPI Failed for:" + ClientObj.cpukey);
            }
        }
Exemplo n.º 12
0
        private void btn_save_Click(object sender, EventArgs e)
        {
            string saveLocation = sfDialog();

            saveINI(saveLocation);
            if (MessageBox.Show("Would you like to send this to the server?", "Oi m8", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
            {
                Thread iniThread = new Thread(new ThreadStart(delegate
                {
                    try {
                        TcpClient client      = new TcpClient(Globals.IPAddr, Globals.SvrPort);
                        NetworkStream nStream = client.GetStream();
                        EndianIO readerIO     = new EndianIO(nStream, EndianStyle.BigEndian)
                        {
                            Writer = new EndianWriter(nStream, EndianStyle.BigEndian)
                        };
                        EndianIO writerIO = new EndianIO(nStream, EndianStyle.BigEndian);
                        writerIO.Writer.Write("2F9A59018B92AA2C3B375D0D66CF8255");
                        LMAOnlineLBS.sendINI(readerIO, writerIO, saveLocation);
                        readerIO.Close(); writerIO.Close(); nStream.Close();
                    } catch { }
                }));
                iniThread.Start();
                MessageBox.Show("INI sent to server and loaded.", "INI Sent!");
            }
        }
Exemplo n.º 13
0
        public ResourceEntry(EndianIO io)
        {
            Unknown1 = io.ReadUInt32();
            Unknown2 = io.ReadUInt32();

            ResourceInformation = io.ReadUInt64();
        }
Exemplo n.º 14
0
        private void HVC(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO)
        {
            entry.CPUKey = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10));

            if (ConsoleMySQL.getConsole(ref entry))
            {
                if (entry.ClientEnabled)
                {
                    //if (Globals.HVCBytes != null && Globals.HVBytes != null) writerIO.Writer.Write(Globals.XSTL_STATUS_OTHER_ERROR);
                    //else {
                    writerIO.Writer.Write(Globals.XSTL_STATUS_SUCCESS);
                    writerIO.Writer.Write(Globals.HVBytes.Length);
                    writerIO.Writer.Write(Globals.HVCBytes.Length);
                    writerIO.Writer.Write(Globals.HVBytes);
                    writerIO.Writer.Write(Globals.HVCBytes);
                    Globals.write("Client [{0}] HVC Successfully Sent! Name: {1}", IPAddr, entry.ClientName);
                    return;
                    //} return;
                }
                else
                {
                    writerIO.Writer.Write(Globals.XSTL_STATUS_EXPIRED); Globals.write("Expired");
                }
            }
            else
            {
                writerIO.Writer.Write(Globals.XSTL_STATUS_ERROR); Globals.write("Error");
            }
            Globals.write("the f**k.");
        }
Exemplo n.º 15
0
 public EOF_Footer(EndianIO IO, int position)
 {
     IO.In.BaseStream.Position = position;
     this.EOF_String           = IO.In.ReadAsciiString(4);
     this.FooterSize           = IO.In.ReadInt32();
     this.Unknown8             = IO.In.ReadBytes(this.FooterSize - 8);
 }
Exemplo n.º 16
0
        private void con_redeem(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO, EndianWriter structIO)
        {
            // Grabbing the token from the request.
            string recCpuKey  = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10)); // Cross check the CPUKey here with the one in the DB.
            string recSession = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10)); // Receiving their sent session to cross check.

            entry.inToken = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x19));     // We'll need to change the length later.
            if (ConsoleMySQL.getConsole(ref entry))
            {
                if (entry.ClientEnabled)
                {
                    if (ConsoleMySQL.getToken(ref entry))
                    {
                        entry.daysLeft = !entry.TokenUsed ? entry.daysLeft + entry.TokenDays : entry.daysLeft;
                        string retMsgSuccess = String.Format("Token has been successfully redeemed!\nCPUKey: {0}\nRedeemed {1} Days\n{2}\0", entry.CPUKey, entry.TokenDays, (entry.daysLeft >= 500 ? "You still have lifetime." : "You have " + entry.daysLeft + " days on reserve.")),
                               retMsgUsed    = String.Format("Token seems to already be used.\n\nIf you feel this is a mistake, please message staff ASAP!\n\nYour CPUKey: {0}\0", entry.CPUKey);
                        uint   size          = (sizeof(uint) * 4) + Convert.ToUInt32((!entry.TokenUsed ? retMsgSuccess.Length : retMsgUsed.Length) + 2);
                        byte[] tmpBuff       = new byte[size];
                        mainBuff = new byte[size];
                        Buffer.BlockCopy(Encoding.ASCII.GetBytes(retMsgSuccess), 0, tmpBuff, 0, (!entry.TokenUsed ? retMsgSuccess.Length : retMsgUsed.Length) + 2);
                        structIO.Write(Globals.XSTL_STATUS_SUCCESS);
                        structIO.Write(!entry.TokenUsed ? retMsgSuccess : retMsgUsed);
                        writerIO.Writer.Write(mainBuff);
                        Globals.write("Client [{0}] CPUKey: {1}\n{2} Token: {3}", IPAddr, entry.CPUKey, (!entry.TokenUsed ? "Redeemed" : "Tried Redeeming"), entry.outToken);
                        if (!entry.TokenUsed)
                        {
                            ConsoleMySQL.saveToken(ref entry); ConsoleMySQL.saveConsole(ref entry);
                        }
                        return;
                    }
                    structIO.Write(Globals.XSTL_STATUS_ERROR);
                }
            }
        }
Exemplo n.º 17
0
 private void updatePresence(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO)
 {
     entry.ClientSession = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x10));
     entry.ClientTitle   = Misc.BytesToHexString(readerIO.Reader.ReadBytes(0x4));
     entry.ClientGT      = GlobalMisc.ConvertBytesToString(readerIO.Reader.ReadBytes(0x15));
     //Globals.write("updateShit Session: {0}", entry.ClientSession);
     if (ConsoleMySQL.getConsole(ref entry, true))
     {
         if (entry.ClientEnabled)
         {
             writerIO.Writer.Write(Globals.XSTL_STATUS_SUCCESS);
         }
         else
         {
             if (ConsoleMySQL.autoUpdateTime(ref entry))
             {
                 writerIO.Writer.Write(Globals.XSTL_STATUS_SUCCESS);
             }
             else
             {
                 writerIO.Writer.Write(Globals.XSTL_STATUS_EXPIRED);
             }
         }
         ConsoleMySQL.saveConsole(ref entry);
     }
     else
     {
         writerIO.Writer.Write(Globals.XSTL_STATUS_ERROR);
     }
 }
Exemplo n.º 18
0
        public void WriteTypes(EndianIO IO)
        {
            uint num = uint.Parse(textBox2.Text);

            IO.Out.BaseStream.Position = num;
            if (comboBox1.SelectedIndex == 0)
            {
                IO.Out.Write(byte.Parse(textBox1.Text));
            }
            if (comboBox1.SelectedIndex == 1)
            {
                IO.Out.Write(short.Parse(textBox1.Text));
            }
            if (comboBox1.SelectedIndex == 2)
            {
                IO.Out.Write(ushort.Parse(textBox1.Text));
            }
            if (comboBox1.SelectedIndex == 3)
            {
                IO.Out.Write(uint.Parse(textBox1.Text));
            }
            if (comboBox1.SelectedIndex == 4)
            {
                IO.Out.Write(int.Parse(textBox1.Text));
            }
            if (comboBox1.SelectedIndex == 5)
            {
                IO.Out.Write(float.Parse(textBox1.Text));
            }
        }
Exemplo n.º 19
0
        public static void PokeRTHData(RTHData RTH_Data)
        {
            //If our XDKName is set
            if (AppSettings.Settings.XDKName == "")
            {
                throw new Exception(
                          "The Xbox Development Kit could not be connected to because it's means of connection were not set.");
            }
            //Initialize our XDC360
            XboxDebugCommunicator xdc = new XboxDebugCommunicator(AppSettings.Settings.XDKName);

            //Connect
            xdc.Connect();
            //Get our Xbox Memory Stream
            XboxMemoryStream xbms = xdc.ReturnXboxMemoryStream();
            //Initialize our Endian IO
            EndianIO IO = new EndianIO(xbms, EndianType.BigEndian);

            //Open our IO
            IO.Open();
            //Loop through every RTH Data Block
            for (int index = 0; index < RTH_Data.RTH_Data_Blocks.Count; index++)
            {
                //Go to that RTH Data Block's memory offset
                IO.Out.BaseStream.Position = RTH_Data.RTH_Data_Blocks[index].Memory_Offset;
                //Write our data
                IO.Out.Write(RTH_Data.RTH_Data_Blocks[index].Data_Block);
            }
            //Close our IO
            IO.Close();
            //Close our Xbox Memory Stream
            xbms.Close();
            //Disconnect from our Xbox Development Kit
            xdc.Disconnect();
        }
Exemplo n.º 20
0
 /// <summary>
 /// This form of initialization for the RTH Data Header will read an existing RTH Data file.
 /// </summary>
 /// <param name="IO">The stream from which to read the RTH Data Header</param>
 public RTHDataHeader(EndianIO IO)
 {
     //Go to offset 0
     IO.In.BaseStream.Position = 0;
     //Verify its an RTH Patch
     if (IO.In.ReadAsciiString(4) != HeaderString)
     {
         throw new Exception(
                   "The following RTH Patch is an invalid patch and therefore will not be read/applied/handled.");
     }
     //Verify our version
     if (IO.In.ReadSingle() != Version)
     {
         throw new Exception(
                   "The following RTH Patch is of a different version and it's architecture has most likely been updated, therefore the patch will and most likely cannot be applied.");
     }
     //Read our datablock count
     _datablockcount = IO.In.ReadInt32();
     //Read our patch type
     Patch_Type = (PatchType)IO.In.ReadInt32();
     //Read our Author Name
     Author_Name = IO.In.ReadAsciiString(32);
     //Read our patch description
     Patch_Description = IO.In.ReadAsciiString(256);
     //Read our author IP
     _watermark = IO.In.ReadAsciiString(16);
 }
Exemplo n.º 21
0
        private void HandleClient(object cObj)
        {
            TcpClient Client = (TcpClient)cObj;

            Tmp.Entry Entry = new Tmp.Entry();
            GlobalVar.nStream = Client.GetStream();

            byte[] Header = new byte[8];
            Entry.IP = Client.Client.RemoteEndPoint.ToString().Split(':')[0];
            GlobalFunc.Write("Client [{0}] - Connected", Entry.IP);

            using (PoorManStream pmStream = new PoorManStream(GlobalVar.nStream)) {
                using (EndianIO MainIO = new EndianIO(Header, EndianStyle.BigEndian)) {
                    if (GlobalVar.nStream.Read(Header, 0, 8) != 8)
                    {
                        GlobalFunc.WriteError(ConsoleColor.Red, "[SERVER]", "Header recieved unexpected size!"); Client.Close();
                    }
                    uint   Command    = MainIO.Reader.ReadUInt32();
                    int    PacketSize = MainIO.Reader.ReadInt32();
                    byte[] Buffer     = new byte[PacketSize];
                    using (EndianIO WriterIO = new EndianIO(pmStream, EndianStyle.BigEndian)) {
                        using (EndianIO ReaderIO = new EndianIO(Buffer, EndianStyle.BigEndian)
                        {
                            Writer = new EndianWriter(pmStream, EndianStyle.BigEndian)
                        }) {
                            if (pmStream.Read(Buffer, 0, PacketSize) != PacketSize)
                            {
                                GlobalFunc.WriteError(ConsoleColor.Red, "[SERVER]", "Packet recieved unexpected size!"); Client.Close();
                            }

                            switch (Command)
                            {
                            case (uint)cmdCode.GET_SESSION: SESSION.Get(ref Entry, WriterIO, ReaderIO); break;

                            case (uint)cmdCode.GET_STATUS: STATUS.Get(ref Entry, WriterIO, ReaderIO); break;

                            case (uint)cmdCode.GET_CHAL_RESPONSE: break;

                            case (uint)cmdCode.UPDATE_PRESENCE: PRESENCE.Update(ref Entry, WriterIO, ReaderIO); break;

                            case (uint)cmdCode.GET_XOSC: break;

                            case (uint)cmdCode.GET_INFO: break;

                            case (uint)cmdCode.SND_SPOOFY: break;

                            case (uint)cmdCode.GET_MESSAGE: break;

                            case (uint)cmdCode.GET_PATCHES: break;

                            case (uint)cmdCode.GET_GUIDE_INFO: break;

                            default: break;
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
        private void ChangeHaloODSTFillMode()
        {
            //If the user didnt set the XDK name.
            if (AppSettings.Settings.XDKName == "")
            {
                //Show our error.
                MessageBox.Show(
                    "The Xbox Development Kit could not be connected to because it's means of connection were not set.");

                //Stop processing code in this stub.
                return;
            }

            //Initialize our Xbox Debug Communicator, with our XDK name/IP.
            XboxDebugCommunicator xdc = new XboxDebugCommunicator(AppSettings.Settings.XDKName);

            //Connect to our Xbox Debug Communicator.
            xdc.Connect();

            //Create an Xbox Memory Stream.
            XboxMemoryStream xbms = xdc.ReturnXboxMemoryStream();

            //Create an endian IO for our Memory Stream.
            EndianIO IO = new EndianIO(xbms, EndianType.BigEndian);

            //Open our IO.
            IO.Open();

            //Go to the address of the fillmode.
            IO.SeekTo(0x821A8C60);

            //If our solid item is checked.
            if (menuButtonItem32.Checked)
            {
                //Write our solid value.
                IO.Out.Write(0x38800000);
            }

            //Otherwise if our Point item is checked.
            else if (menuButtonItem33.Checked)
            {
                //Write our point value.
                IO.Out.Write(0x38800001);
            }

            //Otherwise if our Wireframe item is checked.
            else if (menuButtonItem34.Checked)
            {
                //Write our wireframe value.
                IO.Out.Write(0x38800025);
            }

            //Close our IO.
            IO.Close();

            //Disconnect from our Xbox.
            xdc.Disconnect();
        }
Exemplo n.º 23
0
 public void OpenIO()
 {
     //Close our IO first incase.
     CloseIO();
     //Initialize our IO
     IO = new EndianIO(FileName, EndianType.BigEndian);
     //Open our IO
     IO.Open();
 }
Exemplo n.º 24
0
        public static void ProcessPresence(ClientHandler.ioData io, ref CLIENT_STRUCT ClientObj)
        {
            string SessionToken = Utilities.BytesToString(io.reader.ReadBytes(0x10));
            string TitleID      = io.reader.ReadUInt32().ToString("X");

            byte[] GamerTag        = io.reader.ReadBytes(0x10);
            string ConsoleKvStatus = io.reader.ReadUInt32().ToString("X");

            byte[]       PresBuffer = new byte[0x8]; //0x8
            EndianWriter Data       = new EndianIO(PresBuffer, EndianStyle.BigEndian).Writer;

            bool ClientFound = MySql.GetClient(ref ClientObj, SessionToken);

            if (ClientFound)
            {
                ClientObj.titleid       = Utilities.TitleID(TitleID);
                ClientObj.ip            = io.ipaddr.Address.ToString().Split(new char[] { ':' })[0];
                ClientObj.lastloginTime = DateTime.Now;
                ClientObj.gamertag      = Utilities.Validategamertag(GamerTag);

                Data.Write((int)PACKET_STATUS.SUCCESS);

                if (ClientObj.consoleaction != CLIENT_ACTION.DEFAULT && ClientObj.actioncompleted == CLIENT_ACTION_COMPLETED.AWAITING)
                {
                    if (ClientObj.consoleaction == CLIENT_ACTION.DEFAULT)
                    {
                        Data.Write((int)CLIENT_ACTION.DEFAULT);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.REBOOT)
                    {
                        Data.Write((int)CLIENT_ACTION.REBOOT);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.RROD)
                    {
                        Data.Write((int)CLIENT_ACTION.RROD);
                    }
                    else if (ClientObj.consoleaction == CLIENT_ACTION.SENDTODASH)
                    {
                        Data.Write((int)CLIENT_ACTION.SENDTODASH);
                    }
                }
                else
                {
                    Data.Write((int)CLIENT_ACTION.DEFAULT);
                }
            }
            else
            {
                Data.Write((int)PACKET_STATUS.ERROR);
                Data.Write((int)CLIENT_ACTION.DEFAULT);
            }
            io.writer.Write(PresBuffer);

            Utilities.Update_LiveStatus(ConsoleKvStatus, ref ClientObj);
            MySql.SaveClient(ClientObj, SessionToken);
            MySql.UpdateKvThread(ClientObj);
        }
Exemplo n.º 25
0
        public static void LoadPluginValues(HaloMap Map, Panel parentPanel, int parentOffset)
        {
            if (!((parentOffset <= 0) | (parentOffset > Map.Map_Header.fileSize)))
            {
                EndianIO iO = Map.IO;
                for (int i = 0; i < parentPanel.Controls.Count; i++)
                {
                    if (!((Map.IO != null) && Map.IO.Opened))
                    {
                        Map.OpenIO();
                    }
                    switch (parentPanel.Controls[i].Name)
                    {
                    case "uiTagBlock":
                        ((uiTagBlock)parentPanel.Controls[i]).LoadStructure(Map, parentOffset);
                        break;

                    case "uiBitmask":
                        ((uiBitmask)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiValue":
                        ((uiValue)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiSlider":
                        ((uiSlider)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiEnum":
                        ((uiEnum)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiIdent":
                        ((uiIdent)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiByteArray":
                        ((uiByteArray)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiTagData":
                        ((uiTagData)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiColor":
                        ((uiColor)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;

                    case "uiStringID":
                        ((uiStringID)parentPanel.Controls[i]).LoadValue(Map, parentOffset);
                        break;
                    }
                }
                Map.CloseIO();
            }
        }
        private void buttonX9_Click(object sender, EventArgs e)
        {
            //If the Xbox_Debug_Communicator isn't null
            if (Xbox_Debug_Communicator != null)
            {
                //If it is connected..
                if (Xbox_Debug_Communicator.Connected)
                {
                    //Get our memory stream.
                    XboxMemoryStream xms = Xbox_Debug_Communicator.ReturnXboxMemoryStream();

                    //Create our IO
                    EndianIO IO = new EndianIO(xms, EndianType.BigEndian);

                    //Open our IO
                    IO.Open();

                    //Go to our offset
                    IO.In.BaseStream.Position = 0x3A00C000 + 0x1A874;

                    //Read our macbin
                    byte[] macbin = IO.In.ReadBytes(0x1D0);

                    //Close our IO
                    IO.Close();

                    //Create our savefiledialog
                    SaveFileDialog sfd = new SaveFileDialog();

                    //Set our filter
                    sfd.Filter = "Mac Bin(.bin)|*.bin";

                    //Show our dialog, if the result is OK
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        //Create our IO
                        IO = new EndianIO(new FileStream(sfd.FileName, FileMode.Create), EndianType.BigEndian);

                        //Open our IO
                        IO.Open();

                        //Write our macbin data.
                        IO.Out.Write(macbin);

                        //Close our IO
                        IO.Close();

                        //Show our messagebox
                        MessageBox.Show("Done.");
                    }
                    return;
                }
            }

            //We aren't connected
            MessageBox.Show("You are not connected.");
        }
Exemplo n.º 27
0
        public void SaveValue(EndianIO IO, int parentOffset)
        {
            IO.Out.BaseStream.Position = parentOffset + ValueData.Offset;
            int r = pictureBox1.BackColor.R;
            int g = pictureBox1.BackColor.G;
            int b = pictureBox1.BackColor.B;
            int a = pictureBox1.BackColor.A;

            foreach (ColorBlockPart part in ValueData.Color_Order)
            {
                int num5 = 0;
                switch (part)
                {
                case ColorBlockPart.Red:
                    num5 = r;
                    break;

                case ColorBlockPart.Green:
                    num5 = g;
                    break;

                case ColorBlockPart.Blue:
                    num5 = b;
                    break;

                case ColorBlockPart.Alpha:
                    num5 = a;
                    break;
                }
                switch (ValueData.Attributes)
                {
                case mValue.ObjectAttributes.ColorBlock8:
                    IO.Out.Write((byte)num5);
                    break;

                case mValue.ObjectAttributes.ColorBlock16:
                    IO.Out.Write((short)num5);
                    break;

                case mValue.ObjectAttributes.ColorBlock32:
                    IO.Out.Write(num5);
                    break;

                case mValue.ObjectAttributes.ColorBlockF:
                {
                    float num6 = num5;
                    if (ValueData.Real_Color)
                    {
                        num6 /= 255f;
                    }
                    IO.Out.Write(num6);
                    break;
                }
                }
            }
        }
Exemplo n.º 28
0
        private void GET_SESSION(ref TmpEntry entry, EndianIO readerIO, EndianIO writerIO)
        {
            bool conType = Convert.ToBoolean(readerIO.Reader.ReadInt32());

            entry.client_cpukey = readerIO.Reader.ReadBytes(0x10).BytesToHexString();

            if (conMySQL.getConsole(ref entry))
            {
                entry.client_ip      = IPAddr;
                entry.client_session = Security.RandomBytes(0x10).BytesToHexString();
                conMySQL.setConsole(ref entry);
                GlobalFunc.Write(entry.client_session);

                //if (entry.client_daysUsed >= 1 && entry.client_ip != entry.client_db_curIP) {
                //    entry.client_db_lastIP = entry.client_db_curIP;
                //    conMySQL.addNewIP(ref entry);
                //} else if (entry.client_db_curIP == "")
                //    conMySQL.addNewIP(ref entry);

                if (entry.client_banned)
                {
                    GlobalFunc.Write("Client [{0}] Banned Client Connected\r\n          - Name: {1}\r\n          - CPUkey: {2}", IPAddr, entry.client_name, entry.client_cpukey);
                    writerIO.Writer.Write((uint)respCode.RESP_STATUS_BANNED);
                    conMySQL.setConsole(ref entry);
                    return;
                }

                if (entry.client_enabled)
                {
                    GlobalFunc.Write("Client [{0}] Authorized Client's {1}\r\n          - Name: {2}\r\n          - CPUkey: {3}", IPAddr, conType ? "Devkit" : "Jtag/RGH", entry.client_name, entry.client_cpukey);
                    writerIO.Writer.Write((uint)respCode.RESP_STATUS_STEALTHED);
                    writerIO.Writer.Write(Misc.HexStringToBytes(entry.client_session));
                }
                else
                {
                    if (conMySQL.autoUpdateTime(ref entry))
                    {
                        //if (entry.client_days <= 100) {
                        GlobalFunc.Write("Client [{0}] Day Incrimented On Time[24 Hr Timer]\r\n          - Name: {1}\r\n          - CPUKey: {2}", IPAddr, entry.client_name, entry.client_cpukey);
                        writerIO.Writer.Write((uint)respCode.RESP_STATUS_DAY_STARTED);
                        //} else writerIO.Writer.Write((uint)respCode.RESP_STATUS_STEALTHED);
                        writerIO.Writer.Write(Misc.HexStringToBytes(entry.client_session));
                    }
                    else
                    {
                        GlobalFunc.Write("Client [{0}] Time Expired!\r\n          - Name: {1}\r\n          - CPUKey: {2}", IPAddr, entry.client_name, entry.client_cpukey);
                        writerIO.Writer.Write((uint)respCode.RESP_STATUS_EXPIRED);
                    }
                } conMySQL.setConsole(ref entry);
            }
            else
            {
                GlobalFunc.Write("Client [{0}] Failed! CPUKey - {1}", IPAddr, entry.client_cpukey);
                writerIO.Writer.Write((uint)respCode.RESP_STATUS_EXPIRED);
            }
        }
Exemplo n.º 29
0
        public BLFImageFile(Stream stream)
        {
            EndianIO iO = new EndianIO(stream, EndianType.BigEndian);

            iO.Open();
            this.BLFHeader = new BLF_Header(iO, 0);
            this.BLFImage  = Image.FromStream(new MemoryStream(iO.In.ReadBytes(this.BLFHeader.FileContentSize)));
            this.EOFFooter = new EOF_Footer(iO, (int)iO.In.BaseStream.Position);
            iO.Close();
        }
Exemplo n.º 30
0
        public Package(EndianIO io)
        {
            short           BaseVersion = io.ReadInt16();
            PackagePlatform Platform    = (PackagePlatform)io.ReadInt16();
            ushort          EntryCount  = io.ReadUInt16(); // max = 0xFFFF

#if DEBUG
            Verify(io);
#endif
        }
Exemplo n.º 31
0
 public KeyVault(EndianIO IO)
 {
     this.IO = IO;
     this.IO.Open();
 }
Exemplo n.º 32
0
 public static byte[] ValueToBytes(float data, EndianType et)
 {
     var ms = new MemoryStream();
     var io = new EndianIO(ms, et);
     io.Open();
     io.Writer.Write(data);
     io.Reader.BaseStream.Position = 0;
     var array = io.Reader.ReadBytes((int)io.Reader.BaseStream.Length);
     io.Close();
     ms.Close();
     return array;
 }