/// <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); }
/// <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); } }
/// <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; }
/// <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; }