Пример #1
0
 public void VisitDataRef(DataRef field)
 {
     // AvalonEdit doesn't let us access the text from a different thread
     /*if (!FilterString(field, field.Name))
         FilterString(field, field.Value);*/
     FilterString(field, field.Name);
 }
Пример #2
0
        public void VisitDataRef(DataRef field)
        {
            // AvalonEdit doesn't let us access the text from a different thread

            /*if (!FilterString(field, field.Name))
             * FilterString(field, field.Value);*/
            FilterString(field, field.Name);
        }
Пример #3
0
        public void VisitDataRef(DataRef field)
        {
            var values = new StructureValueCollection();

            values.SetInteger("size", (uint)field.Length);

            SeekToOffset(field.Offset);
            StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

            if (field.DataAddress == 0xFFFFFFFF || field.DataAddress <= 0)
            {
                return;
            }

            // Go to the data location
            uint offset     = field.DataAddress;
            uint dataOffset = offset;

            switch (_type)
            {
            case SaveType.Memory:
            {
                if (_cache.GetType() != typeof(Blamite.Blam.FourthGen.FourthGenCacheFile))
                {
                    values.SetInteger("pointer", offset);
                }
                break;
            }

            case SaveType.File:
            {
                if (_cache.GetType() == typeof(Blamite.Blam.FourthGen.FourthGenCacheFile))
                {
                    offset = offset - _headerOffset + 0x40000000;
                }
                values.SetInteger("pointer", offset);
                dataOffset = (uint)_cache.MetaArea.PointerToOffset(dataOffset);
                break;
            }
            }
            _writer.SeekTo(dataOffset);

            // Write its data
            switch (field.Format)
            {
            default:
                _writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
                break;

            case "unicode":
                _writer.WriteUTF16(field.Value);
                break;

            case "asciiz":
                _writer.WriteAscii(field.Value);
                break;
            }
        }
Пример #4
0
        public void ReadDataRefContents(DataRef field)
        {
            if (field.Length < 0)
            {
                return;
            }

            bool opened = OpenReader();

            if (_reader == null)
            {
                return;
            }

            try
            {
                // Calculate the base offset to read from
                long oldBaseOffset = BaseOffset;
                long dataOffset    = field.DataAddress;
                if (_type == LoadType.File)
                {
                    dataOffset = (uint)_cache.MetaArea.PointerToOffset(dataOffset);
                }

                _reader.SeekTo(dataOffset);

                switch (field.Format)
                {
                default:
                    byte[] data = _reader.ReadBlock(field.Length);
                    field.Value = FunctionHelpers.BytesToHexString(data);
                    break;

                case "utf16":
                    field.Value = _reader.ReadUTF16(field.Length);
                    break;

                case "asciiz":
                    field.Value = _reader.ReadAscii(field.Length);
                    break;
                }

                BaseOffset = oldBaseOffset;
            }
            finally
            {
                if (opened)
                {
                    CloseReader();
                }
            }
        }
Пример #5
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            StructureValueCollection values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            var  length  = (int)values.GetInteger("size");
            uint pointer = values.GetInteger("pointer");

            if (length > 0)
            {
                if (_cache.GetType() == typeof(Blamite.Blam.FourthGen.FourthGenCacheFile))
                {
                    pointer = HeaderOffset + (pointer & 0xFFFFFFF);
                }

                field.DataAddress = pointer;
                field.Length      = length;

                // Go to position
                if (_type == LoadType.Memory)
                {
                    _reader.SeekTo(pointer);
                }
                else
                {
                    _reader.SeekTo(_cache.MetaArea.PointerToOffset(pointer));
                }

                switch (field.Format)
                {
                default:
                    byte[] data = _reader.ReadBlock(field.Length);
                    field.Value = FunctionHelpers.BytesToHexString(data);
                    break;

                case "unicode":
                    field.Value = _reader.ReadUTF16(field.Length);
                    break;

                case "asciiz":
                    field.Value = _reader.ReadAscii(field.Length);
                    break;
                }
            }
            else
            {
                field.DataAddress = 0;
                field.Length      = 0;
                field.Value       = "";
            }
        }
