Exemplo n.º 1
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            m_textWriter.Write(hnt.Hint);
            m_textWriter.Write(Encoding.ASCII.GetBytes(hnt.RuntimeMain));
            m_textWriter.Write('\0');
            m_textWriter.Write(Encoding.ASCII.GetBytes(hnt.RuntimeLibrary));
            m_textWriter.Write('\0');
            m_textWriter.Write(new byte [4]);

            // patch header with ep rva
            RVA ep = m_img.TextSection.VirtualAddress +
                     (uint)m_textWriter.BaseStream.Position;
            long pos = m_binaryWriter.BaseStream.Position;

            m_binaryWriter.BaseStream.Position = 0xa8;
            m_binaryWriter.Write(ep.Value);
            m_binaryWriter.BaseStream.Position = pos;

            // patch reloc Sect with ep
            uint reloc = (ep.Value + 2) % 0x1000;
            uint rva   = (ep.Value + 2) - reloc;

            m_relocWriter.BaseStream.Position = 0;
            m_relocWriter.Write(rva);
            m_relocWriter.BaseStream.Position = 8;
            m_relocWriter.Write((ushort)((3 << 12) | reloc));

            m_textWriter.Write(hnt.EntryPoint);
            m_textWriter.Write(hnt.RVA);
        }
Exemplo n.º 2
0
 public override void VisitHintNameTable(HintNameTable hnt)
 {
     hnt.Hint           = 0;
     hnt.RuntimeLibrary = HintNameTable.RuntimeCorEE;
     hnt.EntryPoint     = 0x25ff;
     hnt.RVA            = new RVA(0x402000);
 }
Exemplo n.º 3
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            if (m_image.ImportAddressTable.HintNameTableRVA == RVA.Zero)
            {
                return;
            }

            if ((m_image.ImportAddressTable.HintNameTableRVA & 0x80000000) != 0)
            {
                return;
            }

            SetPositionToAddress(m_image.ImportAddressTable.HintNameTableRVA);

            hnt.Hint = m_binaryReader.ReadUInt16();

            byte [] bytes = m_binaryReader.ReadBytes(11);
            hnt.RuntimeMain = Encoding.ASCII.GetString(bytes, 0, bytes.Length);

            SetPositionToAddress(m_image.ImportTable.Name);

            bytes = m_binaryReader.ReadBytes(11);
            hnt.RuntimeLibrary = Encoding.ASCII.GetString(bytes, 0, bytes.Length);

            SetPositionToAddress(m_image.PEOptionalHeader.StandardFields.EntryPointRVA);
            hnt.EntryPoint = m_binaryReader.ReadUInt16();
            hnt.RVA        = ReadRVA();
        }
Exemplo n.º 4
0
 internal Image()
 {
     m_dosHeader          = new DOSHeader();
     m_peFileHeader       = new PEFileHeader();
     m_peOptionalHeader   = new PEOptionalHeader();
     m_sections           = new SectionCollection();
     m_importAddressTable = new ImportAddressTable();
     m_importTable        = new ImportTable();
     m_importLookupTable  = new ImportLookupTable();
     m_hintNameTable      = new HintNameTable();
     m_mdRoot             = new MetadataRoot(this);
 }
Exemplo n.º 5
0
 internal Image()
 {
     m_dosHeader = new DOSHeader ();
     m_peFileHeader = new PEFileHeader ();
     m_peOptionalHeader = new PEOptionalHeader ();
     m_sections = new SectionCollection ();
     m_importAddressTable = new ImportAddressTable ();
     m_importTable = new ImportTable ();
     m_importLookupTable = new ImportLookupTable ();
     m_hintNameTable = new HintNameTable ();
     m_mdRoot = new MetadataRoot (this);
 }
