public void AddressNotInDictionary() { RelocationDictionary rd = new RelocationDictionary(); rd.AddPointerReference(0x020, 0x12312312); Assert.IsNull(rd[0x3243232]); Assert.IsFalse(rd.Contains(0x2341231)); }
public void AddPointerRelocation() { RelocationDictionary rd = new RelocationDictionary(); rd.AddPointerReference(0x100400, 0x100500); Assert.AreEqual(1, rd.Count); Constant c = rd[0x0100400]; Assert.AreEqual("ptr32", c.DataType.ToString()); }
public void ApplyRelocation(uint baseOfImage, uint page, ImageReader rdr, RelocationDictionary relocations) { ushort fixup = rdr.ReadLeUInt16(); switch (fixup >> 12) { case RelocationAbsolute: // Used for padding to 4-byte boundary, ignore. break; case RelocationHighLow: { uint offset = page + (fixup & 0x0FFFu); uint n = (uint) (imgLoaded.ReadLeUInt32(offset) + (baseOfImage - preferredBaseOfImage.ToLinear())); imgLoaded.WriteLeUInt32(offset, n); relocations.AddPointerReference(offset, n); break; } case 0xA: break; default: throw new NotImplementedException(string.Format("Fixup type: {0:X}", fixup >> 12)); } }