Пример #6
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            StructureValueCollection values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            var  length  = (int)values.GetInteger("size");
            uint pointer = (uint)values.GetInteger("pointer");

            long expanded = _cache.PointerExpander.Expand(pointer);

            if (length > 0 && _cache.MetaArea.ContainsBlockPointer(expanded, length))
            {
                field.DataAddress = expanded;
                field.Length      = length;

                // Go to position
                if (_type == LoadType.Memory)
                {
                    _reader.SeekTo(expanded);
                }
                else
                {
                    _reader.SeekTo(_cache.MetaArea.PointerToOffset(expanded));
                }

                switch (field.Format)
                {
                default:
                    byte[] data = _reader.ReadBlock(field.Length);
                    field.Value = FunctionHelpers.BytesToHexString(data);
                    break;

                case "unicode":
                    field.Value = _reader.ReadUTF16(field.Length);
                    break;

                case "asciiz":
                    field.Value = _reader.ReadAscii(field.Length);
                    break;
                }
            }
            else
            {
                field.DataAddress = 0;
                field.Length      = 0;
                field.Value       = "";
            }
        }
Пример #7
0
        public void VisitDataRef(DataRef field)
        {
            var  values  = new StructureValueCollection();
            bool isValid = _cache.MetaArea.ContainsBlockPointer(field.DataAddress, field.Length);

            values.SetInteger("size", isValid ? (uint)field.Length : 0);

            uint cont = _cache.PointerExpander.Contract(field.DataAddress);

            values.SetInteger("pointer", isValid ? cont : 0);

            SeekToOffset(field.Offset);
            StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

            if (isValid)
            {
                // Go to the data location
                long offset = field.DataAddress;
                if (_type == SaveType.File)
                {
                    offset = _cache.MetaArea.PointerToOffset(offset);
                }
                _writer.SeekTo(offset);

                // Build the data
                byte[] buffer = new byte[field.Length];
                byte[] bytes;

                switch (field.Format)
                {
                default:
                    bytes = FunctionHelpers.HexStringToBytes(field.Value);
                    break;

                case "utf16":
                    bytes = Encoding.GetEncoding(1200).GetBytes(field.Value);
                    break;

                case "asciiz":
                    bytes = Encoding.GetEncoding(28591).GetBytes(field.Value);
                    break;
                }

                Array.Copy(bytes, buffer, bytes.Length > field.Length ? field.Length : bytes.Length);
                _writer.WriteBlock(buffer, 0, buffer.Length);
            }
        }
Пример #8
0
        public void VisitDataRef(DataRef field)
        {
            var values = new StructureValueCollection();

            values.SetInteger("size", (uint)field.Length);

            uint cont = _cache.PointerExpander.Contract(field.DataAddress);

            values.SetInteger("pointer", cont);

            SeekToOffset(field.Offset);
            StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

            if (field.DataAddress == 0xFFFFFFFF || field.DataAddress <= 0)
            {
                return;
            }

            // Go to the data location
            long offset = field.DataAddress;

            if (_type == SaveType.File)
            {
                offset = _cache.MetaArea.PointerToOffset(offset);
            }
            _writer.SeekTo(offset);

            // Write its data
            switch (field.Format)
            {
            default:
                _writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
                break;

            case "unicode":
                _writer.WriteUTF16(field.Value);
                break;

            case "asciiz":
                _writer.WriteAscii(field.Value);
                break;
            }
        }
Пример #9
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            _writer.WriteInt32(field.Length); // Data size
            _writer.Skip(2 * 4); // Skip two unused values
            _writer.WriteUInt32(field.Address); // Address

            if (field.Address != 0xFFFFFFFF && field.Address > 0)
            {
                // Go to the data location
                uint offset = field.Address;
                if (_type == SaveType.File)
                    offset = _cache.MetaPointerConverter.AddressToOffset(offset);
                _writer.SeekTo(offset);

                // Write its data
                _writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
            }
        }
