Beispiel #1
0
        public static async Task <CLR> GetAsync(PortableExecutableImage image)
        {
            if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.CLRRuntimeHeader))
            {
                return(null);
            }

            var dataDirectory = image.NTHeaders.DataDirectories[DataDirectoryType.CLRRuntimeHeader];

            if (DataDirectory.IsNullOrEmpty(dataDirectory))
            {
                return(null);
            }

            var calc       = image.GetCalculator();
            var section    = calc.RVAToSection(dataDirectory.VirtualAddress);
            var fileOffset = calc.RVAToOffset(section, dataDirectory.VirtualAddress);
            var imageBase  = image.NTHeaders.OptionalHeader.ImageBase;
            var location   = new Location(image, fileOffset, dataDirectory.VirtualAddress, imageBase + dataDirectory.VirtualAddress, dataDirectory.Size, dataDirectory.Size, section);
            var header     = await CLRHeader.GetAsync(image, location).ConfigureAwait(false);

            var metaData = await CLRMetaData.GetAsync(image, header).ConfigureAwait(false);

            return(new CLR(image, dataDirectory, location, header, metaData));
        }
Beispiel #2
0
        internal static async Task <CLRMetaData> GetAsync(PortableExecutableImage image, CLRHeader header)
        {
            var calc           = image.GetCalculator();
            var imageBase      = image.NTHeaders.OptionalHeader.ImageBase;
            var rva            = header.MetaDataAddress;
            var va             = imageBase + rva;
            var offset         = calc.RVAToOffset(rva);
            var size           = header.MetaDataSize;
            var section        = calc.RVAToSection(rva);
            var location       = new Location(image, offset, rva, va, size, size, section);
            var metaDataHeader = await CLRMetaDataHeader.LoadAsync(image, location).ConfigureAwait(false);

            var metaDataStreamTable = await CLRMetaDataStreamTable.LoadAsync(image, metaDataHeader).ConfigureAwait(false);

            var metaDataStreams = await CLRMetaDataStreams.LoadAsync(image, location, metaDataStreamTable).ConfigureAwait(false);

            var metaData = new CLRMetaData(image, location, metaDataHeader, metaDataStreamTable, metaDataStreams);

            return(metaData);
        }
Beispiel #3
0
 private CLR(PortableExecutableImage image, DataDirectory dataDirectory, Location location, CLRHeader header, CLRMetaData metaData) : base(image, dataDirectory, location)
 {
     Header   = header;
     MetaData = metaData;
 }