From 4b66cd8cd26183a64d6625766889711d73842d8a Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Fri, 1 Apr 2022 10:16:31 -0700 Subject: [PATCH] Update file version resource handling --- BurnOutSharp/PackerType/InstallAnywhere.cs | 9 +- .../PackerType/IntelInstallationFramework.cs | 4 +- BurnOutSharp/PackerType/MicrosoftCABSFX.cs | 7 +- BurnOutSharp/PackerType/SetupFactory.cs | 11 +- BurnOutSharp/ProtectionType/ElectronicArts.cs | 12 +- BurnOutSharp/ProtectionType/GFWL.cs | 4 +- BurnOutSharp/ProtectionType/ImpulseReactor.cs | 16 +-- .../ProtectionType/OnlineRegistration.cs | 2 +- BurnOutSharp/ProtectionType/SecuROM.cs | 6 +- BurnOutSharp/ProtectionType/SolidShield.cs | 16 +-- BurnOutSharp/ProtectionType/StarForce.cs | 8 +- BurnOutSharp/ProtectionType/Steam.cs | 2 +- BurnOutSharp/ProtectionType/Tages.cs | 9 +- BurnOutSharp/Tools/Utilities.cs | 121 ++++++++++-------- 14 files changed, 114 insertions(+), 113 deletions(-) diff --git a/BurnOutSharp/PackerType/InstallAnywhere.cs b/BurnOutSharp/PackerType/InstallAnywhere.cs index e9d7e6cc..f41c7585 100644 --- a/BurnOutSharp/PackerType/InstallAnywhere.cs +++ b/BurnOutSharp/PackerType/InstallAnywhere.cs @@ -51,13 +51,8 @@ namespace BurnOutSharp.PackerType private string GetVersion(PortableExecutable pex) { - // Check the file version first - string version = Utilities.GetFileVersion(pex); - if (!string.IsNullOrEmpty(version)) - return version; - - // Then check the manifest version - version = Utilities.GetManifestVersion(pex); + // Check the internal versions + string version = Utilities.GetInternalVersion(pex); if (!string.IsNullOrEmpty(version)) return version; diff --git a/BurnOutSharp/PackerType/IntelInstallationFramework.cs b/BurnOutSharp/PackerType/IntelInstallationFramework.cs index d431a034..f5ebcf4f 100644 --- a/BurnOutSharp/PackerType/IntelInstallationFramework.cs +++ b/BurnOutSharp/PackerType/IntelInstallationFramework.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.PackerType && (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) || name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase))) { - return $"Intel Installation Framework {Utilities.GetFileVersion(pex)}"; + return $"Intel Installation Framework {Utilities.GetInternalVersion(pex)}"; } name = Utilities.GetProductName(pex); @@ -28,7 +28,7 @@ namespace BurnOutSharp.PackerType && (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) || name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase))) { - return $"Intel Installation Framework {Utilities.GetFileVersion(pex)}"; + return $"Intel Installation Framework {Utilities.GetInternalVersion(pex)}"; } return null; diff --git a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs index 3f1d80c3..d2dca317 100644 --- a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs +++ b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs @@ -87,11 +87,8 @@ namespace BurnOutSharp.PackerType private string GetVersion(PortableExecutable pex) { - string version = Utilities.GetFileVersion(pex); - if (!string.IsNullOrWhiteSpace(version)) - return $"v{version}"; - - version = Utilities.GetManifestVersion(pex); + // Check the internal versions + string version = Utilities.GetInternalVersion(pex); if (!string.IsNullOrWhiteSpace(version)) return $"v{version}"; diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs index 6f49e872..4c02508a 100644 --- a/BurnOutSharp/PackerType/SetupFactory.cs +++ b/BurnOutSharp/PackerType/SetupFactory.cs @@ -61,18 +61,13 @@ namespace BurnOutSharp.PackerType private string GetVersion(PortableExecutable pex) { - // Check the product version first + // Check the product version explicitly string version = Utilities.GetProductVersion(pex); if (!string.IsNullOrEmpty(version)) return version; - // Then check the file version - version = Utilities.GetFileVersion(pex); - if (!string.IsNullOrEmpty(version)) - return version; - - // Then check the manifest version - version = Utilities.GetManifestVersion(pex); + // Check the internal versions + version = Utilities.GetInternalVersion(pex); if (!string.IsNullOrEmpty(version)) return version; diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index d0cd183f..3d09f377 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -24,19 +24,19 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetFileDescription(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("EReg MFC Application")) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(pex)}"; + return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.Contains("Registration code installer program")) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(pex)}"; + return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.Equals("EA DRM Helper", StringComparison.OrdinalIgnoreCase)) - return $"EA DRM Protection {Utilities.GetFileVersion(pex)}"; + return $"EA DRM Protection {Utilities.GetInternalVersion(pex)}"; name = Utilities.GetInternalName(pex); if (!string.IsNullOrWhiteSpace(name) && name.Equals("CDCode", StringComparison.Ordinal)) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(pex)}"; + return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; var resource = Utilities.FindResourceInSection(pex.ResourceSection, dataContains: "A\0b\0o\0u\0t\0 \0C\0D\0K\0e\0y"); if (resource != null) - return $"EA CdKey Registration Module {Utilities.GetFileVersion(pex)}"; + return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; // Get the .data section, if it exists if (pex.DataSectionRaw != null) @@ -48,7 +48,7 @@ namespace BurnOutSharp.ProtectionType { 0x45, 0x52, 0x65, 0x67, 0x20, 0x43, 0x6F, 0x6E, 0x66, 0x69, 0x67, 0x20, 0x46, 0x6F, 0x72, 0x6D - }, Utilities.GetFileVersion, "EA CdKey Registration Module"), + }, Utilities.GetInternalVersion, "EA CdKey Registration Module"), }; string match = MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug); diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index bf08aeb5..b1c5b668 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -19,9 +19,9 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetFileDescription(pex); if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Games for Windows - LIVE Zero Day Piracy Protection", StringComparison.OrdinalIgnoreCase)) - return $"Games for Windows LIVE - Zero Day Piracy Protection Module {Utilities.GetFileVersion(pex)}"; + return $"Games for Windows LIVE - Zero Day Piracy Protection Module {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Games for Windows", StringComparison.OrdinalIgnoreCase)) - return $"Games for Windows LIVE {Utilities.GetFileVersion(pex)}"; + return $"Games for Windows LIVE {Utilities.GetInternalVersion(pex)}"; // Get the .rdata section, if it exists if (pex.ResourceDataSectionRaw != null) diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index 5d798ec3..ebe7b7c3 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -20,15 +20,15 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetFileDescription(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("ImpulseReactor Dynamic Link Library")) - return $"Impulse Reactor Core Module {Utilities.GetFileVersion(pex)}"; + return $"Impulse Reactor Core Module {Utilities.GetInternalVersion(pex)}"; name = Utilities.GetProductName(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("ImpulseReactor Dynamic Link Library")) - return $"Impulse Reactor Core Module {Utilities.GetFileVersion(pex)}"; + return $"Impulse Reactor Core Module {Utilities.GetInternalVersion(pex)}"; name = Utilities.GetOriginalFileName(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("ReactorActivate.exe")) - return $"Stardock Product Activation {Utilities.GetFileVersion(pex)}"; + return $"Stardock Product Activation {Utilities.GetInternalVersion(pex)}"; // Get the .rdata section, if it exists if (pex.ResourceDataSectionRaw != null) @@ -56,7 +56,7 @@ namespace BurnOutSharp.ProtectionType bool containsCheck2 = pex.ResourceDataSectionRaw.FirstPosition(check2, out int position2); if (containsCheck && containsCheck2) - return $"Impulse Reactor Core Module {Utilities.GetFileVersion(pex)}" + (includeDebug ? $" (Index {position}, {position2})" : string.Empty); + return $"Impulse Reactor Core Module {Utilities.GetInternalVersion(pex)}" + (includeDebug ? $" (Index {position}, {position2})" : string.Empty); else if (containsCheck && !containsCheck2) return $"Impulse Reactor" + (includeDebug ? $" (Index {position})" : string.Empty); } @@ -69,8 +69,8 @@ namespace BurnOutSharp.ProtectionType { var matchers = new List { - new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetFileVersion, "Impulse Reactor Core Module"), - new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), Utilities.GetFileVersion, "Stardock Product Activation"), + new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetInternalVersion, "Impulse Reactor Core Module"), + new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), Utilities.GetInternalVersion, "Stardock Product Activation"), }; return MatchUtil.GetAllMatches(files, matchers, any: true); @@ -81,8 +81,8 @@ namespace BurnOutSharp.ProtectionType { var matchers = new List { - new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetFileVersion, "Impulse Reactor Core Module"), - new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), Utilities.GetFileVersion, "Stardock Product Activation"), + new PathMatchSet(new PathMatch("ImpulseReactor.dll", useEndsWith: true), Utilities.GetInternalVersion, "Impulse Reactor Core Module"), + new PathMatchSet(new PathMatch("ReactorActivate.exe", useEndsWith: true), Utilities.GetInternalVersion, "Stardock Product Activation"), }; return MatchUtil.GetFirstMatch(path, matchers, any: true); diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs index 48ed469e..e6e97653 100644 --- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs +++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType // TODO: Is this too broad in general? string name = Utilities.GetInternalName(pex); if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("EReg", StringComparison.OrdinalIgnoreCase)) - return $"Executable-Based Online Registration {Utilities.GetFileVersion(pex)}"; + return $"Executable-Based Online Registration {Utilities.GetInternalVersion(pex)}"; return null; } diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index 7f4ca2d2..a4a251bf 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetFileDescription(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("SecuROM PA")) - return $"SecuROM PA v{Utilities.GetFileVersion(pex)}"; + return $"SecuROM PA v{Utilities.GetInternalVersion(pex)}"; // Get the matrosch section, if it exists bool matroschSection = pex.ContainsSection("matrosch", exact: true); @@ -101,7 +101,7 @@ namespace BurnOutSharp.ProtectionType { 0x64, 0x72, 0x6D, 0x5F, 0x70, 0x61, 0x67, 0x75, 0x69, 0x5F, 0x64, 0x6F, 0x69, 0x74 - }, Utilities.GetFileVersion, "SecuROM Product Activation"), + }, Utilities.GetInternalVersion, "SecuROM Product Activation"), // TODO: Re-enable this one if the above undermatches somehow // // S + (char)0x00 + e + (char)0x00 + c + (char)0x00 + u + (char)0x00 + R + (char)0x00 + O + (char)0x00 + M + (char)0x00 + + (char)0x00 + P + (char)0x00 + A + (char)0x00 @@ -110,7 +110,7 @@ namespace BurnOutSharp.ProtectionType // 0x53, 0x00, 0x65, 0x00, 0x63, 0x00, 0x75, 0x00, // 0x52, 0x00, 0x4F, 0x00, 0x4D, 0x00, 0x20, 0x00, // 0x50, 0x00, 0x41, 0x00 - // }, Utilities.GetFileVersion, "SecuROM Product Activation"), + // }, Utilities.GetInternalVersion, "SecuROM Product Activation"), }; string match = MatchUtil.GetFirstMatch(file, pex.ResourceDataSectionRaw, matchers, includeDebug); diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index a14ee224..12fad406 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -22,19 +22,19 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetFileDescription(pex); if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("DVM Library", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield {Utilities.GetFileVersion(pex)}"; + return $"SolidShield {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield Core.dll {Utilities.GetFileVersion(pex)}"; + return $"SolidShield Core.dll {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield Activation Manager Module {GetFileVersion(pex)}"; + return $"SolidShield Activation Manager Module {GetInternalVersion(pex)}"; name = Utilities.GetProductName(pex); if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield Core.dll {Utilities.GetFileVersion(pex)}"; + return $"SolidShield Core.dll {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield Core.dll {Utilities.GetFileVersion(pex)}"; + return $"SolidShield Core.dll {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase)) - return $"SolidShield Activation Manager Module {GetFileVersion(pex)}"; + return $"SolidShield Activation Manager Module {GetInternalVersion(pex)}"; // Get the .init section, if it exists var initSectionRaw = pex.ReadRawSection(".init", first: true); @@ -188,11 +188,11 @@ namespace BurnOutSharp.ProtectionType return null; } - private static string GetFileVersion(PortableExecutable pex) + private static string GetInternalVersion(PortableExecutable pex) { string companyName = Utilities.GetCompanyName(pex)?.ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(companyName) && (companyName.Contains("solidshield") || companyName.Contains("tages"))) - return Utilities.GetFileVersion(pex); + return Utilities.GetInternalVersion(pex); return null; } diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index a1a1cd6a..03e93dd2 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -20,13 +20,13 @@ namespace BurnOutSharp.ProtectionType string name = Utilities.GetLegalCopyright(pex); if (!string.IsNullOrWhiteSpace(name) && name.Contains("Protection Technology")) // Protection Technology (StarForce)? - return $"StarForce {Utilities.GetFileVersion(pex)}"; + return $"StarForce {Utilities.GetInternalVersion(pex)}"; name = Utilities.GetInternalName(pex); if (!string.IsNullOrWhiteSpace(name) && name.Equals("CORE.EXE", StringComparison.Ordinal)) - return $"StarForce {Utilities.GetFileVersion(pex)}"; + return $"StarForce {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.Equals("protect.exe", StringComparison.Ordinal)) - return $"StarForce {Utilities.GetFileVersion(pex)}"; + return $"StarForce {Utilities.GetInternalVersion(pex)}"; // TODO: Find what fvinfo field actually maps to this name = Utilities.GetFileDescription(pex); @@ -139,7 +139,7 @@ namespace BurnOutSharp.ProtectionType // }, GetVersion, "StarForce"), // public static string GetVersion(string file, byte[] fileContent, List positions) // { - // return $"{Utilities.GetFileVersion(fileContent)} ({fileContent.Skip(positions[1] + 22).TakeWhile(c => c != 0x00)})"; + // return $"{Utilities.GetInternalVersion(fileContent)} ({fileContent.Skip(positions[1] + 22).TakeWhile(c => c != 0x00)})"; // } } } diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs index a7ca0ec7..5162574f 100644 --- a/BurnOutSharp/ProtectionType/Steam.cs +++ b/BurnOutSharp/ProtectionType/Steam.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client API")) return "Steam"; else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Engine")) - return $"Steam Client Engine {Utilities.GetFileVersion(pex)}"; + return $"Steam Client Engine {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Service")) return "Steam"; diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 18e40495..0c043dbc 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -180,13 +180,8 @@ namespace BurnOutSharp.ProtectionType private string GetVersion(PortableExecutable pex) { - // Check the file version first - string version = Utilities.GetFileVersion(pex); - if (!string.IsNullOrEmpty(version)) - return version; - - // Then check the manifest version - version = Utilities.GetManifestVersion(pex); + // Check the internal versions + string version = Utilities.GetInternalVersion(pex); if (!string.IsNullOrEmpty(version)) return version; diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index cb98a2dc..0c29d674 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -181,41 +181,49 @@ namespace BurnOutSharp.Tools #endregion - #region Executable Information + #region Processed Executable Information /// - /// Get the company name as reported by the filesystem - /// - /// PortableExecutable representing the file contents - /// Company name string, null on error - public static string GetCompanyName(PortableExecutable pex) => GetResourceString(pex, "CompanyName"); - - /// - /// Get the file description as reported by the filesystem - /// - /// PortableExecutable representing the file contents - /// Description string, null on error - public static string GetFileDescription(PortableExecutable pex) => GetResourceString(pex, "FileDescription"); - - /// - /// Get the file version as reported by the filesystem + /// Get the internal version as reported by the resources /// /// Byte array representing the file contents /// Version string, null on error - public static string GetFileVersion(byte[] fileContent) + public static string GetInternalVersion(byte[] fileContent) { if (fileContent == null || !fileContent.Any()) return null; - return GetFileVersion(new PortableExecutable(fileContent, 0)); + return GetInternalVersion(new PortableExecutable(fileContent, 0)); } /// - /// Get the file version as reported by the filesystem + /// Get the internal version as reported by the resources + /// + /// PortableExecutable representing the file contents + /// Version string, null on error + public static string GetInternalVersion(PortableExecutable pex) + { + string version = GetFileVersion(pex); + if (!string.IsNullOrWhiteSpace(version)) + return version; + + version = GetProductVersion(pex); + if (!string.IsNullOrWhiteSpace(version)) + return version; + + version = GetManifestVersion(pex); + if (!string.IsNullOrWhiteSpace(version)) + return version; + + return null; + } + + /// + /// Get the internal version as reported by the filesystem /// /// File to check for version /// Version string, null on error - public static string GetFileVersion(string file) + public static string GetInternalVersion(string file) { var fvinfo = GetFileVersionInfo(file); if (fvinfo?.FileVersion == null) @@ -225,51 +233,41 @@ namespace BurnOutSharp.Tools else return fvinfo.ProductVersion.Replace(", ", "."); } - + + #endregion + + #region Executable Information + /// - /// Get the file version as reported by the filesystem + /// Get the company name as reported by the resources /// /// PortableExecutable representing the file contents - /// Version string, null on error - public static string GetFileVersion(PortableExecutable pex) - { - string version = GetResourceString(pex, "FileVersion"); - if (!string.IsNullOrWhiteSpace(version)) - return version.Replace(", ", "."); - - version = GetProductVersion(pex); - if (!string.IsNullOrWhiteSpace(version)) - return version; - - return null; - } + /// Company name string, null on error + public static string GetCompanyName(PortableExecutable pex) => GetResourceString(pex, "CompanyName"); /// - /// Wrapper for GetFileVersion for use in content matching + /// Get the file description as reported by the resources /// - /// File to check for version - /// Byte array representing the file contents - /// Last matched positions in the contents - /// Version string, null on error - public static string GetFileVersion(string file, byte[] fileContent, List positions) => GetFileVersion(fileContent); + /// PortableExecutable representing the file contents + /// Description string, null on error + public static string GetFileDescription(PortableExecutable pex) => GetResourceString(pex, "FileDescription"); /// - /// Wrapper for GetFileVersion for use in path matching + /// Get the file version as reported by the resources /// - /// File to check for version - /// Full list of input paths - /// Version string, null on error - public static string GetFileVersion(string firstMatchedString, IEnumerable files) => GetFileVersion(firstMatchedString); + /// PortableExecutable representing the file contents + /// File version string, null on error + public static string GetFileVersion(PortableExecutable pex) => GetResourceString(pex, "FileVersion")?.Replace(", ", "."); /// - /// Get the internal name as reported by the filesystem + /// Get the internal name as reported by the resources /// /// PortableExecutable representing the file contents /// Internal name string, null on error public static string GetInternalName(PortableExecutable pex) => GetResourceString(pex, "InternalName"); /// - /// Get the legal copyright as reported by the filesystem + /// Get the legal copyright as reported by the resources /// /// PortableExecutable representing the file contents /// Legal copyright string, null on error @@ -353,21 +351,21 @@ namespace BurnOutSharp.Tools } /// - /// Get the original filename as reported by the filesystem + /// Get the original filename as reported by the resources /// /// PortableExecutable representing the file contents /// Original filename string, null on error public static string GetOriginalFileName(PortableExecutable pex) => GetResourceString(pex, "OriginalFileName"); /// - /// Get the product name as reported by the filesystem + /// Get the product name as reported by the resources /// /// PortableExecutable representing the file contents /// Product name string, null on error public static string GetProductName(PortableExecutable pex) => GetResourceString(pex, "ProductName"); /// - /// Get the product name as reported by the filesystem + /// Get the product name as reported by the resources /// /// PortableExecutable representing the file contents /// Product version string, null on error @@ -552,5 +550,26 @@ namespace BurnOutSharp.Tools } #endregion + + #region Wrappers for Matchers + + /// + /// Wrapper for GetInternalVersion for use in content matching + /// + /// File to check for version + /// Byte array representing the file contents + /// Last matched positions in the contents + /// Version string, null on error + public static string GetInternalVersion(string file, byte[] fileContent, List positions) => GetInternalVersion(fileContent); + + /// + /// Wrapper for GetInternalVersion for use in path matching + /// + /// File to check for version + /// Full list of input paths + /// Version string, null on error + public static string GetInternalVersion(string firstMatchedString, IEnumerable files) => GetInternalVersion(firstMatchedString); + + #endregion } }