Example #1
0
        public string getValue(uint offset, string type)
        {
            string hex = "X";
            object rn  = null;
            XboxDebugCommunicator Xbox_Debug_Communicator = new XboxDebugCommunicator(new XboxManager().DefaultConsole);

            //Connect
            if (Xbox_Debug_Communicator.Connected == false)
            {
                try
                {
                    Xbox_Debug_Communicator.Connect();
                }
                catch { }
            }

            XboxMemoryStream xbms = Xbox_Debug_Communicator.ReturnXboxMemoryStream();

            //Endian IO
            HaloReach3d.IO.EndianIO IO = new HaloReach3d.IO.EndianIO(xbms,
                                                                     HaloReach3d.IO.EndianType.BigEndian);
            IO.Open();
            IO.In.BaseStream.Position = offset;

            if (type == "String" | type == "string")
            {
                rn = IO.In.ReadString();
            }
            if (type == "Float" | type == "float")
            {
                rn = IO.In.ReadSingle();
            }
            if (type == "Double" | type == "double")
            {
                rn = IO.In.ReadDouble();
            }
            if (type == "Short" | type == "short")
            {
                rn = IO.In.ReadInt16().ToString(hex);
            }
            if (type == "Byte" | type == "byte")
            {
                rn = IO.In.ReadByte().ToString(hex);
            }
            if (type == "Long" | type == "long")
            {
                rn = IO.In.ReadInt32().ToString(hex);
            }
            if (type == "Quad" | type == "quad")
            {
                rn = IO.In.ReadInt64().ToString(hex);
            }

            IO.Close();
            xbms.Close();
            Xbox_Debug_Communicator.Disconnect();

            return(rn.ToString());
        }
Example #2
0
        public static void PokePatch(string originalMap, string patchPath)
        {
            XboxDebugCommunicator debugCommunicator = new XboxDebugCommunicator(AppSettings.Settings.IP_and_XDK_Name);

            if (!debugCommunicator.Connected)
            {
                try
                {
                    debugCommunicator.Connect();
                }
                catch
                {
                }
            }
            XboxMemoryStream xboxMemoryStream = debugCommunicator.ReturnXboxMemoryStream();

            debugCommunicator.Disconnect();
            HaloReach3d.IO.EndianIO endianIo = new HaloReach3d.IO.EndianIO((Stream)xboxMemoryStream, HaloReach3d.IO.EndianType.BigEndian);
            endianIo.Open();
            HaloMap haloMap = new HaloMap(originalMap);

            haloMap.ReloadMap();
            int mapMagic = haloMap.Map_Header.mapMagic;

            haloMap.CloseIO();
            BinaryReader binaryReader = new BinaryReader((Stream) new FileStream(patchPath, FileMode.Open, FileAccess.Read));

            try
            {
                while (binaryReader.BaseStream.Position != binaryReader.BaseStream.Length - 8L)
                {
                    int num   = binaryReader.ReadInt32();
                    int count = binaryReader.ReadInt32();
                    endianIo.Out.BaseStream.Position = (long)(num + mapMagic);
                    endianIo.Out.Write(binaryReader.ReadBytes(count));
                }
            }
            catch
            {
            }
            binaryReader.Close();
            endianIo.Close();
            xboxMemoryStream.Close();
        }
 public string PeekXbox(uint offset, string type)
 {
     if (isConnected)
     {
         string hex = "X";
         object rn  = null;
         if (xdkName != "")
         {
             if (!Xbox_Debug_Communicator.Connected)
             {
                 try
                 {
                     Xbox_Debug_Communicator.Connect();
                 }
                 catch
                 {
                 }
             }
             XboxMemoryStream        xbms = Xbox_Debug_Communicator.ReturnXboxMemoryStream();
             HaloReach3d.IO.EndianIO IO   = new HaloReach3d.IO.EndianIO(xbms, HaloReach3d.IO.EndianType.BigEndian);
             IO.Open();
             IO.In.BaseStream.Position = offset;
             if ((type == "String") | (type == "string"))
             {
                 rn = IO.In.ReadString();
             }
             if ((type == "Float") | (type == "float"))
             {
                 rn = IO.In.ReadSingle();
             }
             if ((type == "Double") | (type == "double"))
             {
                 rn = IO.In.ReadDouble();
             }
             if ((type == "Short") | (type == "short"))
             {
                 rn = IO.In.ReadInt16().ToString(hex);
             }
             if ((type == "Byte") | (type == "byte"))
             {
                 rn = IO.In.ReadByte().ToString(hex);
             }
             if ((type == "Long") | (type == "long"))
             {
                 rn = IO.In.ReadInt32().ToString(hex);
             }
             if ((type == "Quad") | (type == "quad"))
             {
                 rn = IO.In.ReadInt64().ToString(hex);
             }
             IO.Close();
             xbms.Close();
             return(rn.ToString());
         }
         MessageBox.Show("XDK Name/IP not set");
         return("No Console Detected");
     }
     else
     {
         Elysium.Notifications.NotificationManager.BeginTryPush("Error", "You are not connected to your XDK");
         return("Not Connected");
     }
 }
        public void PokeXbox(Offset offsetData)
        {
            uint   offset   = Convert.ToUInt32(offsetData.Address, 0x10);
            string poketype = offsetData.Type;
            string amount   = offsetData.Value;

            if (isConnected)
            {
                try
                {
                    if (!Xbox_Debug_Communicator.Connected)
                    {
                        try
                        {
                            Xbox_Debug_Communicator.Connect();
                        }
                        catch
                        {
                        }
                    }
                    XboxMemoryStream        xbms = Xbox_Debug_Communicator.ReturnXboxMemoryStream();
                    HaloReach3d.IO.EndianIO IO   = new HaloReach3d.IO.EndianIO(xbms, HaloReach3d.IO.EndianType.BigEndian);
                    IO.Open();
                    IO.Out.BaseStream.Position = offset;
                    if (poketype == "Unicode String")
                    {
                        IO.Out.WriteUnicodeString(amount, amount.Length);
                    }
                    if (poketype == "ASCII String")
                    {
                        IO.Out.WriteUnicodeString(amount, amount.Length);
                    }
                    if ((poketype == "String") | (poketype == "string"))
                    {
                        IO.Out.Write(amount);
                    }
                    if ((poketype == "Float") | (poketype == "float"))
                    {
                        IO.Out.Write(float.Parse(amount));
                    }
                    if ((poketype == "Double") | (poketype == "double"))
                    {
                        IO.Out.Write(double.Parse(amount));
                    }
                    if ((poketype == "Short") | (poketype == "short"))
                    {
                        IO.Out.Write((short)Convert.ToUInt32(amount, 0x10));
                    }
                    if ((poketype == "Byte") | (poketype == "byte"))
                    {
                        IO.Out.Write((byte)Convert.ToUInt32(amount, 0x10));
                    }
                    if ((poketype == "Long") | (poketype == "long"))
                    {
                        IO.Out.Write((long)Convert.ToUInt32(amount, 0x10));
                    }
                    if ((poketype == "Quad") | (poketype == "quad"))
                    {
                        IO.Out.Write((long)Convert.ToUInt64(amount, 0x10));
                    }
                    if ((poketype == "Int") | (poketype == "int"))
                    {
                        IO.Out.Write(Convert.ToUInt32(amount, 0x10));
                    }
                    IO.Close();
                    xbms.Close();
                    Elysium.Notifications.NotificationManager.BeginTryPush("Poked", "Poked " + amount + " to 0x" + offset.ToString("X"));
                }
                catch
                {
                    Elysium.Notifications.NotificationManager.BeginTryPush("Error", "Couldn't poke XDK. ");
                }
            }
            else
            {
                Elysium.Notifications.NotificationManager.BeginTryPush("Error", "You are not connected to your XDK. ");
            }
        }
