static string GetBuildNumberFromEFIESPSpkg(string filepath) { if (File.Exists("man.dsm.xml")) { File.Delete("man.dsm.xml"); } var proc = new Process(); proc.StartInfo = new ProcessStartInfo("7za.exe", "x \"" + filepath + "\" man.dsm.xml") { WindowStyle = ProcessWindowStyle.Hidden }; proc.Start(); proc.WaitForExit(); if (File.Exists("man.dsm.xml")) { string buildstr = null; Stream stream = File.OpenRead("man.dsm.xml"); XmlSerializer serializer = new XmlSerializer(typeof(XmlDsm.Package)); XmlDsm.Package package = (XmlDsm.Package)serializer.Deserialize(stream); if (package.Files.FileEntry.Any(x => x.DevicePath.Contains(@"\bootmgr.efi"))) { var entry = package.Files.FileEntry.First(x => x.DevicePath.Contains(@"\bootmgr.efi")); if (File.Exists(entry.CabPath)) { File.Delete(entry.CabPath); } proc = new Process(); proc.StartInfo = new ProcessStartInfo("7za.exe", "x \"" + filepath + "\" " + entry.CabPath) { WindowStyle = ProcessWindowStyle.Hidden }; proc.Start(); proc.WaitForExit(); buildstr = FileVersionInfo.GetVersionInfo(entry.CabPath).FileVersion; File.Delete(entry.CabPath); } stream.Close(); File.Delete("man.dsm.xml"); return(buildstr); } else { return(null); } }
static XmlDsm.Version GetVersionInfoSpkg(string filepath) { if (File.Exists("man.dsm.xml")) { File.Delete("man.dsm.xml"); } var proc = new Process(); proc.StartInfo = new ProcessStartInfo("7za.exe", "x \"" + filepath + "\" man.dsm.xml") { WindowStyle = ProcessWindowStyle.Hidden }; proc.Start(); proc.WaitForExit(); if (File.Exists("man.dsm.xml")) { Stream stream = File.OpenRead("man.dsm.xml"); XmlSerializer serializer = new XmlSerializer(typeof(XmlDsm.Package)); XmlDsm.Package package = (XmlDsm.Package)serializer.Deserialize(stream); XmlDsm.Version ver = package.Identity.Version; stream.Close(); File.Delete("man.dsm.xml"); return(ver); } else { return(null); } }
static BuildInfo.Buildinformation GetBuildInfoFromMainOSProdSpkg(string filepath) { if (File.Exists("man.dsm.xml")) { File.Delete("man.dsm.xml"); } var proc = new Process(); proc.StartInfo = new ProcessStartInfo("7za.exe", "x \"" + filepath + "\" man.dsm.xml") { WindowStyle = ProcessWindowStyle.Hidden }; proc.Start(); proc.WaitForExit(); if (File.Exists("man.dsm.xml")) { BuildInfo.Buildinformation buildstr = null; Stream stream = File.OpenRead("man.dsm.xml"); XmlSerializer serializer = new XmlSerializer(typeof(XmlDsm.Package)); XmlDsm.Package package = (XmlDsm.Package)serializer.Deserialize(stream); if (package.Files.FileEntry.Any(x => x.DevicePath.Contains(@"\buildinfo.xml"))) { var entry = package.Files.FileEntry.First(x => x.DevicePath.Contains(@"\buildinfo.xml")); if (File.Exists(entry.CabPath)) { try { File.Delete(entry.CabPath); } catch { File.Move(entry.CabPath, Path.GetTempFileName()); //File.Delete(entry.CabPath); } } proc = new Process(); proc.StartInfo = new ProcessStartInfo("7za.exe", "x \"" + filepath + "\" " + entry.CabPath) { WindowStyle = ProcessWindowStyle.Hidden }; proc.Start(); proc.WaitForExit(); Stream stream2 = File.OpenRead(entry.CabPath); XmlSerializer serializer2 = new XmlSerializer(typeof(BuildInfo.Buildinformation)); BuildInfo.Buildinformation package2 = (BuildInfo.Buildinformation)serializer2.Deserialize(stream2); buildstr = package2; stream2.Close(); try { File.Delete(entry.CabPath); } catch { } } stream.Close(); File.Delete("man.dsm.xml"); return(buildstr); } else { return(null); } }