public override string PackForRiivolution() { Address.AssertAbsolute(); Target.AssertAbsolute(); return(string.Format("<memory offset='0x{0:X8}' value='{1:X8}' />", Address.Value, GenerateInstruction())); }
public override string PackForRiivolution() { Address.AssertAbsolute(); if (ValueType == Type.Pointer) { Value.AssertAbsolute(); } else { Value.AssertValue(); } if (Original.HasValue) { Original.Value.AssertNotRelative(); switch (ValueType) { case Type.Value8: return(string.Format("<memory offset='0x{0:X8}' value='{1:X2}' original='{2:X2}' />", Address.Value, Value.Value, Original.Value.Value)); case Type.Value16: return(string.Format("<memory offset='0x{0:X8}' value='{1:X4}' original='{2:X4}' />", Address.Value, Value.Value, Original.Value.Value)); case Type.Value32: case Type.Pointer: return(string.Format("<memory offset='0x{0:X8}' value='{1:X8}' original='{2:X8}' />", Address.Value, Value.Value, Original.Value.Value)); } } else { switch (ValueType) { case Type.Value8: return(string.Format("<memory offset='0x{0:X8}' value='{1:X2}' />", Address.Value, Value.Value)); case Type.Value16: return(string.Format("<memory offset='0x{0:X8}' value='{1:X4}' />", Address.Value, Value.Value)); case Type.Value32: case Type.Pointer: return(string.Format("<memory offset='0x{0:X8}' value='{1:X8}' />", Address.Value, Value.Value)); } } return(null); }
public override void ApplyToDol(Dol dol) { Address.AssertAbsolute(); Target.AssertAbsolute(); switch (Id) { case Ids.Rel24: long delta = Target - Address; uint insn = dol.ReadUInt32(Address.Value) & 0xFC000003; insn |= ((uint)delta & 0x3FFFFFC); dol.WriteUInt32(Address.Value, insn); break; case Ids.Addr32: dol.WriteUInt32(Address.Value, Target.Value); break; case Ids.Addr16Lo: dol.WriteUInt16(Address.Value, (ushort)(Target.Value & 0xFFFF)); break; case Ids.Addr16Hi: dol.WriteUInt16(Address.Value, (ushort)(Target.Value >> 16)); break; case Ids.Addr16Ha: ushort v = (ushort)(Target.Value >> 16); if ((Target.Value & 0x8000) == 0x8000) { v++; } dol.WriteUInt16(Address.Value, v); break; default: throw new NotImplementedException("unrecognised relocation type"); } }