Пример #1
0
        // PE section headers are always 40 bytes.
        private void Given_Section(string section, uint virtAddress, uint rvaData)
        {
            var bytes = Encoding.UTF8.GetBytes(section);

            writer.WriteBytes(bytes).WriteBytes(0, 8 - (uint)bytes.Length);
            writer.WriteLeUInt32(0x1000);      // Section size in memory
            writer.WriteLeUInt32(virtAddress); // Where to load this
            writer.WriteLeUInt32(0x1000);      // raw data
            writer.WriteLeUInt32(rvaData);     // rva to raw data
            writer.WriteLeInt32(0);            // relocs
            writer.WriteLeInt32(0);            // line numbers
            writer.WriteLeInt16(0);            // #relocs
            writer.WriteLeInt16(0);            // #line numbers
            writer.WriteLeInt32(0);            // characteristics

            // Increment the section count in the optional header.
            short sections = MemoryArea.ReadLeInt16(fileImage, RvaPeHdr + 6);

            MemoryArea.WriteLeInt16(fileImage, RvaPeHdr + 6, (short)(sections + 1));
        }