mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-09-24 15:54:57 +00:00
Make file version finding safer
This commit is contained in:
@@ -232,8 +232,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (files.Length > 0)
|
||||
{
|
||||
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
|
||||
if (fvinfo.FileVersion != "")
|
||||
var fvinfo = Utilities.GetFileVersionInfo(files[0]);
|
||||
if (!string.IsNullOrWhiteSpace(fvinfo?.FileVersion))
|
||||
{
|
||||
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
|
||||
//ProtectDisc 9 uses a ProtectDisc-Core dll version 8.0.x
|
||||
@@ -249,8 +249,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
files = Directory.GetFiles(Path.GetTempPath(), "a*.tmp");
|
||||
if (files.Length > 0)
|
||||
{
|
||||
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
|
||||
if (fvinfo.FileVersion != "")
|
||||
var fvinfo = Utilities.GetFileVersionInfo(files[0]);
|
||||
if (!string.IsNullOrWhiteSpace(fvinfo?.FileVersion))
|
||||
{
|
||||
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
|
||||
fvinfo = null;
|
||||
|
||||
@@ -123,11 +123,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
public static string GetFileVersion(string file, byte[] fileContent, List<int> positions)
|
||||
{
|
||||
string companyName = string.Empty;
|
||||
if (file != null)
|
||||
companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
|
||||
|
||||
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
|
||||
string companyName = Utilities.GetFileVersionInfo(file)?.CompanyName.ToLowerInvariant();
|
||||
if (!string.IsNullOrWhiteSpace(companyName) && (companyName.Contains("solidshield") || companyName.Contains("tages")))
|
||||
return Utilities.GetFileVersion(file);
|
||||
|
||||
return null;
|
||||
|
||||
@@ -156,8 +156,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (files.Length > 0)
|
||||
{
|
||||
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
|
||||
if (fvinfo.FileVersion != "")
|
||||
var fvinfo = Utilities.GetFileVersionInfo(files[0]);
|
||||
if (!string.IsNullOrWhiteSpace(fvinfo?.FileVersion))
|
||||
{
|
||||
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
|
||||
//ProtectDisc 9 uses a ProtectDisc-Core dll version 8.0.x
|
||||
@@ -173,8 +173,8 @@ namespace BurnOutSharp.ProtectionType
|
||||
files = Directory.GetFiles(Path.GetTempPath(), "a*.tmp");
|
||||
if (files.Length > 0)
|
||||
{
|
||||
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
|
||||
if (fvinfo.FileVersion != "")
|
||||
var fvinfo = Utilities.GetFileVersionInfo(files[0]);
|
||||
if (!string.IsNullOrWhiteSpace(fvinfo?.FileVersion))
|
||||
{
|
||||
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
|
||||
fvinfo = null;
|
||||
|
||||
Reference in New Issue
Block a user