Example #5
0
        public static unsafe void CreatePatch(string Orig, string ModdedMap, string PatchLocation)
        {
            HaloReach3d.IO.EndianIO endianIo1 = new HaloReach3d.IO.EndianIO(PatchLocation, HaloReach3d.IO.EndianType.LittleEndian);
            HaloReach3d.IO.EndianIO endianIo2 = new HaloReach3d.IO.EndianIO(ModdedMap, HaloReach3d.IO.EndianType.LittleEndian);
            HaloReach3d.IO.EndianIO endianIo3 = new HaloReach3d.IO.EndianIO(Orig, HaloReach3d.IO.EndianType.LittleEndian);
            endianIo3.Open();
            endianIo1.Open();
            endianIo2.Open();
            int val1   = 4096;
            int length = (int)endianIo2.Stream.Length;

            byte[] buffer1 = new byte[val1];
            byte[] buffer2 = new byte[val1];
            byte[] buffer3 = new byte[val1];
            endianIo3.In.BaseStream.Position = 0L;
            endianIo2.In.BaseStream.Position = 0L;
            fixed(byte *numPtr1 = buffer1)
            fixed(byte *numPtr2 = buffer2)
            fixed(byte *numPtr3 = buffer3)
            {
                int *numPtr4 = (int *)numPtr1;
                int *numPtr5 = (int *)numPtr2;
                int *numPtr6 = (int *)numPtr3;
                int  num1    = 0;

                while (num1 < length)
                {
                    int count1 = Math.Min(val1, length - num1);
                    if (endianIo3.In.BaseStream.Position + (long)val1 > endianIo3.In.BaseStream.Length)
                    {
                        buffer1 = new byte[val1];
                    }
                    else
                    {
                        endianIo3.In.Read(buffer1, 0, count1);
                    }
                    endianIo2.In.Read(buffer2, 0, count1);
                    for (int index = 0; index < count1 / 4; ++index)
                    {
                        if (numPtr4[index] != numPtr5[index] | endianIo3.In.BaseStream.Position + (long)val1 > endianIo3.In.BaseStream.Length)
                        {
                            int num2   = num1 + index * 4;
                            int count2 = 0;
                            while (index < count1 / 4 && numPtr4[index] != numPtr5[index] | endianIo3.In.BaseStream.Position + (long)val1 > endianIo3.In.BaseStream.Length)
                            {
                                numPtr6[count2 / 4] = numPtr5[index];
                                ++index;
                                count2 += 4;
                            }
                            endianIo1.Out.Write(num2);
                            endianIo1.Out.Write(count2);
                            endianIo1.Out.Write(buffer3, 0, count2);
                        }
                    }
                    num1 += val1;
                }
            }
            endianIo1.Close();
            endianIo2.Close();
            endianIo3.Close();
        }