Example #1
0
        internal ModuleDefinition(Image image)
            : this()
        {
            this.Image           = image;
            this.kind            = image.Kind;
            this.RuntimeVersion  = image.RuntimeVersion;
            this.architecture    = image.Architecture;
            this.attributes      = image.Attributes;
            this.characteristics = image.Characteristics;
            this.fq_name         = image.FileName;

            this.reader = new MetadataReader(this);
        }
Example #2
0
        public void Load(BufferedBinaryReader reader)
        {
            if (reader.Length < 128)
            {
                throw new BadImageFormatException();
            }

            // - DOSHeader
            // PE					2
            // Start				58
            // Lfanew				4
            // End					64
            if (reader.ReadUInt16() != 0x5a4d)
            {
                throw new BadImageFormatException();
            }
            reader.Advance(58);
            reader.Position = reader.ReadUInt32();

            // PE NT signature
            if (reader.ReadUInt32() != 0x00004550)
            {
                throw new BadImageFormatException();
            }

            // - PEFileHeader

            Architecture = ReadArchitecture(reader);             // 2 bytes
            ushort numberOfSections = reader.ReadUInt16();

            // TimeDateStamp		4
            // PointerToSymbolTable	4
            // NumberOfSymbols		4
            // OptionalHeaderSize	2
            reader.Advance(14);

            // Characteristics		2
            ushort characteristics = reader.ReadUInt16();

            DataDirectory cli;
            ushort        subsystem, dll_characteristics;

            ReadOptionalHeaders(reader, out subsystem, out dll_characteristics, out cli);

            Kind            = ResolveModuleKind(characteristics, subsystem);
            Characteristics = (ModuleCharacteristics)dll_characteristics;

            ReadSections(reader, numberOfSections);
            ReadCliHeader(reader, cli);
        }
Example #3
0
 internal ModuleDefinition(Image image)
     : this()
 {
     Image           = image;
     kind            = image.Kind;
     RuntimeVersion  = image.RuntimeVersion;
     architecture    = image.Architecture;
     attributes      = image.Attributes;
     characteristics = image.Characteristics;
     linker_version  = image.LinkerVersion;
     file_name       = image.FileName;
     timestamp       = image.Timestamp;
     reader          = new MetadataReader(this);
 }
Example #4
0
        internal ModuleDefinition(Image image)
            : this()
        {
            this.Image           = image;
            this.kind            = image.Kind;
            this.RuntimeVersion  = image.RuntimeVersion;
            this.architecture    = image.Architecture;
            this.attributes      = image.Attributes;
            this.characteristics = image.Characteristics;
            this.linker_version  = image.LinkerVersion;
            this.subsystem_major = image.SubSystemMajor;
            this.subsystem_minor = image.SubSystemMinor;
            this.file_name       = image.FileName;
            this.timestamp       = image.Timestamp;

            this.reader = new MetadataReader(this);
        }