public void AddWorksWithOverlap8() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0000, 0x01FF, MemorySectionType.ByteArray)); mm.Add(new MemorySection(0x0300, 0x03FF, MemorySectionType.ByteArray)); mm.Add(new MemorySection(0x0500, 0x05FF, MemorySectionType.ByteArray)); mm.Add(new MemorySection(0x0700, 0x16FF, MemorySectionType.ByteArray)); // --- Act mm.Add(new MemorySection(0x0100, 0x10FF)); // --- Assert mm.Count.ShouldBe(3); mm[0].StartAddress.ShouldBe((ushort)0x0000); mm[0].EndAddress.ShouldBe((ushort)0x00FF); mm[0].SectionType.ShouldBe(MemorySectionType.ByteArray); mm[1].StartAddress.ShouldBe((ushort)0x0100); mm[1].EndAddress.ShouldBe((ushort)0x10FF); mm[1].SectionType.ShouldBe(MemorySectionType.Disassemble); mm[2].StartAddress.ShouldBe((ushort)0x1100); mm[2].EndAddress.ShouldBe((ushort)0x16FF); mm[2].SectionType.ShouldBe(MemorySectionType.ByteArray); }
public void NormalizeWorksWithMultipleSections() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0100, 0x01FF)); mm.Add(new MemorySection(0x0300, 0x03FF)); mm.Add(new MemorySection(0x0400, 0x04FF)); mm.Add(new MemorySection(0x0600, 0x06FF)); mm.Add(new MemorySection(0x0700, 0x07FF)); mm.Add(new MemorySection(0x0800, 0x08FF)); mm.Add(new MemorySection(0x0900, 0x09FF)); mm.Add(new MemorySection(0x1000, 0x1FFF)); // --- Act mm.Normalize(); // --- Assert mm.Count.ShouldBe(4); mm[0].StartAddress.ShouldBe((ushort)0x0100); mm[0].EndAddress.ShouldBe((ushort)0x01FF); mm[0].SectionType.ShouldBe(MemorySectionType.Disassemble); mm[1].StartAddress.ShouldBe((ushort)0x0300); mm[1].EndAddress.ShouldBe((ushort)0x04FF); mm[1].SectionType.ShouldBe(MemorySectionType.Disassemble); mm[2].StartAddress.ShouldBe((ushort)0x0600); mm[2].EndAddress.ShouldBe((ushort)0x09FF); mm[2].SectionType.ShouldBe(MemorySectionType.Disassemble); mm[3].StartAddress.ShouldBe((ushort)0x1000); mm[3].EndAddress.ShouldBe((ushort)0x1FFF); mm[3].SectionType.ShouldBe(MemorySectionType.Disassemble); }
public void AddWorksWithOverlap6() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0200, 0x0F00, MemorySectionType.ByteArray)); // --- Act mm.Add(new MemorySection(0x0100, 0x0F00)); // --- Assert mm.Count.ShouldBe(1); mm[0].StartAddress.ShouldBe((ushort)0x0100); mm[0].EndAddress.ShouldBe((ushort)0x0F00); mm[0].SectionType.ShouldBe(MemorySectionType.Disassemble); }
public Dump(string fileName) { // Open dump file using (var dump = new BinaryReader(File.OpenRead(fileName))) { // Read memory map int memoryMapEntryCount = (int)dump.ReadUInt32(); for (int i = 0; i < memoryMapEntryCount; ++i) { MemoryMapEntry entry = new MemoryMapEntry(); entry.Type = (MemoryMapEntryTypes)dump.ReadUInt32(); entry.AddressStart = AlignToNext4K(dump.ReadUInt64()); entry.AddressEnd = AlignToPrev4K(dump.ReadUInt64()); MemoryMap.Add(entry); } // Read frames int frameCount = (int)dump.ReadUInt32(); for (int i = 0; i < frameCount; ++i) { FrameData frame = new FrameData(); ulong data = dump.ReadUInt64(); frame.Address = data & ~0xFFFul; frame.Flags = (DumpEntryFlags)(data & 0xFFFul); Frames.Add(frame); } } }
public void AddWorksWithOverlap3() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0000, 0x0FFF)); // --- Act mm.Add(new MemorySection(0x0100, 0x10FF)); // --- Assert mm.Count.ShouldBe(2); mm[0].StartAddress.ShouldBe((ushort)0x0000); mm[0].EndAddress.ShouldBe((ushort)0x00FF); mm[1].StartAddress.ShouldBe((ushort)0x0100); mm[1].EndAddress.ShouldBe((ushort)0x10FF); }
public void NormalizeWorksWithThreeAdjacentSections() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0100, 0x01FF)); mm.Add(new MemorySection(0x0200, 0x02FF)); mm.Add(new MemorySection(0x0300, 0x03FF)); // --- Act mm.Normalize(); // --- Assert mm.Count.ShouldBe(1); mm[0].StartAddress.ShouldBe((ushort)0x0100); mm[0].EndAddress.ShouldBe((ushort)0x03FF); mm[0].SectionType.ShouldBe(MemorySectionType.Disassemble); }
public void NormalizeDoesNotMergeDifferentTypes3() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0100, 0x01FF, MemorySectionType.Skip)); mm.Add(new MemorySection(0x0200, 0x02FF)); mm.Add(new MemorySection(0x0300, 0x03FF)); // --- Act mm.Normalize(); // --- Assert mm.Count.ShouldBe(2); mm[0].StartAddress.ShouldBe((ushort)0x0100); mm[0].EndAddress.ShouldBe((ushort)0x01FF); mm[0].SectionType.ShouldBe(MemorySectionType.Skip); mm[1].StartAddress.ShouldBe((ushort)0x0200); mm[1].EndAddress.ShouldBe((ushort)0x03FF); mm[1].SectionType.ShouldBe(MemorySectionType.Disassemble); }
public void AddWorksWithEmptyMap() { // --- Arrange var mm = new MemoryMap(); // --- Act mm.Add(new MemorySection(0x0000, 0x100)); // --- Assert mm.Count.ShouldBe(1); mm[0].StartAddress.ShouldBe((ushort)0x0000); mm[0].EndAddress.ShouldBe((ushort)0x100); }
public void NormalizeDoesNotMergeSkipSections() { // --- Arrange var mm = new MemoryMap(); mm.Add(new MemorySection(0x0100, 0x01FF, MemorySectionType.Skip)); mm.Add(new MemorySection(0x0200, 0x02FF, MemorySectionType.Skip)); mm.Add(new MemorySection(0x0500, 0x05FF, MemorySectionType.Skip)); // --- Act mm.Normalize(); // --- Assert mm.Count.ShouldBe(3); mm[0].StartAddress.ShouldBe((ushort)0x0100); mm[0].EndAddress.ShouldBe((ushort)0x01FF); mm[0].SectionType.ShouldBe(MemorySectionType.Skip); mm[1].StartAddress.ShouldBe((ushort)0x0200); mm[1].EndAddress.ShouldBe((ushort)0x02FF); mm[1].SectionType.ShouldBe(MemorySectionType.Skip); mm[2].StartAddress.ShouldBe((ushort)0x0500); mm[2].EndAddress.ShouldBe((ushort)0x05FF); mm[2].SectionType.ShouldBe(MemorySectionType.Skip); }