Пример #10
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            StructureValueCollection values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            var  length  = (int)values.GetInteger("size");
            uint pointer = (uint)values.GetInteger("pointer");

            long expanded = _cache.PointerExpander.Expand(pointer);

            if (length > 0 && _cache.MetaArea.ContainsBlockPointer(expanded, length))
            {
                field.DataAddress = expanded;
                field.Length      = length;
            }
            else
            {
                field.DataAddress = 0;
                field.Length      = 0;
                field.Value       = "";
            }
        }
Пример #11
0
        public void VisitDataRef(DataRef field)
        {
            var values = new StructureValueCollection();
            values.SetInteger("size", (uint)field.Length);
            values.SetInteger("pointer", field.FieldAddress);

            SeekToOffset(field.Offset);
            StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

            if (field.DataAddress == 0xFFFFFFFF || field.DataAddress <= 0) return;

            // Go to the data location
            var offset = field.DataAddress;
            if (_type == SaveType.File)
                offset = (uint)_cache.MetaArea.PointerToOffset(offset);
            _writer.SeekTo(offset);

            // Write its data
            _writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
        }
Пример #12
0
 public void VisitDataRef(DataRef field)
 {
 }
Пример #13
0
 public void VisitDataRef(DataRef field)
 {
     AddWidth(_rawBlock.Width);
 }
Пример #14
0
        public void VisitDataRef(DataRef field)
        {
            var values = new StructureValueCollection();
            values.SetInteger("size", (uint) field.Length);
            values.SetInteger("pointer", field.DataAddress);

            SeekToOffset(field.Offset);
            StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

            if (field.DataAddress == 0xFFFFFFFF || field.DataAddress <= 0) return;

            // Go to the data location
            uint offset = field.DataAddress;
            if (_type == SaveType.File)
                offset = (uint) _cache.MetaArea.PointerToOffset(offset);
            _writer.SeekTo(offset);

            // Write its data
            switch (field.Format)
            {
                default:
                    _writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
                    break;
                case "unicode":
                    _writer.WriteUTF16(field.Value);
                    break;
                case "asciiz":
                    _writer.WriteAscii(field.Value);
                    break;
            }
        }
Пример #15
0
		public void VisitDataRef(DataRef field)
		{
			var values = new StructureValueCollection();
			values.SetInteger("size", (uint) field.Length);

			SeekToOffset(field.Offset);
			StructureWriter.WriteStructure(values, _dataRefLayout, _writer);

			if (field.DataAddress == 0xFFFFFFFF || field.DataAddress <= 0) return;

			// Go to the data location
			uint offset = field.DataAddress;
			uint dataOffset = offset;

			switch (_type)
			{
				case SaveType.Memory:
					{
						if (_cache.GetType() != typeof(Blamite.Blam.FourthGen.FourthGenCacheFile))
							values.SetInteger("pointer", offset);
						break;
					}
				case SaveType.File:
					{
						if (_cache.GetType() == typeof(Blamite.Blam.FourthGen.FourthGenCacheFile))
							offset = offset - _headerOffset + 0x40000000;
						values.SetInteger("pointer", offset);
						dataOffset = (uint)_cache.MetaArea.PointerToOffset(dataOffset);
						break;
					}
			}
			_writer.SeekTo(dataOffset);

			// Write its data
			switch (field.Format)
			{
				default:
					_writer.WriteBlock(FunctionHelpers.HexStringToBytes(field.Value), 0, field.Length);
					break;
				case "unicode":
					_writer.WriteUTF16(field.Value);
					break;
				case "asciiz":
					_writer.WriteAscii(field.Value);
					break;
			}
		}
Пример #16
0
        public override MetaField CloneValue()
        {
            var result = new DataRef(Name, Offset, Format, FieldAddress, DataAddress, Value, Length, PluginLine, ToolTip, _metaArea);

            return(result);
        }
