From b933249ff767e1b5f51c461fdde30cf00f1c1ee2 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sat, 2 Apr 2022 16:12:23 -0700 Subject: [PATCH] Add resource finding on creation --- .../Microsoft/PE/PortableExecutable.cs | 277 ++++++++++-------- .../PackerType/AutoPlayMediaStudio.cs | 4 +- BurnOutSharp/PackerType/InstallAnywhere.cs | 4 +- .../PackerType/IntelInstallationFramework.cs | 4 +- BurnOutSharp/PackerType/MicrosoftCABSFX.cs | 4 +- BurnOutSharp/PackerType/NSIS.cs | 2 +- BurnOutSharp/PackerType/SetupFactory.cs | 8 +- BurnOutSharp/PackerType/WinZipSFX.cs | 4 +- BurnOutSharp/ProtectionType/CDKey.cs | 2 +- BurnOutSharp/ProtectionType/ElectronicArts.cs | 4 +- BurnOutSharp/ProtectionType/GFWL.cs | 2 +- BurnOutSharp/ProtectionType/ImpulseReactor.cs | 6 +- BurnOutSharp/ProtectionType/Key2AudioXS.cs | 2 +- .../ProtectionType/OnlineRegistration.cs | 2 +- BurnOutSharp/ProtectionType/Origin.cs | 4 +- BurnOutSharp/ProtectionType/SafeDisc.cs | 2 +- BurnOutSharp/ProtectionType/SecuROM.cs | 2 +- BurnOutSharp/ProtectionType/SolidShield.cs | 6 +- BurnOutSharp/ProtectionType/StarForce.cs | 7 +- BurnOutSharp/ProtectionType/Steam.cs | 4 +- BurnOutSharp/ProtectionType/Tages.cs | 4 +- BurnOutSharp/ProtectionType/Uplay.cs | 4 +- BurnOutSharp/ProtectionType/WTMCDProtect.cs | 4 +- BurnOutSharp/Tools/Utilities.cs | 10 +- 24 files changed, 199 insertions(+), 173 deletions(-) diff --git a/BurnOutSharp/ExecutableType/Microsoft/PE/PortableExecutable.cs b/BurnOutSharp/ExecutableType/Microsoft/PE/PortableExecutable.cs index 3a82ee28..2f134d50 100644 --- a/BurnOutSharp/ExecutableType/Microsoft/PE/PortableExecutable.cs +++ b/BurnOutSharp/ExecutableType/Microsoft/PE/PortableExecutable.cs @@ -184,6 +184,60 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE #endregion + #region Resources + + /// + /// Company name resource string + /// + public string CompanyName { get; private set; } + + /// + /// File description resource string + /// + public string FileDescription { get; private set; } + + /// + /// File version resource string + /// + public string FileVersion { get; private set; } + + /// + /// Internal name resource string + /// + public string InternalName { get; private set; } + + /// + /// Legal copyright resource string + /// + public string LegalCopyright { get; private set; } + + /// + /// Description manifest string + /// + public string ManifestDescription { get; private set; } + + /// + /// Version manifest string + /// + public string ManifestVersion { get; private set; } + + /// + /// Original filename resource string + /// + public string OriginalFileName { get; private set; } + + /// + /// Product name resource string + /// + public string ProductName { get; private set; } + + /// + /// Product version resource string + /// + public string ProductVersion { get; private set; } + + #endregion + #region Constructors /// @@ -311,6 +365,9 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE this.TextSectionRaw = this.ReadRawSection(".text", force: true, first: false); #endregion + + // Populate resources, if possible + PopulateResourceStrings(); } catch (Exception ex) { @@ -418,6 +475,9 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE this.TextSectionRaw = this.ReadRawSection(".text", force: true, first: false); #endregion + + // Populate resources, if possible + PopulateResourceStrings(); } catch (Exception ex) { @@ -430,7 +490,6 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE #endregion - // TODO: This entire section needs to have caching #region Resource Helpers /// @@ -448,127 +507,6 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE return FindResourceInTable(this.ResourceSection.ResourceDirectoryTable, dataStart, dataContains, dataEnd); } - /// - /// Get the company name as reported by the resources - /// - /// Company name string, null on error - public string GetCompanyName() => GetResourceString("CompanyName"); - - /// - /// Get the file description as reported by the resources - /// - /// Description string, null on error - public string GetFileDescription() => GetResourceString("FileDescription"); - - /// - /// Get the file version as reported by the resources - /// - /// File version string, null on error - public string GetFileVersion() => GetResourceString("FileVersion")?.Replace(", ", "."); - - /// - /// Get the internal name as reported by the resources - /// - /// Internal name string, null on error - public string GetInternalName() => GetResourceString("InternalName"); - - /// - /// Get the legal copyright as reported by the resources - /// - /// Legal copyright string, null on error - public string GetLegalCopyright() => GetResourceString("LegalCopyright"); - - /// - /// Get the assembly version as determined by an embedded assembly manifest - /// - /// Description string, null on error - public string GetManifestDescription() - { - // If we don't have a complete PE executable, just return null - if (this.ResourceSection == null) - return null; - - // Read in the manifest to a string - string manifestString = FindAssemblyManifest(); - if (string.IsNullOrWhiteSpace(manifestString)) - return null; - - // Try to read the XML in from the string - try - { - // Try to read the assembly - var assemblyNode = GetAssemblyNode(manifestString); - if (assemblyNode == null) - return null; - - // Return the content of the description node, if possible - var descriptionNode = assemblyNode["description"]; - if (descriptionNode == null) - return null; - - return descriptionNode.InnerXml; - } - catch - { - return null; - } - } - - /// - /// Get the assembly version as determined by an embedded assembly manifest - /// - /// Version string, null on error - public string GetManifestVersion() - { - // If we don't have a complete PE executable, just return null - if (this.ResourceSection == null) - return null; - - // Read in the manifest to a string - string manifestString = FindAssemblyManifest(); - if (string.IsNullOrWhiteSpace(manifestString)) - return null; - - // Try to read the XML in from the string - try - { - // Try to read the assembly - var assemblyNode = GetAssemblyNode(manifestString); - if (assemblyNode == null) - return null; - - // Try to read the assemblyIdentity - var assemblyIdentityNode = assemblyNode["assemblyIdentity"]; - if (assemblyIdentityNode == null) - return null; - - // Return the version attribute, if possible - return assemblyIdentityNode.GetAttribute("version"); - } - catch - { - return null; - } - } - - /// - /// Get the original filename as reported by the resources - /// - /// Original filename string, null on error - public string GetOriginalFileName() => GetResourceString("OriginalFileName"); - - /// - /// Get the product name as reported by the resources - /// - /// Product name string, null on error - public string GetProductName() => GetResourceString("ProductName"); - - /// - /// Get the product name as reported by the resources - /// - /// Product version string, null on error - public string GetProductVersion() => GetResourceString("ProductVersion")?.Replace(", ", "."); - /// /// Get the assembly identity node from an embedded manifest /// @@ -663,6 +601,79 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE return null; } + /// + /// Get the assembly version as determined by an embedded assembly manifest + /// + /// Description string, null on error + private string GetManifestDescription() + { + // If we don't have a complete PE executable, just return null + if (this.ResourceSection == null) + return null; + + // Read in the manifest to a string + string manifestString = FindAssemblyManifest(); + if (string.IsNullOrWhiteSpace(manifestString)) + return null; + + // Try to read the XML in from the string + try + { + // Try to read the assembly + var assemblyNode = GetAssemblyNode(manifestString); + if (assemblyNode == null) + return null; + + // Return the content of the description node, if possible + var descriptionNode = assemblyNode["description"]; + if (descriptionNode == null) + return null; + + return descriptionNode.InnerXml; + } + catch + { + return null; + } + } + + /// + /// Get the assembly version as determined by an embedded assembly manifest + /// + /// Version string, null on error + private string GetManifestVersion() + { + // If we don't have a complete PE executable, just return null + if (this.ResourceSection == null) + return null; + + // Read in the manifest to a string + string manifestString = FindAssemblyManifest(); + if (string.IsNullOrWhiteSpace(manifestString)) + return null; + + // Try to read the XML in from the string + try + { + // Try to read the assembly + var assemblyNode = GetAssemblyNode(manifestString); + if (assemblyNode == null) + return null; + + // Try to read the assemblyIdentity + var assemblyIdentityNode = assemblyNode["assemblyIdentity"]; + if (assemblyIdentityNode == null) + return null; + + // Return the version attribute, if possible + return assemblyIdentityNode.GetAttribute("version"); + } + catch + { + return null; + } + } + /// /// Get a resource string from the version info /// @@ -683,7 +694,6 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE /// /// Get the version info object related to file contents, if possible /// - /// PortableExecutable representing the file contents /// VersionInfo object on success, null on error private VersionInfo GetVersionInfo() { @@ -708,6 +718,27 @@ namespace BurnOutSharp.ExecutableType.Microsoft.PE } } + /// + /// Populate all resource strings + /// + private void PopulateResourceStrings() + { + // Standalone resource strings + this.CompanyName = GetResourceString("CompanyName"); + this.FileDescription = GetResourceString("FileDescription"); + this.FileVersion = GetResourceString("FileVersion")?.Replace(", ", "."); + this.InternalName = GetResourceString("InternalName"); + this.LegalCopyright = GetResourceString("LegalCopyright"); + this.OriginalFileName = GetResourceString("OriginalFileName"); + this.ProductName = GetResourceString("ProductName"); + this.ProductVersion = GetResourceString("ProductVersion")?.Replace(", ", "."); + + // TODO: Make these combined calls more efficient + // Manifest resource strings + this.ManifestDescription = GetManifestDescription(); + this.ManifestVersion = GetManifestVersion(); + } + #endregion #region Section Helpers diff --git a/BurnOutSharp/PackerType/AutoPlayMediaStudio.cs b/BurnOutSharp/PackerType/AutoPlayMediaStudio.cs index 2dde314f..a3671b12 100644 --- a/BurnOutSharp/PackerType/AutoPlayMediaStudio.cs +++ b/BurnOutSharp/PackerType/AutoPlayMediaStudio.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.PackerType return null; // Known to detect versions 5.0.0.3 - 8.1.0.0 - string name = pex.GetProductName(); + string name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("AutoPlay Media Studio", StringComparison.OrdinalIgnoreCase)) return $"AutoPlay Media Studio {GetVersion(pex)}"; @@ -57,7 +57,7 @@ namespace BurnOutSharp.PackerType private string GetVersion(PortableExecutable pex) { // Check the product version explicitly - string version = pex.GetProductVersion(); + string version = pex.ProductVersion; if (!string.IsNullOrEmpty(version)) return version; diff --git a/BurnOutSharp/PackerType/InstallAnywhere.cs b/BurnOutSharp/PackerType/InstallAnywhere.cs index 7d5e97da..51ac29b1 100644 --- a/BurnOutSharp/PackerType/InstallAnywhere.cs +++ b/BurnOutSharp/PackerType/InstallAnywhere.cs @@ -19,11 +19,11 @@ namespace BurnOutSharp.PackerType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("InstallAnywhere Self Extractor", StringComparison.OrdinalIgnoreCase)) return $"InstallAnywhere {GetVersion(pex)}"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("InstallAnywhere", StringComparison.OrdinalIgnoreCase)) return $"InstallAnywhere {GetVersion(pex)}"; diff --git a/BurnOutSharp/PackerType/IntelInstallationFramework.cs b/BurnOutSharp/PackerType/IntelInstallationFramework.cs index 11cee13e..b931282e 100644 --- a/BurnOutSharp/PackerType/IntelInstallationFramework.cs +++ b/BurnOutSharp/PackerType/IntelInstallationFramework.cs @@ -15,7 +15,7 @@ namespace BurnOutSharp.PackerType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) || name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase))) @@ -23,7 +23,7 @@ namespace BurnOutSharp.PackerType return $"Intel Installation Framework {Utilities.GetInternalVersion(pex)}"; } - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && (name.Equals("Intel(R) Installation Framework", StringComparison.OrdinalIgnoreCase) || name.Equals("Intel Installation Framework", StringComparison.OrdinalIgnoreCase))) diff --git a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs index 8eef2ae8..41a78956 100644 --- a/BurnOutSharp/PackerType/MicrosoftCABSFX.cs +++ b/BurnOutSharp/PackerType/MicrosoftCABSFX.cs @@ -22,11 +22,11 @@ namespace BurnOutSharp.PackerType if (sections == null) return null; - string name = pex.GetInternalName(); + string name = pex.InternalName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("Wextract", StringComparison.OrdinalIgnoreCase)) return $"Microsoft CAB SFX {GetVersion(pex)}"; - name = pex.GetOriginalFileName(); + name = pex.OriginalFileName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("WEXTRACT.EXE", StringComparison.OrdinalIgnoreCase)) return $"Microsoft CAB SFX {GetVersion(pex)}"; diff --git a/BurnOutSharp/PackerType/NSIS.cs b/BurnOutSharp/PackerType/NSIS.cs index d4d1fe8e..91ebc6b1 100644 --- a/BurnOutSharp/PackerType/NSIS.cs +++ b/BurnOutSharp/PackerType/NSIS.cs @@ -14,7 +14,7 @@ namespace BurnOutSharp.PackerType if (sections == null) return null; - string description = pex.GetManifestDescription(); + string description = pex.ManifestDescription; if (!string.IsNullOrWhiteSpace(description) && description.StartsWith("Nullsoft Install System")) return $"NSIS {description.Substring("Nullsoft Install System".Length).Trim()}"; diff --git a/BurnOutSharp/PackerType/SetupFactory.cs b/BurnOutSharp/PackerType/SetupFactory.cs index 2e694ac9..d1854e14 100644 --- a/BurnOutSharp/PackerType/SetupFactory.cs +++ b/BurnOutSharp/PackerType/SetupFactory.cs @@ -20,16 +20,16 @@ namespace BurnOutSharp.PackerType return null; // Known to detect versions 7.0.5.1 - 9.1.0.0 - string name = pex.GetLegalCopyright(); + string name = pex.LegalCopyright; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Setup Engine", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; // Known to detect version 5.0.1 - 6.0.1.3 - name = pex.GetFileDescription(); + name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Setup Factory", StringComparison.OrdinalIgnoreCase)) return $"Setup Factory {GetVersion(pex)}"; @@ -62,7 +62,7 @@ namespace BurnOutSharp.PackerType private string GetVersion(PortableExecutable pex) { // Check the product version explicitly - string version = pex.GetProductVersion(); + string version = pex.ProductVersion; if (!string.IsNullOrEmpty(version)) return version; diff --git a/BurnOutSharp/PackerType/WinZipSFX.cs b/BurnOutSharp/PackerType/WinZipSFX.cs index 2aad534b..4607e145 100644 --- a/BurnOutSharp/PackerType/WinZipSFX.cs +++ b/BurnOutSharp/PackerType/WinZipSFX.cs @@ -187,8 +187,8 @@ namespace BurnOutSharp.PackerType private static string GetAdjustedManifestVersion(PortableExecutable pex) { // Get the manifest information, if possible - string description = pex.GetManifestDescription(); - string version = pex.GetManifestVersion(); + string description = pex.ManifestDescription; + string version = pex.ManifestVersion; // Either an incorrect description or empty version mean we can't match if (description != "WinZip Self-Extractor") diff --git a/BurnOutSharp/ProtectionType/CDKey.cs b/BurnOutSharp/ProtectionType/CDKey.cs index a3750f50..7f81f1a3 100644 --- a/BurnOutSharp/ProtectionType/CDKey.cs +++ b/BurnOutSharp/ProtectionType/CDKey.cs @@ -13,7 +13,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetInternalName(); + string name = pex.InternalName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("CDKey", StringComparison.OrdinalIgnoreCase)) return "CD-Key / Serial"; diff --git a/BurnOutSharp/ProtectionType/ElectronicArts.cs b/BurnOutSharp/ProtectionType/ElectronicArts.cs index 06534799..9df3412a 100644 --- a/BurnOutSharp/ProtectionType/ElectronicArts.cs +++ b/BurnOutSharp/ProtectionType/ElectronicArts.cs @@ -22,7 +22,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Contains("EReg MFC Application")) return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.Contains("Registration code installer program")) @@ -30,7 +30,7 @@ namespace BurnOutSharp.ProtectionType else if (!string.IsNullOrWhiteSpace(name) && name.Equals("EA DRM Helper", StringComparison.OrdinalIgnoreCase)) return $"EA DRM Protection {Utilities.GetInternalVersion(pex)}"; - name = pex.GetInternalName(); + name = pex.InternalName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("CDCode", StringComparison.Ordinal)) return $"EA CdKey Registration Module {Utilities.GetInternalVersion(pex)}"; diff --git a/BurnOutSharp/ProtectionType/GFWL.cs b/BurnOutSharp/ProtectionType/GFWL.cs index 3c834225..4afefe08 100644 --- a/BurnOutSharp/ProtectionType/GFWL.cs +++ b/BurnOutSharp/ProtectionType/GFWL.cs @@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; 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.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Games for Windows", StringComparison.OrdinalIgnoreCase)) diff --git a/BurnOutSharp/ProtectionType/ImpulseReactor.cs b/BurnOutSharp/ProtectionType/ImpulseReactor.cs index 0fdf8c0c..3ab3054a 100644 --- a/BurnOutSharp/ProtectionType/ImpulseReactor.cs +++ b/BurnOutSharp/ProtectionType/ImpulseReactor.cs @@ -18,15 +18,15 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Contains("ImpulseReactor Dynamic Link Library")) return $"Impulse Reactor Core Module {Utilities.GetInternalVersion(pex)}"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.Contains("ImpulseReactor Dynamic Link Library")) return $"Impulse Reactor Core Module {Utilities.GetInternalVersion(pex)}"; - name = pex.GetOriginalFileName(); + name = pex.OriginalFileName; if (!string.IsNullOrWhiteSpace(name) && name.Contains("ReactorActivate.exe")) return $"Stardock Product Activation {Utilities.GetInternalVersion(pex)}"; diff --git a/BurnOutSharp/ProtectionType/Key2AudioXS.cs b/BurnOutSharp/ProtectionType/Key2AudioXS.cs index f15b23ce..33e403b3 100644 --- a/BurnOutSharp/ProtectionType/Key2AudioXS.cs +++ b/BurnOutSharp/ProtectionType/Key2AudioXS.cs @@ -15,7 +15,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Contains("SDKHM (KEEP)")) return "key2AudioXS"; else if (!string.IsNullOrWhiteSpace(name) && name.Contains("SDKHM (KEPT)")) diff --git a/BurnOutSharp/ProtectionType/OnlineRegistration.cs b/BurnOutSharp/ProtectionType/OnlineRegistration.cs index 30e11baa..ab13d4a5 100644 --- a/BurnOutSharp/ProtectionType/OnlineRegistration.cs +++ b/BurnOutSharp/ProtectionType/OnlineRegistration.cs @@ -15,7 +15,7 @@ namespace BurnOutSharp.ProtectionType return null; // TODO: Is this too broad in general? - string name = pex.GetInternalName(); + string name = pex.InternalName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("EReg", StringComparison.OrdinalIgnoreCase)) return $"Executable-Based Online Registration {Utilities.GetInternalVersion(pex)}"; diff --git a/BurnOutSharp/ProtectionType/Origin.cs b/BurnOutSharp/ProtectionType/Origin.cs index c91e88eb..449355b0 100644 --- a/BurnOutSharp/ProtectionType/Origin.cs +++ b/BurnOutSharp/ProtectionType/Origin.cs @@ -16,11 +16,11 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Equals("Origin", StringComparison.OrdinalIgnoreCase)) return "Origin"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("Origin", StringComparison.OrdinalIgnoreCase)) return "Origin"; diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs index 32146d2a..182f98e6 100644 --- a/BurnOutSharp/ProtectionType/SafeDisc.cs +++ b/BurnOutSharp/ProtectionType/SafeDisc.cs @@ -54,7 +54,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Equals("SafeCast2", StringComparison.OrdinalIgnoreCase)) return $"SafeCast"; diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs index a6a34bc1..7ef56c49 100644 --- a/BurnOutSharp/ProtectionType/SecuROM.cs +++ b/BurnOutSharp/ProtectionType/SecuROM.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Contains("SecuROM PA")) return $"SecuROM PA v{Utilities.GetInternalVersion(pex)}"; diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs index 91e04329..2d235c76 100644 --- a/BurnOutSharp/ProtectionType/SolidShield.cs +++ b/BurnOutSharp/ProtectionType/SolidShield.cs @@ -20,7 +20,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("DVM Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) @@ -28,7 +28,7 @@ namespace BurnOutSharp.ProtectionType else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Activation Manager", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Activation Manager Module {GetInternalVersion(pex)}"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Activation Library", StringComparison.OrdinalIgnoreCase)) return $"SolidShield Core.dll {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Solidshield Library", StringComparison.OrdinalIgnoreCase)) @@ -190,7 +190,7 @@ namespace BurnOutSharp.ProtectionType private static string GetInternalVersion(PortableExecutable pex) { - string companyName = pex.GetCompanyName()?.ToLowerInvariant(); + string companyName = pex.CompanyName?.ToLowerInvariant(); if (!string.IsNullOrWhiteSpace(companyName) && (companyName.Contains("solidshield") || companyName.Contains("tages"))) return Utilities.GetInternalVersion(pex); diff --git a/BurnOutSharp/ProtectionType/StarForce.cs b/BurnOutSharp/ProtectionType/StarForce.cs index be9992a1..86f3984d 100644 --- a/BurnOutSharp/ProtectionType/StarForce.cs +++ b/BurnOutSharp/ProtectionType/StarForce.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; -using System.Text; using BurnOutSharp.ExecutableType.Microsoft.PE; using BurnOutSharp.Matching; using BurnOutSharp.Tools; @@ -18,18 +17,18 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetLegalCopyright(); + string name = pex.LegalCopyright; if (!string.IsNullOrWhiteSpace(name) && name.Contains("Protection Technology")) // Protection Technology (StarForce)? return $"StarForce {Utilities.GetInternalVersion(pex)}"; - name = pex.GetInternalName(); + name = pex.InternalName; if (!string.IsNullOrWhiteSpace(name) && name.Equals("CORE.EXE", StringComparison.Ordinal)) return $"StarForce {Utilities.GetInternalVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.Equals("protect.exe", StringComparison.Ordinal)) return $"StarForce {Utilities.GetInternalVersion(pex)}"; // TODO: Find what fvinfo field actually maps to this - name = pex.GetFileDescription(); + name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.Contains("Protected Module")) return $"StarForce 5"; diff --git a/BurnOutSharp/ProtectionType/Steam.cs b/BurnOutSharp/ProtectionType/Steam.cs index dab6cfe2..9df68841 100644 --- a/BurnOutSharp/ProtectionType/Steam.cs +++ b/BurnOutSharp/ProtectionType/Steam.cs @@ -16,7 +16,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrEmpty(name) && name.Contains("Steam Autorun Setup")) return "Steam"; else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client API")) @@ -26,7 +26,7 @@ namespace BurnOutSharp.ProtectionType else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client Service")) return "Steam"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrEmpty(name) && name.Contains("Steam Autorun Setup")) return "Steam"; else if (!string.IsNullOrEmpty(name) && name.Contains("Steam Client API")) diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs index 45ffa8b9..13e29437 100644 --- a/BurnOutSharp/ProtectionType/Tages.cs +++ b/BurnOutSharp/ProtectionType/Tages.cs @@ -28,13 +28,13 @@ namespace BurnOutSharp.ProtectionType // - TagesClient.exe // - TagesClient.dat (Does not always exist) - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("TagesSetup", StringComparison.OrdinalIgnoreCase)) return $"TAGES Driver Setup {GetVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Tagès activation client", StringComparison.OrdinalIgnoreCase)) return $"TAGES Activation Client {GetVersion(pex)}"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("Application TagesSetup", StringComparison.OrdinalIgnoreCase)) return $"TAGES Driver Setup {GetVersion(pex)}"; else if (!string.IsNullOrWhiteSpace(name) && name.StartsWith("T@GES", StringComparison.OrdinalIgnoreCase)) diff --git a/BurnOutSharp/ProtectionType/Uplay.cs b/BurnOutSharp/ProtectionType/Uplay.cs index 1f234dfc..1d72d6da 100644 --- a/BurnOutSharp/ProtectionType/Uplay.cs +++ b/BurnOutSharp/ProtectionType/Uplay.cs @@ -16,7 +16,7 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect Installer")) return "Uplay / Ubisoft Connect"; else if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect Service")) @@ -33,7 +33,7 @@ namespace BurnOutSharp.ProtectionType return "Uplay / Ubisoft Connect"; // There's also a variant that looks like "Uplay installer" - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrEmpty(name) && name.Contains("Ubisoft Connect")) return "Uplay / Ubisoft Connect"; else if (!string.IsNullOrEmpty(name) && name.Contains("Uplay")) diff --git a/BurnOutSharp/ProtectionType/WTMCDProtect.cs b/BurnOutSharp/ProtectionType/WTMCDProtect.cs index 34afb886..ba5d250a 100644 --- a/BurnOutSharp/ProtectionType/WTMCDProtect.cs +++ b/BurnOutSharp/ProtectionType/WTMCDProtect.cs @@ -15,11 +15,11 @@ namespace BurnOutSharp.ProtectionType if (sections == null) return null; - string name = pex.GetFileDescription(); + string name = pex.FileDescription; if (!string.IsNullOrEmpty(name) && name.Contains("Copy Protection Viewer")) return "WTM Protection Viewer"; - name = pex.GetProductName(); + name = pex.ProductName; if (!string.IsNullOrEmpty(name) && name.Contains("WTM Copy Protection Viewer")) return "WTM Protection Viewer"; diff --git a/BurnOutSharp/Tools/Utilities.cs b/BurnOutSharp/Tools/Utilities.cs index b7940faf..380d4202 100644 --- a/BurnOutSharp/Tools/Utilities.cs +++ b/BurnOutSharp/Tools/Utilities.cs @@ -4,11 +4,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; -using System.Xml; using BurnOutSharp.ExecutableType.Microsoft.PE; -using BurnOutSharp.ExecutableType.Microsoft.PE.Entries; -using BurnOutSharp.ExecutableType.Microsoft.PE.Sections; -using BurnOutSharp.ExecutableType.Microsoft.PE.Tables; namespace BurnOutSharp.Tools { @@ -202,15 +198,15 @@ namespace BurnOutSharp.Tools /// Version string, null on error public static string GetInternalVersion(PortableExecutable pex) { - string version = pex.GetFileVersion(); + string version = pex.FileVersion; if (!string.IsNullOrWhiteSpace(version)) return version; - version = pex.GetProductVersion(); + version = pex.ProductVersion; if (!string.IsNullOrWhiteSpace(version)) return version; - version = pex.GetManifestVersion(); + version = pex.ManifestVersion; if (!string.IsNullOrWhiteSpace(version)) return version;