예제 #1
0
        void init()
        {
            seek(0);
            if (reader.ReadUInt16() != 0x5A4D)
                throw new BadImageFormatException("Not a PE file");
            skip(29 * 2);
            seek(reader.ReadUInt32());

            if (reader.ReadUInt32() != 0x4550)
                throw new BadImageFormatException("Not a PE file");
            fileHeader = new FileHeader(reader);
            optionalHeader = new OptionalHeader(reader);

            sectionHeaders = new SectionHeader[fileHeader.numberOfSections];
            for (int i = 0; i < sectionHeaders.Length; i++)
                sectionHeaders[i] = new SectionHeader(reader);

            uint netRva = optionalHeader.dataDirectories[14].virtualAddress;
            if (netRva != 0) {
                seekRva(netRva);
                cor20Header = new Cor20Header(reader);
                dotNetSection = getSectionHeader(netRva);
                seekRva(cor20Header.metadataDirectory.virtualAddress);
                cor20Header.initMetadataTable();
            }

            uint resourceRva = optionalHeader.dataDirectories[2].virtualAddress;
            uint resourceOffset = 0;
            if (resourceRva != 0)
                resourceOffset = rvaToOffset(resourceRva);
            resources = new Resources(reader, resourceOffset, optionalHeader.dataDirectories[2].size);
        }
예제 #2
0
 public ResourceDirectory(string name, Resources resources, int offset)
     : base(name)
 {
     init(resources, offset);
 }
예제 #3
0
 void init(Resources resources, int offset)
 {
     this.resources = resources;
     this.offset = offset;
     initializeEntries();
 }
예제 #4
0
 public ResourceDirectory(int id, Resources resources, int offset)
     : base(id)
 {
     init(resources, offset);
 }