Exemplo n.º 6
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress(
                m_image.ImportAddressTable.HintNameTableRVA);

            hnt.Hint = m_binaryReader.ReadUInt16();

            byte [] bytes = m_binaryReader.ReadBytes(11);
            hnt.RuntimeMain = Encoding.ASCII.GetString(bytes, 0, bytes.Length);

            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress(
                m_image.ImportTable.Name);

            bytes = m_binaryReader.ReadBytes(11);
            hnt.RuntimeLibrary = Encoding.ASCII.GetString(bytes, 0, bytes.Length);

            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress(
                m_image.PEOptionalHeader.StandardFields.EntryPointRVA);
            hnt.EntryPoint = m_binaryReader.ReadUInt16();
            hnt.RVA        = new RVA(m_binaryReader.ReadUInt32());
        }
Exemplo n.º 7
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            if (m_image.ImportAddressTable.HintNameTableRVA == RVA.Zero)
                return;

            if ((m_image.ImportAddressTable.HintNameTableRVA & 0x80000000) != 0)
                return;

            SetPositionToAddress (m_image.ImportAddressTable.HintNameTableRVA);

            hnt.Hint = m_binaryReader.ReadUInt16 ();

            byte [] bytes = m_binaryReader.ReadBytes (11);
            hnt.RuntimeMain = Encoding.ASCII.GetString (bytes, 0, bytes.Length);

            SetPositionToAddress (m_image.ImportTable.Name);

            bytes = m_binaryReader.ReadBytes (11);
            hnt.RuntimeLibrary = Encoding.ASCII.GetString (bytes, 0, bytes.Length);

            SetPositionToAddress (m_image.PEOptionalHeader.StandardFields.EntryPointRVA);
            hnt.EntryPoint = m_binaryReader.ReadUInt16 ();
            hnt.RVA = ReadRVA ();
        }
Exemplo n.º 8
0
 public override void VisitHintNameTable(HintNameTable hnt)
 {
     hnt.Hint = 0;
     hnt.RuntimeLibrary = HintNameTable.RuntimeCorEE;
     hnt.EntryPoint = 0x25ff;
     hnt.RVA = new RVA (0x402000);
 }
Exemplo n.º 9
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress (
                m_image.ImportAddressTable.HintNameTableRVA);

            hnt.Hint = m_binaryReader.ReadUInt16 ();

            byte [] bytes = m_binaryReader.ReadBytes (11);
            hnt.RuntimeMain = Encoding.ASCII.GetString (bytes, 0, bytes.Length);

            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress (
                m_image.ImportTable.Name);

            bytes = m_binaryReader.ReadBytes (11);
            hnt.RuntimeLibrary = Encoding.ASCII.GetString (bytes, 0, bytes.Length);

            m_binaryReader.BaseStream.Position = m_image.ResolveVirtualAddress (
                m_image.PEOptionalHeader.StandardFields.EntryPointRVA);
            hnt.EntryPoint = m_binaryReader.ReadUInt16 ();
            hnt.RVA = new RVA (m_binaryReader.ReadUInt32 ());
        }
Exemplo n.º 10
0
        public override void VisitHintNameTable(HintNameTable hnt)
        {
            m_textWriter.Write (hnt.Hint);
            m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeMain));
            m_textWriter.Write ('\0');
            m_textWriter.Write (Encoding.ASCII.GetBytes (hnt.RuntimeLibrary));
            m_textWriter.Write ('\0');
            m_textWriter.Write (new byte [4]);

            // patch header with ep rva
            RVA ep = m_img.TextSection.VirtualAddress +
                (uint) m_textWriter.BaseStream.Position;
            long pos = m_binaryWriter.BaseStream.Position;
            m_binaryWriter.BaseStream.Position = 0xa8;
            m_binaryWriter.Write (ep.Value);
            m_binaryWriter.BaseStream.Position = pos;

            // patch reloc Sect with ep
            uint reloc = (ep.Value + 2) % 0x1000;
            uint rva = (ep.Value + 2) - reloc;

            m_relocWriter.BaseStream.Position = 0;
            m_relocWriter.Write (rva);
            m_relocWriter.BaseStream.Position = 8;
            m_relocWriter.Write ((ushort) ((3 << 12) | reloc));

            m_textWriter.Write (hnt.EntryPoint);
            m_textWriter.Write (hnt.RVA);
        }