diff --git a/BurnOutSharp.sln b/BurnOutSharp.sln
index e7ba4788..c82b3e74 100644
--- a/BurnOutSharp.sln
+++ b/BurnOutSharp.sln
@@ -1,12 +1,17 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 15
-VisualStudioVersion = 15.0.27703.2026
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.29306.81
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BurnOutSharp", "BurnOutSharp\BurnOutSharp.csproj", "{1DA4212E-6071-4951-B45D-BB74A7838246}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{88735BA2-778D-4192-8EB2-FFF6843719E2}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{68D10531-99CB-40B1-8912-73FA286C9433}"
+ ProjectSection(SolutionItems) = preProject
+ README.md = README.md
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
diff --git a/BurnOutSharp/EVORE.cs b/BurnOutSharp/EVORE.cs
index 140012dc..2d2a4723 100644
--- a/BurnOutSharp/EVORE.cs
+++ b/BurnOutSharp/EVORE.cs
@@ -37,6 +37,9 @@ namespace BurnOutSharp
private static Process StartSafe(string file)
{
+ if (file == null)
+ return string.Empty;
+
Process startingprocess = new Process();
startingprocess.StartInfo.FileName = file;
startingprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
@@ -56,6 +59,9 @@ namespace BurnOutSharp
private static string MakeTempFile(string file, string sExtension = ".exe")
{
+ if (file == null)
+ return string.Empty;
+
FileInfo filei = new FileInfo(file);
try
{
@@ -69,6 +75,9 @@ namespace BurnOutSharp
private static bool IsEXE(string file)
{
+ if (file == null)
+ return false;
+
BinaryReader breader = new BinaryReader(File.OpenRead(file));
breader.ReadBytes(60);
int PEHeaderOffset = breader.ReadInt32();
@@ -85,6 +94,9 @@ namespace BurnOutSharp
private static string[] CopyDependentDlls(string exefile)
{
+ if (exefile == null)
+ return null;
+
FileInfo fiExe = new FileInfo(exefile);
Section[] sections = ReadSections(exefile);
BinaryReader breader = new BinaryReader(File.OpenRead(exefile), Encoding.Default);
@@ -141,6 +153,9 @@ namespace BurnOutSharp
private static Section[] ReadSections(string exefile)
{
+ if (exefile == null)
+ return null;
+
BinaryReader breader = new BinaryReader(File.OpenRead(exefile));
breader.ReadBytes(60);
uint PEHeaderOffset = breader.ReadUInt32();
@@ -184,6 +199,9 @@ namespace BurnOutSharp
public static string SearchProtectDiscVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
Process exe = new Process();
Process[] processes = new Process[0];
string version = "";
@@ -339,6 +357,9 @@ namespace BurnOutSharp
public static string SearchSafeDiscVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
Process exe = new Process();
string version = "";
DateTime timestart;
diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs
index 64b9310f..e4910eaa 100644
--- a/BurnOutSharp/ProtectionFind.cs
+++ b/BurnOutSharp/ProtectionFind.cs
@@ -116,7 +116,7 @@ namespace BurnOutSharp
///
///
///
- private static string ScanPath(string path, bool isDirectory)
+ public static string ScanPath(string path, bool isDirectory)
{
List protections = new List();
string protection;
@@ -353,7 +353,8 @@ namespace BurnOutSharp
///
/// Scan an individual file for copy protection
///
- private static string ScanInFile(string file)
+ /// File path for scanning
+ public static string ScanInFile(string file)
{
// Get the extension for certain checks
string extension = Path.GetExtension(file).ToLower().TrimStart('.');
@@ -383,196 +384,14 @@ namespace BurnOutSharp
{
try
{
- // Load the current file and check for specialty strings first
- StreamReader sr = new StreamReader(file, Encoding.Default);
- string protection;
- string fileContent = sr.ReadToEnd();
- sr.Close();
+ // Load the current file content
+ string fileContent = null;
+ using (StreamReader sr = new StreamReader(file))
+ {
+ fileContent = sr.ReadToEnd();
+ }
- // 3PLock
- protection = ThreePLock.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // ActiveMARK
- protection = ActiveMARK.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Alpha-ROM
- protection = AlphaROM.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Armadillo
- protection = Armadillo.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // CD-Cops
- protection = CDCops.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // CD-Lock
- protection = CDLock.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // CDSHiELD SE
- protection = CDSHiELDSE.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // CD Check
- protection = CDCheck.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Cenega ProtectDVD
- protection = CengaProtectDVD.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Code Lock
- protection = CodeLock.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // CopyKiller
- protection = CopyKiller.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Cucko (EA Custom)
- protection = Cucko.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // dotFuscator
- protection = dotFuscator.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // DVD-Cops
- protection = DVDCops.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // EA CdKey Registration Module
- protection = EACdKey.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // EXE Stealth
- protection = EXEStealth.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Games for Windows - Live
- protection = GFWL.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Impulse Reactor
- protection = ImpulseReactor.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Inno Setup
- protection = InnoSetup.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // JoWooD X-Prot
- protection = JoWooDXProt.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Key-Lock (Dongle)
- protection = KeyLock.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // LaserLock
- protection = LaserLock.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // PE Compact
- protection = PECompact.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // ProtectDisc
- protection = ProtectDisc.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Ring PROTECH
- protection = RingPROTECH.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SafeDisc / SafeCast
- protection = SafeDisc.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SafeLock
- protection = SafeLock.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SecuROM
- protection = SecuROM.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SmartE
- protection = SmartE.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SolidShield
- protection = SolidShield.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // StarForce
- protection = StarForce.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // SVK Protector
- protection = SVKProtector.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Sysiphus / Sysiphus DVD
- protection = Sysiphus.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // TAGES
- protection = Tages.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // VOB ProtectCD/DVD
- protection = VOBProtectCDDVD.CheckContents(file, fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // WTM CD Protect
- protection = WTMCDProtect.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
-
- // Xtreme-Protector
- protection = XtremeProtector.CheckContents(fileContent);
- if (!string.IsNullOrWhiteSpace(protection))
- protections.Add(protection);
+ protections.AddRange(ScanFileContent(file, fileContent));
}
catch { }
}
@@ -602,7 +421,6 @@ namespace BurnOutSharp
{
// We don't care what the error was
}
- // No-op
}
#endregion
@@ -704,6 +522,325 @@ namespace BurnOutSharp
return string.Join(", ", protections);
}
+ ///
+ /// Scan an individual stream for copy protection
+ ///
+ /// Generic stream to scan
+ /// File path to be used for name checks (optional)
+ public static string ScanInFile(Stream stream, string file = null)
+ {
+ // Assume the first part of the stream is the start of a file
+ string magic = "";
+ try
+ {
+ using (BinaryReader br = new BinaryReader(stream, Encoding.Default, true))
+ {
+ magic = new string(br.ReadChars(8));
+ }
+ }
+ catch
+ {
+ // We don't care what the issue was, we can't open the file
+ return null;
+ }
+
+ // If we can, seek to the beginning of the stream
+ if (stream.CanSeek)
+ stream.Seek(0, SeekOrigin.Begin);
+
+ // Files can be protected in multiple ways
+ List protections = new List();
+
+ #region Executable Content Checks
+
+ // Windows Executable and DLL
+ if (magic.StartsWith("MZ"))
+ {
+ try
+ {
+ // Load the current file content
+ string fileContent = null;
+ using (StreamReader sr = new StreamReader(stream))
+ {
+ fileContent = sr.ReadToEnd();
+ }
+
+ protections.AddRange(ScanFileContent(file, fileContent));
+ }
+ catch { }
+ }
+
+ #endregion
+
+ #region Textfile Content Checks
+
+ if (magic.StartsWith("{\rtf") // Rich Text File
+ || magic.StartsWith("" + (char)0xd0 + (char)0xcf + (char)0x11 + (char)0xe0 + (char)0xa1 + (char)0xb1 + (char)0x1a + (char)0xe1)) // Microsoft Office File (old)
+ {
+ try
+ {
+ // Load the current file content
+ string fileContent = null;
+ using (StreamReader sr = new StreamReader(stream))
+ {
+ fileContent = sr.ReadToEnd();
+ }
+
+ // CD-Key
+ if (fileContent.Contains("a valid serial number is required")
+ || fileContent.Contains("serial number is located"))
+ {
+ protections.Add("CD-Key / Serial");
+ }
+ }
+ catch
+ {
+ // We don't care what the error was
+ }
+ }
+
+ #endregion
+
+ #region Archive Content Checks
+
+ // 7-zip
+ if (magic.StartsWith("7z" + (char)0xbc + (char)0xaf + (char)0x27 + (char)0x1c))
+ {
+ // No-op
+ }
+
+ // InstallShield CAB
+ else if (magic.StartsWith("ISc"))
+ {
+ // TODO: Update UnshieldSharp to include generic stream support
+ }
+
+ // Microsoft CAB
+ else if (magic.StartsWith("MSCF"))
+ {
+ // TODO: See if LibMSPackN can use generic streams
+ }
+
+ // PKZIP
+ else if (magic.StartsWith("PK" + (char)03 + (char)04)
+ || magic.StartsWith("PK" + (char)05 + (char)06)
+ || magic.StartsWith("PK" + (char)07 + (char)08))
+ {
+ // No-op
+ }
+
+ // RAR
+ else if (magic.StartsWith("Rar!"))
+ {
+ // No-op
+ }
+
+ #endregion
+
+ // Return blank if nothing found, or comma-separated list of protections
+ if (protections.Count() == 0)
+ return string.Empty;
+ else
+ return string.Join(", ", protections);
+ }
+
+ ///
+ /// Scan the contents of a file for protection
+ ///
+ private static List ScanFileContent(string file, string fileContent)
+ {
+ // Files can be protected in multiple ways
+ List protections = new List();
+ string protection;
+
+ // 3PLock
+ protection = ThreePLock.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // ActiveMARK
+ protection = ActiveMARK.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Alpha-ROM
+ protection = AlphaROM.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Armadillo
+ protection = Armadillo.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // CD-Cops
+ protection = CDCops.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // CD-Lock
+ protection = CDLock.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // CDSHiELD SE
+ protection = CDSHiELDSE.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // CD Check
+ protection = CDCheck.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Cenega ProtectDVD
+ protection = CengaProtectDVD.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Code Lock
+ protection = CodeLock.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // CopyKiller
+ protection = CopyKiller.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Cucko (EA Custom)
+ protection = Cucko.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // dotFuscator
+ protection = dotFuscator.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // DVD-Cops
+ protection = DVDCops.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // EA CdKey Registration Module
+ protection = EACdKey.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // EXE Stealth
+ protection = EXEStealth.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Games for Windows - Live
+ protection = GFWL.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Impulse Reactor
+ protection = ImpulseReactor.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Inno Setup
+ protection = InnoSetup.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // JoWooD X-Prot
+ protection = JoWooDXProt.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Key-Lock (Dongle)
+ protection = KeyLock.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // LaserLock
+ protection = LaserLock.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // PE Compact
+ protection = PECompact.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // ProtectDisc
+ protection = ProtectDisc.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Ring PROTECH
+ protection = RingPROTECH.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SafeDisc / SafeCast
+ protection = SafeDisc.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SafeLock
+ protection = SafeLock.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SecuROM
+ protection = SecuROM.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SmartE
+ protection = SmartE.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SolidShield
+ protection = SolidShield.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // StarForce
+ protection = StarForce.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // SVK Protector
+ protection = SVKProtector.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Sysiphus / Sysiphus DVD
+ protection = Sysiphus.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // TAGES
+ protection = Tages.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // VOB ProtectCD/DVD
+ protection = VOBProtectCDDVD.CheckContents(file, fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // WTM CD Protect
+ protection = WTMCDProtect.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ // Xtreme-Protector
+ protection = XtremeProtector.CheckContents(fileContent);
+ if (!string.IsNullOrWhiteSpace(protection))
+ protections.Add(protection);
+
+ return protections;
+ }
+
///
/// Scan a disc sector by sector for protection
///
diff --git a/BurnOutSharp/ProtectionType/CDCops.cs b/BurnOutSharp/ProtectionType/CDCops.cs
index d9d7c12e..4d169ebd 100644
--- a/BurnOutSharp/ProtectionType/CDCops.cs
+++ b/BurnOutSharp/ProtectionType/CDCops.cs
@@ -49,6 +49,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/DVDCops.cs b/BurnOutSharp/ProtectionType/DVDCops.cs
index ac028ed1..8c598d9a 100644
--- a/BurnOutSharp/ProtectionType/DVDCops.cs
+++ b/BurnOutSharp/ProtectionType/DVDCops.cs
@@ -15,6 +15,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/InnoSetup.cs b/BurnOutSharp/ProtectionType/InnoSetup.cs
index 07d1e96c..fcff8855 100644
--- a/BurnOutSharp/ProtectionType/InnoSetup.cs
+++ b/BurnOutSharp/ProtectionType/InnoSetup.cs
@@ -17,6 +17,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/JoWooDXProt.cs b/BurnOutSharp/ProtectionType/JoWooDXProt.cs
index 5b820bc9..68ece9ce 100644
--- a/BurnOutSharp/ProtectionType/JoWooDXProt.cs
+++ b/BurnOutSharp/ProtectionType/JoWooDXProt.cs
@@ -27,6 +27,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/LaserLock.cs b/BurnOutSharp/ProtectionType/LaserLock.cs
index bec29a9c..c6a02fac 100644
--- a/BurnOutSharp/ProtectionType/LaserLock.cs
+++ b/BurnOutSharp/ProtectionType/LaserLock.cs
@@ -28,7 +28,7 @@ namespace BurnOutSharp.ProtectionType
return "LaserLock " + GetVersion(fileContent, --position) + " " + GetBuild(fileContent, false);
}
- if (Path.GetFileName(file) == "NOMOUSE.SP")
+ if (file != null && Path.GetFileName(file) == "NOMOUSE.SP")
return "LaserLock " + GetVersion16Bit(file);
if (fileContent.Contains(":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP"))
diff --git a/BurnOutSharp/ProtectionType/ProtectDisc.cs b/BurnOutSharp/ProtectionType/ProtectDisc.cs
index f2633ee3..9461e78c 100644
--- a/BurnOutSharp/ProtectionType/ProtectDisc.cs
+++ b/BurnOutSharp/ProtectionType/ProtectDisc.cs
@@ -41,6 +41,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersionBuild6till8(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
@@ -89,6 +92,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersionBuild76till10(string file, int position, out int irefBuild)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/SafeDisc.cs b/BurnOutSharp/ProtectionType/SafeDisc.cs
index 2331b8d5..674d385a 100644
--- a/BurnOutSharp/ProtectionType/SafeDisc.cs
+++ b/BurnOutSharp/ProtectionType/SafeDisc.cs
@@ -97,6 +97,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetDPlayerXVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
FileInfo fi = new FileInfo(file);
if (fi.Length == 81408)
return "SafeDisc 1.0x";
@@ -122,6 +125,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetDrvmgtVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
FileInfo fi = new FileInfo(file);
if (fi.Length == 34816)
return "SafeDisc 1.0x";
@@ -147,6 +153,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetSecdrvVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
FileInfo fi = new FileInfo(file);
if (fi.Length == 20128)
return "SafeDisc 2.10";
@@ -178,6 +187,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/SecuROM.cs b/BurnOutSharp/ProtectionType/SecuROM.cs
index 327e17eb..f2cc994b 100644
--- a/BurnOutSharp/ProtectionType/SecuROM.cs
+++ b/BurnOutSharp/ProtectionType/SecuROM.cs
@@ -80,6 +80,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetV4Version(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
@@ -103,6 +106,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetV5Version(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
@@ -129,6 +135,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetV7Version(string file)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/SolidShield.cs b/BurnOutSharp/ProtectionType/SolidShield.cs
index cb9bb338..3548b90c 100644
--- a/BurnOutSharp/ProtectionType/SolidShield.cs
+++ b/BurnOutSharp/ProtectionType/SolidShield.cs
@@ -27,7 +27,10 @@ namespace BurnOutSharp.ProtectionType
+ "a" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00
+ "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y"))
{
- string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
+ string companyName = string.Empty;
+ if (file != null)
+ companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
+
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
return "SolidShield Core.dll " + Utilities.GetFileVersion(file);
}
@@ -47,7 +50,10 @@ namespace BurnOutSharp.ProtectionType
+ "a" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00
+ "M" + (char)0x00 + "a" + (char)0x00 + "n" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "r"))
{
- string companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
+ string companyName = string.Empty;
+ if (file != null)
+ companyName = FileVersionInfo.GetVersionInfo(file).CompanyName.ToLower();
+
if (companyName.Contains("solidshield") || companyName.Contains("tages"))
return "SolidShield Activation Manager Module " + Utilities.GetFileVersion(file);
}
@@ -125,6 +131,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/Sysiphus.cs b/BurnOutSharp/ProtectionType/Sysiphus.cs
index 2fc5ad54..370c91d9 100644
--- a/BurnOutSharp/ProtectionType/Sysiphus.cs
+++ b/BurnOutSharp/ProtectionType/Sysiphus.cs
@@ -18,6 +18,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/Tages.cs b/BurnOutSharp/ProtectionType/Tages.cs
index 06574356..e708630d 100644
--- a/BurnOutSharp/ProtectionType/Tages.cs
+++ b/BurnOutSharp/ProtectionType/Tages.cs
@@ -80,6 +80,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs
index b15522fb..f4fd2e4c 100644
--- a/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs
+++ b/BurnOutSharp/ProtectionType/VOBProtectCDDVD.cs
@@ -58,6 +58,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetBuild(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
@@ -73,6 +76,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetOldVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
@@ -92,6 +98,9 @@ namespace BurnOutSharp.ProtectionType
private static string GetVersion(string file, int position)
{
+ if (file == null)
+ return string.Empty;
+
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
diff --git a/BurnOutSharp/Utilities.cs b/BurnOutSharp/Utilities.cs
index 5756171a..341ed0ba 100644
--- a/BurnOutSharp/Utilities.cs
+++ b/BurnOutSharp/Utilities.cs
@@ -14,6 +14,9 @@ namespace BurnOutSharp
///
public static string GetFileVersion(string file)
{
+ if (file == null)
+ return string.Empty;
+
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file);
if (fvinfo.FileVersion == null)
return "";