Represents the header of a Portable Executeable file
상속: IHeader
예제 #1
0
        /// <summary>
        /// Gets the Portable Executeable's NT header by specifing the assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read the nt header</param>
        /// <returns></returns>
        public static NTHeader FromAssembly(Win32Assembly assembly)
        {
            NTHeader a = new NTHeader();

            a.assembly = assembly;
            a.file     = assembly.path;
            a.header   = assembly.headerReader;

            a.fheader = FileHeader.FromAssembly(assembly);


            return(a);
        }
예제 #2
0
        /// <summary>
        /// Loads an assembly from a specific file using the specific reading parameters.
        /// </summary>
        /// <param name="file">The file to read.</param>
        /// <param name="arguments">The reading parameters to use.</param>
        /// <returns></returns>
        /// <exception cref="System.BadImageFormatException"></exception>
        public static Win32Assembly LoadFile(string file, ReadingParameters arguments)
        {
            try
            {
                Win32Assembly a = new Win32Assembly();


                a.path             = file;
                a.ReadingArguments = arguments;
                a.peImage          = PeImage.LoadFromAssembly(a);

                a.headerReader = PeHeaderReader.FromAssembly(a);
                a.ntHeader     = NTHeader.FromAssembly(a);
                a.mzHeader     = MZHeader.FromAssembly(a);
                a.headerReader.LoadData(arguments.IgnoreDataDirectoryAmount);


                if (!arguments.OnlyManaged)
                {
                    a.disassembler            = new x86Disassembler(a);
                    a.assembler               = new x86Assembler(a);
                    a.importExportTableReader = new ImportExportTableReader(a.ntHeader);
                    a.resourcesReader         = new ResourcesReader(a.ntHeader);
                }


                a.netHeader = NETHeader.FromAssembly(a);
                a.peImage.SetOffset(a.ntHeader.OptionalHeader.HeaderSize);

                return(a);
            }
            catch (Exception ex)
            {
                if (ex is AccessViolationException || ex is FileNotFoundException)
                {
                    throw;
                }
                throw new BadImageFormatException("The file is not a valid Portable Executable File.", ex);
            }
        }
예제 #3
0
파일: NTHeader.cs 프로젝트: Rex-Hays/GNIDA
        /// <summary>
        /// Gets the Portable Executeable's NT header by specifing the assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read the nt header</param>
        /// <returns></returns>
        public static NTHeader FromAssembly(Win32Assembly assembly)
        {
            NTHeader a = new NTHeader();
            a._assembly = assembly;
            a._file = assembly._path;
            a._header = assembly._headerReader;

            a._fheader = FileHeader.FromAssembly(assembly);

            return a;
        }
예제 #4
0
        /// <summary>
        /// Gets the Portable Executeable's NT header by specifing the assembly.
        /// </summary>
        /// <param name="assembly">The assembly to read the nt header</param>
        /// <returns></returns>
        public static NTHeader FromAssembly(Win32Assembly assembly)
        {
            NTHeader a = new NTHeader();
            a.assembly = assembly;
            a.file = assembly.path;
            a.header = assembly.headerreader;

            a.fheader = FileHeader.FromAssembly(assembly);

            return a;
        }