Exemplo n.º 1
0
        public static async Task <ExceptionTable> GetAsync(PortableExecutableImage image)
        {
            if (!image.NTHeaders.DataDirectories.Exists(DataDirectoryType.ExceptionTable))
            {
                return(null);
            }

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

            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);
            ExceptionTable table;

            if (image.Is64Bit)
            {
                table = await ExceptionTable64.GetAsync(image, dataDirectory, location).ConfigureAwait(false);
            }
            else
            {
                table = await ExceptionTable32.GetAsync(image, dataDirectory, location).ConfigureAwait(false);
            }

            return(table);
        }
Exemplo n.º 2
0
        internal static Task <ExceptionTable> GetAsync(PortableExecutableImage image, DataDirectory dataDirectory, Location location)
        {
            ExceptionTable table = new ExceptionTable32(image, dataDirectory, location, new ExceptionTableEntry[0]);

            return(Task.FromResult(table));
        }