コード例 #1
0
		public void MoveTo (int rva)
		{
			if (!IsInSection (rva)) {
				code_section = reader.image.GetSectionAtVirtualAddress ((uint) rva);
				Reset (code_section.Data);
			}

			base.position = rva - (int) code_section.VirtualAddress;
		}
コード例 #2
0
		public uint ResolveVirtualAddressInSection (RVA rva, Section section)
		{
			return rva + section.PointerToRawData - section.VirtualAddress;
		}
コード例 #3
0
		public UserStringHeap (Section section, uint start, uint size)
			: base (section, start, size)
		{
		}
コード例 #4
0
		public CodeReader (Section section, MetadataReader reader)
			: base (section.Data)
		{
			this.code_section = section;
			this.reader = reader;
		}
コード例 #5
0
 public TableHeap(Section section, uint start, uint size)
     : base(section, start, size)
 {
 }
コード例 #6
0
		protected Heap (Section section, uint offset, uint size)
		{
			this.Section = section;
			this.Offset = offset;
			this.Size = size;
		}
コード例 #7
0
		public BlobHeap (Section section, uint start, uint size)
			: base (section, start, size)
		{
		}
コード例 #8
0
		public GuidHeap (Section section, uint start, uint size)
			: base (section, start, size)
		{
		}
コード例 #9
0
		void ReadMetadataStream (Section section)
		{
			// Offset		4
			uint start = metadata.VirtualAddress - section.VirtualAddress + ReadUInt32 (); // relative to the section start

			// Size			4
			uint size = ReadUInt32 ();

			var name = ReadAlignedString (16);
			switch (name) {
			case "#~":
			case "#-":
				image.TableHeap = new TableHeap (section, start, size);
				break;
			case "#Strings":
				image.StringHeap = new StringHeap (section, start, size);
				break;
			case "#Blob":
				image.BlobHeap = new BlobHeap (section, start, size);
				break;
			case "#GUID":
				image.GuidHeap = new GuidHeap (section, start, size);
				break;
			case "#US":
				image.UserStringHeap = new UserStringHeap (section, start, size);
				break;
			}
		}
コード例 #10
0
		void ReadSectionData (Section section)
		{
			var position = BaseStream.Position;

			MoveTo (section.PointerToRawData);

			var length = (int) section.SizeOfRawData;
			var data = new byte [length];
			int offset = 0, read;

			while ((read = Read (data, offset, length - offset)) > 0)
				offset += read;

			section.Data = data;

			BaseStream.Position = position;
		}
コード例 #11
0
		void ReadSections (ushort count)
		{
			var sections = new Section [count];

			for (int i = 0; i < count; i++) {
				var section = new Section ();

				// Name
				section.Name = ReadZeroTerminatedString (8);

				// VirtualSize		4
				Advance (4);

				// VirtualAddress	4
				section.VirtualAddress = ReadUInt32 ();
				// SizeOfRawData	4
				section.SizeOfRawData = ReadUInt32 ();
				// PointerToRawData	4
				section.PointerToRawData = ReadUInt32 ();

				// PointerToRelocations		4
				// PointerToLineNumbers		4
				// NumberOfRelocations		2
				// NumberOfLineNumbers		2
				// Characteristics			4
				Advance (16);

				sections [i] = section;

				if (section.Name == ".reloc")
					continue;

				ReadSectionData (section);
			}

			image.Sections = sections;
		}