Пример #17
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            var values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            var length = (int)values.GetInteger("size");
            var pointer = values.GetInteger("pointer");
            field.DataAddress = pointer;

            // Check if the pointer is valid
            if (length > 0 && _cache.MetaArea.ContainsPointer(pointer))
            {
                field.Length = length;

                // Go to position
                var offset = pointer;
                if (_type == LoadType.File)
                    offset = (uint)_cache.MetaArea.PointerToOffset(offset);
                _reader.SeekTo(offset);

                switch (field.Format)
                {
                    default:
                        var data = _reader.ReadBlock(field.Length);
                        field.Value = FunctionHelpers.BytesToHexLines(data, 24);
                        break;
                    case "unicode":
                        field.Value = _reader.ReadUTF16(field.Length);
                        break;
                    case "asciiz":
                        field.Value = _reader.ReadAscii(field.Length);
                        break;
                }
            }
            else
            {
                field.Length = 0;
            }
        }
Пример #18
0
 public void VisitDataRef(DataRef field)
 {
 }
Пример #19
0
 public void VisitDataRef(DataRef field)
 {
     AddWidth(_rawBlock.Width);
 }
Пример #20
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            StructureValueCollection values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            var length = (int) values.GetInteger("size");
            uint pointer = values.GetInteger("pointer");

            if (length > 0 && _cache.MetaArea.ContainsBlockPointer(pointer, length))
            {
                field.DataAddress = pointer;
                field.Length = length;

                // Go to position
                if (_type == LoadType.Memory)
                    _reader.SeekTo(pointer);
                else
                    _reader.SeekTo(_cache.MetaArea.PointerToOffset(pointer));

                switch (field.Format)
                {
                    default:
                        byte[] data = _reader.ReadBlock(field.Length);
                        field.Value = FunctionHelpers.BytesToHexString(data);
                        break;
                    case "unicode":
                        field.Value = _reader.ReadUTF16(field.Length);
                        break;
                    case "asciiz":
                        field.Value = _reader.ReadAscii(field.Length);
                        break;
                }
            }
            else
            {
                field.DataAddress = 0;
                field.Length = 0;
                field.Value = "";
            }
        }
Пример #21
0
        public void VisitDataRef(DataRef field)
        {
            SeekToOffset(field.Offset);
            StructureValueCollection values = StructureReader.ReadStructure(_reader, _dataRefLayout);

            int length = (int)values.GetInteger("size");
            uint pointer = values.GetInteger("pointer");
            field.DataAddress = pointer;

            // Check if the pointer is valid
            uint offset = (uint)_cache.MetaArea.PointerToOffset(pointer);
            int metaStartOff = _cache.MetaArea.Offset;
            int metaEndOff = metaStartOff + _cache.MetaArea.Size;
            if (length > 0 && offset >= metaStartOff && offset + field.Length <= metaEndOff)
            {
                field.Length = length;

                // Go to position
                _reader.SeekTo(offset);

                // Read Data
                byte[] data = _reader.ReadBlock(field.Length);

                // Convert to hex string
                field.Value = FunctionHelpers.BytesToHexLines(data, 24);
            }
            else
            {
                field.Length = 0;
            }
        }
Пример #22
0
 public void VisitDataRef(DataRef field)
 {
     field.PropertyChanged += DataRefPropertyChanged;
 }
Пример #23
0
 public override MetaField CloneValue()
 {
     DataRef result = new DataRef(Name, Offset, _address, Value, Length, base.PluginLine);
     return result;
 }
Пример #24
0
        public void VisitDataRef(DataRef field)
        {
            // Go to length offset
            SeekToOffset(field.Offset);

            // Read length
            field.Length = _reader.ReadInt32();

            // Skip 2 unknown int32's
            _reader.ReadBlock(0x08);

            // Read the memory address
            field.Address = _reader.ReadUInt32();

            // Check if memory address is valid
            uint metaStartAddr = _cache.Info.MetaBase.AsAddress();
            uint metaEndAddr = metaStartAddr + _cache.Info.MetaSize;
            if (field.Length > 0 && field.Address >= metaStartAddr && field.Address + field.Length <= metaEndAddr)
            {
                // Go to position
                _reader.SeekTo(_cache.MetaPointerConverter.PointerToOffset(field.Address));

                // Read Data
                byte[] data = _reader.ReadBlock(field.Length);

                // Convert to hex string
                field.Value = ExtryzeDLL.Util.FunctionHelpers.BytesToHexLines(data, 24);
            }
        }