public static PortableExecutableFileHeader Read(string peFilePath) { var peFileHeader = new PortableExecutableFileHeader() { IsValid = false, DosHeader = null, NtHeader = null, }; // Read DOS header. var dosHeader = ImageDosHeader.Read(peFilePath); if (!dosHeader.IsValid) { return(peFileHeader); } // Read NT header. var ntHeader = ImageNtHeaders.Read(peFilePath, dosHeader.e_lfanew); if (!ntHeader.IsValid) { return(peFileHeader); } peFileHeader.IsValid = true; peFileHeader.DosHeader = dosHeader; peFileHeader.NtHeader = ntHeader; return(peFileHeader); }
private static UpdateModuleProcessorArchitecture ReadModuleProcessorArchitecture(string filePath) { var peFileHeader = PortableExecutableFileHeader.Read(filePath); var fileProcArch = peFileHeader.NtHeader.FileHeader.Machine; if (fileProcArch == ImageFileHeader.MachineType.AMD64) { return(UpdateModuleProcessorArchitecture.Amd64); } else if (fileProcArch == ImageFileHeader.MachineType.I386) { return(UpdateModuleProcessorArchitecture.I386); } else if (fileProcArch == ImageFileHeader.MachineType.ARM) { return(UpdateModuleProcessorArchitecture.Arm); } else if (fileProcArch == ImageFileHeader.MachineType.IA64) { return(UpdateModuleProcessorArchitecture.IA64); } return(UpdateModuleProcessorArchitecture.Unknown); }