mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-02-09 21:32:11 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
99f4909e9b | ||
|
|
482644af85 |
@@ -2,7 +2,7 @@
|
||||
<package >
|
||||
<metadata>
|
||||
<id>BurnOutSharp</id>
|
||||
<version>1.03.8.0</version>
|
||||
<version>1.03.8.2</version>
|
||||
<title>BurnOutSharp</title>
|
||||
<authors>Matt Nadareski, Gernot Knippen</authors>
|
||||
<owners>Matt Nadareski, Gernot Knippen</owners>
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace BurnOutSharp
|
||||
|
||||
private static Process StartSafe(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return null;
|
||||
|
||||
Process startingprocess = new Process();
|
||||
@@ -59,7 +59,7 @@ namespace BurnOutSharp
|
||||
|
||||
private static string MakeTempFile(string file, string sExtension = ".exe")
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
FileInfo filei = new FileInfo(file);
|
||||
@@ -75,7 +75,7 @@ namespace BurnOutSharp
|
||||
|
||||
private static bool IsEXE(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return false;
|
||||
|
||||
BinaryReader breader = new BinaryReader(File.OpenRead(file));
|
||||
@@ -199,7 +199,7 @@ namespace BurnOutSharp
|
||||
|
||||
public static string SearchProtectDiscVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
Process exe = new Process();
|
||||
@@ -357,7 +357,7 @@ namespace BurnOutSharp
|
||||
|
||||
public static string SearchSafeDiscVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
Process exe = new Process();
|
||||
|
||||
@@ -21,6 +21,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using BurnOutSharp.ProtectionType;
|
||||
using LibMSPackN;
|
||||
@@ -436,36 +437,51 @@ namespace BurnOutSharp
|
||||
// InstallShield CAB
|
||||
else if (magic.StartsWith("ISc"))
|
||||
{
|
||||
try
|
||||
// Get the name of the first cabinet file or header
|
||||
string directory = Path.GetDirectoryName(file);
|
||||
string noExtension = Path.GetFileNameWithoutExtension(file);
|
||||
string filenamePattern = Path.Combine(directory, noExtension);
|
||||
filenamePattern = new Regex(@"\d+$").Replace(filenamePattern, string.Empty);
|
||||
|
||||
bool cabinetHeaderExists = File.Exists(Path.Combine(directory, filenamePattern + "1.hdr"));
|
||||
bool shouldScanCabinet = cabinetHeaderExists
|
||||
? file.Equals(Path.Combine(directory, filenamePattern + "1.hdr"), StringComparison.OrdinalIgnoreCase)
|
||||
: file.Equals(Path.Combine(directory, filenamePattern + "1.cab"), StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
// If we have the first file
|
||||
if (shouldScanCabinet)
|
||||
{
|
||||
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempPath);
|
||||
|
||||
UnshieldCabinet cabfile = UnshieldCabinet.Open(file);
|
||||
for (int i = 0; i < cabfile.FileCount; i++)
|
||||
{
|
||||
string tempFileName = Path.Combine(tempPath, cabfile.FileName(i));
|
||||
if (cabfile.FileSave(i, tempFileName))
|
||||
{
|
||||
string protection = ScanInFile(tempFileName);
|
||||
try
|
||||
{
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (!string.IsNullOrEmpty(protection))
|
||||
protections.Add(protection);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(tempPath, true);
|
||||
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
|
||||
Directory.CreateDirectory(tempPath);
|
||||
|
||||
UnshieldCabinet cabfile = UnshieldCabinet.Open(file);
|
||||
for (int i = 0; i < cabfile.FileCount; i++)
|
||||
{
|
||||
string tempFileName = Path.Combine(tempPath, cabfile.FileName(i));
|
||||
if (cabfile.FileSave(i, tempFileName))
|
||||
{
|
||||
string protection = ScanInFile(tempFileName);
|
||||
try
|
||||
{
|
||||
File.Delete(tempFileName);
|
||||
}
|
||||
catch { }
|
||||
|
||||
if (!string.IsNullOrEmpty(protection))
|
||||
protections.Add(protection);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Directory.Delete(tempPath, true);
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// Microsoft CAB
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
@@ -11,8 +12,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
if (Path.GetFileName(file) == "CDSPlayer.app")
|
||||
{
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var sr = new StreamReader(fs))
|
||||
using (var sr = new StreamReader(file, Encoding.Default))
|
||||
{
|
||||
return "Cactus Data Shield " + sr.ReadLine().Substring(3) + "(" + sr.ReadLine() + ")";
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
@@ -26,28 +27,19 @@ namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
foreach (string file in files)
|
||||
{
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var sr = new StreamReader(fs))
|
||||
// Load the current file content
|
||||
string fileContent = null;
|
||||
using (StreamReader sr = new StreamReader(file, Encoding.Default))
|
||||
{
|
||||
string fileContent = sr.ReadToEnd();
|
||||
string protection = CheckContents(path, fileContent);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
return protection;
|
||||
fileContent = sr.ReadToEnd();
|
||||
}
|
||||
|
||||
string protection = CheckContents(path, fileContent);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
return protection;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
string fileContent = sr.ReadToEnd();
|
||||
string protection = CheckContents(path, fileContent);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
return protection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersionBuild6till8(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
@@ -93,7 +93,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
private static string GetVersionBuild76till10(string file, int position, out int irefBuild)
|
||||
{
|
||||
irefBuild = 0;
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -39,15 +39,22 @@ namespace BurnOutSharp.ProtectionType
|
||||
// TODO: These are all cop-outs that don't check the existence of the other files
|
||||
if (files.Count(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
|
||||
{
|
||||
return GetDPlayerXVersion(path);
|
||||
string file = files.First(f => Path.GetFileName(f).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase));
|
||||
return GetDPlayerXVersion(file);
|
||||
}
|
||||
else if (files.Count(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase)) > 0)
|
||||
{
|
||||
return GetDrvmgtVersion(path);
|
||||
string file = files.First(f => Path.GetFileName(f).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase));
|
||||
return GetDrvmgtVersion(file);
|
||||
}
|
||||
else if (files.Count(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase)) > 0)
|
||||
{
|
||||
return GetSecdrvVersion(path);
|
||||
string file = files.First(f => Path.GetFileName(f).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase));
|
||||
return GetSecdrvVersion(file);
|
||||
}
|
||||
else if (path.EndsWith(".SafeDiscDVD.bundle", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "SafeDisc for Macintosh";
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -97,7 +104,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetDPlayerXVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
FileInfo fi = new FileInfo(file);
|
||||
@@ -125,7 +132,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetDrvmgtVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
FileInfo fi = new FileInfo(file);
|
||||
@@ -153,7 +160,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetSecdrvVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
FileInfo fi = new FileInfo(file);
|
||||
@@ -187,7 +194,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetV4Version(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
@@ -106,7 +106,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetV5Version(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
@@ -135,7 +135,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetV7Version(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -131,7 +131,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetBuild(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
@@ -76,7 +76,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetOldVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
@@ -98,7 +98,7 @@ namespace BurnOutSharp.ProtectionType
|
||||
|
||||
private static string GetVersion(string file, int position)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace BurnOutSharp
|
||||
/// </summary>
|
||||
public static string GetFileVersion(string file)
|
||||
{
|
||||
if (file == null)
|
||||
if (file == null || !File.Exists(file))
|
||||
return string.Empty;
|
||||
|
||||
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file);
|
||||
|
||||
Reference in New Issue
Block a user