示例#1
0
 public void Given_DebugHeader(short nSymbols, short nTypes)
 {
     writer.WriteLeUInt16(SymbolLoader.MagicNumber); // magic_number
     writer.WriteLeUInt16(0);                        // version_id
     // Remember this position so we can backpatch later.
     this.offNames = writer.Position;
     writer.WriteLeUInt32(0);       // names
     writer.WriteLeUInt16(0);       // names_count
     writer.WriteLeInt16(nTypes);   // types_count
     writer.WriteLeUInt16(0);       // members_count
     writer.WriteLeInt16(nSymbols); // symbols_count
     writer.WriteLeUInt16(0);       // globals_count
     writer.WriteLeUInt16(0);       // modules_count
     writer.WriteLeUInt16(0);       // locals_count
     writer.WriteLeUInt16(0);       // scopes_count
     writer.WriteLeUInt16(0);       // lines_count
     writer.WriteLeUInt16(0);       // source_count
     writer.WriteLeUInt16(0);       // segment_count
     writer.WriteLeUInt16(0);       // correlation_count
     writer.WriteUInt32(0);         // image_size
     writer.WriteUInt32(0);         // /*void far * */debugger_hook
     writer.WriteByte(0);           // program_flags
     writer.WriteLeUInt16(0);       // stringsegoffset
     writer.WriteLeUInt16(0);       // data_count
     writer.WriteByte(0);           // filler
     writer.WriteLeUInt16(0x00);    // extension_size
 }
示例#2
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));
        }