Ejemplo n.º 1
0
 public void Write(EndianWriter ew)
 {
     if (ew.Position + 32 > ew.Length)
     {
         ew.BaseStream.SetLength(ew.Position + 32);
     }
     ew.Write(fourcc, false);
     ew.Write(parent, false);
     ew.Write(grandparent, false);
     ew.Write(ew.Append(extension));
     ew.Write(headerLength);
     ew.Write(version);
     ew.Write(fieldCount  = fields.Length);
     ew.Write(fieldOffset = ew.Length);
     ew.Flush();
     ew.Position = fieldOffset;
     for (int x = 0; x < fieldCount; x++)
     {
         fields[x].Write(ew);
     }
 }
Ejemplo n.º 2
0
        public void EndianWriterCompatible_NonNativeEndian()
        {
            var stream = new MemoryStream();
            var writer = new EndianWriter(stream);
            var reader = new EndianReader(stream);

            writer.Endian = reader.Endian = Endian.NonNative;

            foreach (TestValue value in _testValuesWithBits)
            {
                value.Write(writer);
            }

            writer.Flush();
            stream.Position = 0;

            foreach (TestValue value in _testValuesWithBits)
            {
                value.Read(reader);
            }
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream stream = new FileStream(ofd.FileName, FileMode.Open);
                EndianReader reader = new EndianReader(stream, EndianType.BigEndian);
                EndianWriter writer = new EndianWriter(stream, EndianType.BigEndian);

                int CSum = 0;
                reader.BaseStream.Position = 0xD000;
                for (int i = 0; i < 0x768; i += 4)
                    CSum += reader.ReadInt32();

                writer.Write(CSum);
                writer.Flush();
                writer.Close();
                reader.Close();
                MessageBox.Show("New Checksum: " + CSum.ToString("X2"), "Done!");
            }
        }
Ejemplo n.º 4
0
            internal void Write(EndianWriter ew)
            {
                int pos = ew.Position;

                if (pos + 40 > ew.Length)
                {
                    ew.BaseStream.SetLength(pos + 40);
                }
                ew.Write(ew.Append(name));
                ew.Write(ew.Append(description));
                ew.Write(new Int24(offset, (byte)type));
                ew.Write(children.Length);
                ew.Write(0);
                ew.Write(options.Length);
                ew.Write(optionOffset = ew.Length);
                ew.Position           = ew.Length;
                ew.BaseStream.SetLength(ew.Length + (options.Length * 4));
                for (int x = 0; x < options.Length; x++)
                {
                    ew.Write(ew.Append(options[x]));
                }
                ew.Position = pos + 28;
                ew.Write(maxCount);
                ew.Write(size);
                ew.Position          = pos + 16;
                ew.Write(fieldOffset = ew.Length);
                ew.Position          = fieldOffset;
                for (int x = 0; x < children.Length; x++)
                {
                    children[x].Write(ew);
                }
                ew.Position         = pos + 36;
                ew.Write(nextOffset = ew.Length);
                ew.Flush();
                ew.Position = nextOffset;
            }
Ejemplo n.º 5
0
        private void button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                FileStream   stream = new FileStream(ofd.FileName, FileMode.Open);
                EndianReader reader = new EndianReader(stream, EndianType.BigEndian);
                EndianWriter writer = new EndianWriter(stream, EndianType.BigEndian);

                int CSum = 0;
                reader.BaseStream.Position = 0xD000;
                for (int i = 0; i < 0x768; i += 4)
                {
                    CSum += reader.ReadInt32();
                }

                writer.Write(CSum);
                writer.Flush();
                writer.Close();
                reader.Close();
                MessageBox.Show("New Checksum: " + CSum.ToString("X2"), "Done!");
            }
        }