Compare commits

..

39 Commits

Author SHA1 Message Date
Matt Nadareski
99f4909e9b Missing or moved files shouldn't cause an issue (#5) 2019-10-25 23:25:30 -04:00
Matt Nadareski
482644af85 Fix Memory Issues (#4)
* Fix a couple of protection scans (possible mem issues)

* Don't open the file contents on path scan for antimodchip

* IS-CAB intermediate filtering to reduce scan times

* Update NuGet version
2019-10-24 16:09:43 -04:00
Matt Nadareski
45661f3ccd Merge pull request #2 from mnadareski/reorg
Reorganization and Update
2019-09-30 20:39:49 -07:00
Matt Nadareski
c7a9485bf3 Update all 2019-09-30 20:08:12 -07:00
Matt Nadareski
9422ba01e7 Remove backups 2019-09-30 12:17:15 -07:00
Matt Nadareski
b8bbc0b333 Update packages 2019-09-30 12:10:32 -07:00
Matt Nadareski
44922a1f6b Fix encoding issue, add note 2019-09-30 12:09:03 -07:00
Matt Nadareski
cfcb608990 Update all to 4.7.2 2019-09-30 11:46:53 -07:00
Matt Nadareski
392f9dae0c Fix build 2019-09-30 11:29:38 -07:00
Matt Nadareski
4b1cae2ba2 Filename is no longer expected 2019-09-30 11:08:44 -07:00
Matt Nadareski
fd866465b4 Fix test program output 2019-09-29 12:08:31 -07:00
Matt Nadareski
5ffaedc024 Keep path scanning on individual files, for now 2019-09-29 11:57:46 -07:00
Matt Nadareski
ca0d695470 Else-If causes some issues 2019-09-28 01:51:06 -07:00
Matt Nadareski
c109aceb24 Update nuspec 2019-09-28 00:05:44 -07:00
Matt Nadareski
2938033fa6 Remove unused class 2019-09-28 00:01:22 -07:00
Matt Nadareski
5a2755d7c7 Consistent comments 2019-09-27 23:57:32 -07:00
Matt Nadareski
550086791b Separate protections into their own classes 2019-09-27 23:52:24 -07:00
Matt Nadareski
9e4836826d Fix "FileProtection" callback, add InnoSetup
The InnoSetup placeholder here will eventually be a way to call to an external library to extract the contents of the installer, similar to how CAB files are handled right now. The code to o so need sto be converted before that can happen, so in the meantime, this adds Inno Steup itself as a "protection" since other protections could be hidden within.
2018-07-22 23:48:44 -07:00
Matt Nadareski
e0d0722e2b Update csproj 2018-07-22 23:47:08 -07:00
Matt Nadareski
b4c5b220ef Progress => FileProtection
This also implements a sample usage in the Test program
2018-07-22 23:46:49 -07:00
Matt Nadareski
413652f92a Add AppVeyor badge 2018-07-19 14:42:18 -07:00
Matt Nadareski
0cf2b0f6d2 Better cabinet handling, update version 2018-07-19 10:12:38 -07:00
Matt Nadareski
a3094ef471 Add antimod detection (2/3) 2018-07-18 12:06:25 -07:00
Matt Nadareski
055fcbbde7 Update to 1.3.8 2018-07-18 10:57:33 -07:00
Matt Nadareski
a2e00e3945 Better progress indicator 2018-07-18 10:38:41 -07:00
Matt Nadareski
7338640635 Add optional progress indicator callback 2018-07-18 10:11:49 -07:00
Matt Nadareski
99d4adee75 Update version 2018-07-17 10:25:41 -07:00
Matt Nadareski
3356854215 Public documentation 2018-07-16 17:28:47 -07:00
Matt Nadareski
0d04a1b20e Files are valid too 2018-07-16 17:25:36 -07:00
Matt Nadareski
8723639ebc Add simple program for functionality testing 2018-07-16 17:10:45 -07:00
Matt Nadareski
e4df323266 EVORE should not be public 2018-07-16 17:06:16 -07:00
Matt Nadareski
43990dfddb Update README.md 2018-07-16 16:47:52 -07:00
Matt Nadareski
dad04915d4 Fixes for SolidShield and TAGES 2018-07-16 16:27:21 -07:00
Matt Nadareski
959a8d4dc2 CopyKiller check is in error 2018-07-16 14:44:35 -07:00
Matt Nadareski
d6d223946f Add list of known-missing protections 2018-07-16 14:38:17 -07:00
Matt Nadareski
426bc94725 Add nuspec 2018-07-16 02:27:52 -07:00
Matt Nadareski
9728bff8c8 Use the NuGet package 2018-07-16 02:16:55 -07:00
Matt Nadareski
afe72d4083 Add UnshieldSharp as a submodule 2018-07-16 00:58:28 -07:00
Matt Nadareski
d266c7dd20 Initial commit forked from DICUI
This will rely on UnshieldSharp, so it is not currently buildable
2018-07-16 00:45:29 -07:00
92 changed files with 4934 additions and 1 deletions

63
.gitattributes vendored Normal file
View File

@@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

36
BurnOutSharp.sln Normal file
View File

@@ -0,0 +1,36 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# 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
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1DA4212E-6071-4951-B45D-BB74A7838246}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1DA4212E-6071-4951-B45D-BB74A7838246}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1DA4212E-6071-4951-B45D-BB74A7838246}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1DA4212E-6071-4951-B45D-BB74A7838246}.Release|Any CPU.Build.0 = Release|Any CPU
{88735BA2-778D-4192-8EB2-FFF6843719E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88735BA2-778D-4192-8EB2-FFF6843719E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88735BA2-778D-4192-8EB2-FFF6843719E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88735BA2-778D-4192-8EB2-FFF6843719E2}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0B343DD2-8852-47B0-9647-DFCFBEDF933C}
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net462;net472;netcoreapp3.0</TargetFrameworks>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<None Include="BurnOutSharp.nuspec" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="LessIO">
<Version>0.6.16</Version>
</PackageReference>
<PackageReference Include="libmspack4n">
<Version>0.9.10</Version>
</PackageReference>
<PackageReference Include="UnshieldSharp">
<Version>1.4.2.3</Version>
</PackageReference>
<PackageReference Include="zlib.net">
<Version>1.0.4</Version>
</PackageReference>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<package >
<metadata>
<id>BurnOutSharp</id>
<version>1.03.8.2</version>
<title>BurnOutSharp</title>
<authors>Matt Nadareski, Gernot Knippen</authors>
<owners>Matt Nadareski, Gernot Knippen</owners>
<licenseUrl>https://www.gnu.org/licenses/gpl-3.0.txt</licenseUrl>
<projectUrl>https://github.com/mnadareski/BurnOutSharp</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>Port of BurnOut to C#, with additions</description>
<copyright>Copyright (c)2005-2010 Gernot Knippen, Copyright (c)2018-2019 Matt Nadareski</copyright>
<tags>protection scan burnout</tags>
<dependencies>
<dependency id="LessIO" version="0.5.0" />
<dependency id="libmspack4n" version="0.8.0" />
<dependency id="UnshieldSharp" version="1.4.2.3" />
</dependencies>
</metadata>
<files>
<file src="bin\Debug\net462\BurnOutSharp.dll" target="lib\net462\BurnOutSharp.dll" />
<file src="bin\Debug\net462\BurnOutSharp.pdb" target="lib\net462\BurnOutSharp.pdb" />
<file src="bin\Debug\net472\BurnOutSharp.dll" target="lib\net472\BurnOutSharp.dll" />
<file src="bin\Debug\net472\BurnOutSharp.pdb" target="lib\net472\BurnOutSharp.pdb" />
<file src="bin\Debug\netcoreapp3.0\BurnOutSharp.dll" target="lib\netcoreapp3.0\BurnOutSharp.dll" />
<file src="bin\Debug\netcoreapp3.0\BurnOutSharp.pdb" target="lib\netcoreapp3.0\BurnOutSharp.pdb" />
</files>
</package>

446
BurnOutSharp/EVORE.cs Normal file
View File

@@ -0,0 +1,446 @@
//this file is part of BurnOut
//Copyright (C)2005-2010 Gernot Knippen
//Ported code with augments Copyright (C)2018 Matt Nadareski
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You can get a copy of the GNU General Public License
//by writing to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Threading;
namespace BurnOutSharp
{
internal static class EVORE
{
private struct Section
{
public uint iVirtualSize;
public uint iVirtualOffset;
public uint iRawOffset;
}
private const int WaitSeconds = 20;
private static Process StartSafe(string file)
{
if (file == null || !File.Exists(file))
return null;
Process startingprocess = new Process();
startingprocess.StartInfo.FileName = file;
startingprocess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
startingprocess.StartInfo.CreateNoWindow = true;
startingprocess.StartInfo.ErrorDialog = false;
try
{
startingprocess.Start();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return null;
}
return startingprocess;
}
private static string MakeTempFile(string file, string sExtension = ".exe")
{
if (file == null || !File.Exists(file))
return string.Empty;
FileInfo filei = new FileInfo(file);
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "tmp", filei.Name + "*" + sExtension));
}
catch { }
filei = filei.CopyTo(Path.GetTempPath() + "tmp" + filei.Name + Directory.GetFiles(Path.GetTempPath(), "tmp" + filei.Name + "*" + sExtension).Length + sExtension, true);
filei.Attributes = FileAttributes.Temporary | FileAttributes.NotContentIndexed;
return filei.FullName;
}
private static bool IsEXE(string file)
{
if (file == null || !File.Exists(file))
return false;
BinaryReader breader = new BinaryReader(File.OpenRead(file));
breader.ReadBytes(60);
int PEHeaderOffset = breader.ReadInt32();
breader.BaseStream.Seek(PEHeaderOffset, SeekOrigin.Begin);
breader.ReadBytes(22);
short Characteristics = breader.ReadInt16();
breader.Close();
//check if file is dll
if ((Characteristics & 0x2000) == 0x2000)
return false;
else
return true;
}
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);
long lastPosition;
string[] saDependentDLLs = null;
breader.ReadBytes(60);
int PEHeaderOffset = breader.ReadInt32();
breader.BaseStream.Seek(PEHeaderOffset + 120 + 8, SeekOrigin.Begin); //120 Bytes till IMAGE_DATA_DIRECTORY array,8 Bytes=size of IMAGE_DATA_DIRECTORY
uint ImportTableRVA = breader.ReadUInt32();
uint ImportTableSize = breader.ReadUInt32();
breader.BaseStream.Seek(RVA2Offset(ImportTableRVA, sections), SeekOrigin.Begin);
breader.BaseStream.Seek(12, SeekOrigin.Current);
uint DllNameRVA = breader.ReadUInt32();
while (DllNameRVA != 0)
{
string sDllName = "";
byte bChar;
lastPosition = breader.BaseStream.Position;
uint DLLNameOffset = RVA2Offset(DllNameRVA, sections);
if (DLLNameOffset > 0)
{
breader.BaseStream.Seek(DLLNameOffset, SeekOrigin.Begin);
if (breader.PeekChar() > -1)
{
do
{
bChar = breader.ReadByte();
sDllName += (char)bChar;
} while (bChar != 0 && breader.PeekChar() > -1);
sDllName = sDllName.Remove(sDllName.Length - 1, 1);
if (File.Exists(Path.Combine(fiExe.DirectoryName, sDllName)))
{
if (saDependentDLLs == null)
saDependentDLLs = new string[0];
else
saDependentDLLs = new string[saDependentDLLs.Length];
FileInfo fiDLL = new FileInfo(Path.Combine(fiExe.DirectoryName, sDllName));
saDependentDLLs[saDependentDLLs.Length - 1] = fiDLL.CopyTo(Path.GetTempPath() + sDllName, true).FullName;
}
}
breader.BaseStream.Seek(lastPosition, SeekOrigin.Begin);
}
breader.BaseStream.Seek(4 + 12, SeekOrigin.Current);
DllNameRVA = breader.ReadUInt32();
}
breader.Close();
return saDependentDLLs;
}
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();
breader.BaseStream.Seek(PEHeaderOffset + 6, SeekOrigin.Begin);
ushort NumberOfSections = breader.ReadUInt16();
breader.BaseStream.Seek(PEHeaderOffset + 120 + 16 * 8, SeekOrigin.Begin);
Section[] sections = new Section[NumberOfSections];
for (int i = 0; i < NumberOfSections; i++)
{
breader.BaseStream.Seek(8, SeekOrigin.Current);
uint ivs = breader.ReadUInt32();
uint ivo = breader.ReadUInt32();
breader.BaseStream.Seek(4, SeekOrigin.Current);
uint iro = breader.ReadUInt32();
breader.BaseStream.Seek(16, SeekOrigin.Current);
sections[i] = new Section()
{
iVirtualSize = ivs,
iVirtualOffset = ivo,
iRawOffset = iro,
};
}
breader.Close();
return sections;
}
private static uint RVA2Offset(uint RVA, Section[] sections)
{
int i = 0;
while (i != sections.Length)
{
if (sections[i].iVirtualOffset <= RVA && sections[i].iVirtualOffset + sections[i].iVirtualSize > RVA)
return RVA - sections[i].iVirtualOffset + sections[i].iRawOffset;
i++;
}
return 0;
}
#region "EVORE version-search-functions"
public static string SearchProtectDiscVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
Process exe = new Process();
Process[] processes = new Process[0];
string version = "";
DateTime timestart;
if (!IsEXE(file))
return "";
string tempexe = MakeTempFile(file);
string[] DependentDlls = CopyDependentDlls(file);
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "a*.tmp"));
}
catch { }
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "PCD*.sys"));
}
catch { }
if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc")))
{
try
{
File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc", "p*.dll"));
}
catch { }
}
exe = StartSafe(tempexe);
if (exe == null)
return "";
timestart = DateTime.Now;
do
{
exe.Refresh();
string[] files = null;
//check for ProtectDisc 8.2-x
if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc")))
{
files = Directory.GetFiles(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc"), "p*.dll");
}
if (files != null)
{
if (files.Length > 0)
{
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
if (fvinfo.FileVersion != "")
{
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
//ProtectDisc 9 uses a ProtectDisc-Core dll version 8.0.x
if (version.StartsWith("8.0"))
version = "";
fvinfo = null;
break;
}
}
}
//check for ProtectDisc 7.1-8.1
files = Directory.GetFiles(Path.GetTempPath(), "a*.tmp");
if (files.Length > 0)
{
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(files[0]);
if (fvinfo.FileVersion != "")
{
version = fvinfo.FileVersion.Replace(" ", "").Replace(",", ".");
fvinfo = null;
break;
}
}
if (exe.HasExited)
break;
processes = Process.GetProcessesByName(exe.ProcessName);
if (processes.Length == 2)
{
processes[0].Refresh();
processes[1].Refresh();
if (processes[1].WorkingSet64 > exe.WorkingSet64)
exe = processes[1];
else if (processes[0].WorkingSet64 > exe.WorkingSet64) //else if (processes[0].Modules.Count > exe.Modules.Count)
exe = processes[0];
}
} while (processes.Length > 0 && DateTime.Now.Subtract(timestart).TotalSeconds < WaitSeconds);
Thread.Sleep(500);
if (!exe.HasExited)
{
processes = Process.GetProcessesByName(exe.ProcessName);
if (processes.Length == 2)
{
try
{
processes[0].Kill();
}
catch { }
processes[0].Close();
try
{
processes[1].Kill();
}
catch { }
}
else
{
exe.Refresh();
try
{
exe.Kill();
}
catch { }
}
}
exe.Close();
Thread.Sleep(500);
if (Directory.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc")))
{
try
{
File.Delete(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "ProtectDisc", "p*.dll"));
}
catch { }
}
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "a*.tmp"));
}
catch { }
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "PCD*.sys"));
}
catch { }
File.Delete(tempexe);
if (DependentDlls != null)
{
for (int i = 0; i < DependentDlls.Length; i++)
{
try
{
File.Delete(DependentDlls[i]);
}
catch (Exception ex)
{
Console.WriteLine("!error while deleting file " + DependentDlls[i] + "; " + ex.Message);
}
}
}
return version;
}
public static string SearchSafeDiscVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
Process exe = new Process();
string version = "";
DateTime timestart;
if (!IsEXE(file))
return "";
string tempexe = MakeTempFile(file);
string[] DependentDlls = CopyDependentDlls(file);
try
{
Directory.Delete(Path.Combine(Path.GetTempPath(), "~e*"), true);
}
catch { }
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "~e*"));
}
catch { }
exe = StartSafe(tempexe);
if (exe == null)
return "";
timestart = DateTime.Now;
do
{
if (Directory.GetDirectories(Path.GetTempPath(), "~e*").Length > 0)
{
string[] files = Directory.GetFiles(Directory.GetDirectories(Path.GetTempPath(), "~e*")[0], "~de*.tmp");
if (files.Length > 0)
{
StreamReader sr;
try
{
sr = new StreamReader(files[0], Encoding.Default);
string FileContent = sr.ReadToEnd();
sr.Close();
int position = FileContent.IndexOf("%ld.%ld.%ld, %ld, %s,") - 1;
if (position > -1)
version = FileContent.Substring(position + 28, 12);
break;
}
catch { }
}
}
} while (!exe.HasExited && DateTime.Now.Subtract(timestart).TotalSeconds < WaitSeconds);
if (!exe.HasExited)
exe.Kill();
exe.Close();
try
{
Directory.Delete(Path.Combine(Path.GetTempPath(), "~e*"), true);
}
catch { }
try
{
File.Delete(Path.Combine(Path.GetTempPath(), "~e*"));
}
catch { }
File.Delete(tempexe);
if (DependentDlls != null)
{
for (int i = 0; i < DependentDlls.Length; i--)
{
try
{
File.Delete(DependentDlls[i]);
}
catch (Exception ex)
{
Console.WriteLine("!error while deleting file " + DependentDlls[i] + "; " + ex.Message);
}
}
}
return version;
}
#endregion
}
}

View File

@@ -0,0 +1,16 @@
namespace BurnOutSharp
{
public class FileProtection
{
public string Filename { get; private set; }
public float Percentage { get; private set; }
public string Protection { get; private set; }
public FileProtection(string filename, float percentage, string protection)
{
this.Filename = filename;
this.Percentage = percentage;
this.Protection = protection;
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BurnOutSharp")]
[assembly: AssemblyDescription("Port of BurnOut to C#, with additions")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Matt Nadareski, Gernot Knippen")]
[assembly: AssemblyProduct("BurnOutSharp")]
[assembly: AssemblyCopyright("Copyright (c)2005-2010 Gernot Knippen, Copyright (c)2018 Matt Nadareski")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("1da4212e-6071-4951-b45d-bb74a7838246")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.03.7.1")]
[assembly: AssemblyFileVersion("1.03.7.1")]

View File

@@ -0,0 +1,920 @@
//this file is part of BurnOut
//Copyright (C)2005-2010 Gernot Knippen
//Ported code with augments Copyright (C)2018 Matt Nadareski
//
//This program is free software; you can redistribute it and/or
//modify it under the terms of the GNU General Public License
//as published by the Free Software Foundation; either
//version 2 of the License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You can get a copy of the GNU General Public License
//by writing to the Free Software
//Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
using System;
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;
using UnshieldSharp;
namespace BurnOutSharp
{
public static class ProtectionFind
{
/// <summary>
/// Scan a path to find any known copy protection(s)
/// </summary>
/// <param name="path">Path to scan for protection(s)</param>
/// <param name="progress">Optional progress indicator that will return a float in the range from 0 to 1</param>
/// <returns>Dictionary of filename to protection mappings, if possible</returns>
public static Dictionary<string, string> Scan(string path, IProgress<FileProtection> progress = null)
{
var protections = new Dictionary<string, string>();
// Checkpoint
progress?.Report(new FileProtection(null, 0, null));
// If we have a file
if (File.Exists(path))
{
// Try using just the file first to get protection info
string fileProtection = ScanPath(path, false);
if (!string.IsNullOrWhiteSpace(fileProtection))
protections[path] = fileProtection;
// Now check to see if the file contains any additional information
string contentProtection = ScanInFile(path)?.Replace("" + (char)0x00, "");
if (!string.IsNullOrWhiteSpace(contentProtection))
{
if (protections.ContainsKey(path))
protections[path] += $", {contentProtection}";
else
protections[path] = contentProtection;
}
// Checkpoint
progress?.Report(new FileProtection(path, 1, contentProtection));
}
// If we have a directory
else if (Directory.Exists(path))
{
// Get the lists of files to be used
var files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
// Try using just the path first to get protection info
string pathProtection = ScanPath(path, true);
if (!string.IsNullOrWhiteSpace(pathProtection))
protections[path] = pathProtection;
// Loop through all files and scan their contents
for (int i = 0; i < files.Count(); i++)
{
// Get the current file
string file = files.ElementAt(i);
// Try using just the file first to get protection info
string fileProtection = ScanPath(file, false);
if (!string.IsNullOrWhiteSpace(fileProtection))
protections[file] = fileProtection;
// Now check to see if the file contains any additional information
string contentProtection = ScanInFile(file)?.Replace("" + (char)0x00, "");
if (!string.IsNullOrWhiteSpace(contentProtection))
{
if (protections.ContainsKey(file))
protections[file] += $", {contentProtection}";
else
protections[file] = contentProtection;
}
// Checkpoint
progress?.Report(new FileProtection(file, i / (float)files.Count(), contentProtection));
}
}
// If we have an empty list, we need to take care of that
if (protections.Count(p => !string.IsNullOrWhiteSpace(p.Value)) == 0)
{
protections = new Dictionary<string, string>();
}
return protections;
}
/// <summary>
/// Scan a path for indications of copy protection
/// </summary>
/// <param name="path"></param>
/// <param name="isDirectory"></param>
/// <returns></returns>
public static string ScanPath(string path, bool isDirectory)
{
List<string> protections = new List<string>();
string protection;
// If we have a directory, get the files in the directory for searching
IEnumerable<string> files = null;
if (isDirectory)
files = Directory.EnumerateFiles(path, "*", SearchOption.AllDirectories);
// AACS
protection = AACS.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Alpha-DVD
protection = AlphaDVD.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Bitpool
protection = Bitpool.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// ByteShield
protection = ByteShield.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Cactus Data Shield
protection = CactusDataShield.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// CD-Cops
protection = CDCops.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// CD-Lock
protection = CDLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// CD-Protector
protection = CDProtector.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// CD-X
protection = CDX.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
/*
// CopyKiller
protection = CopyKiller.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
*/
// DiscGuard
protection = DiscGuard.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// DVD Crypt
protection = DVDCrypt.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// DVD-Movie-PROTECT
protection = DVDMoviePROTECT.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// FreeLock
protection = FreeLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Games for Windows - Live
protection = GFWL.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Hexalock AutoLock
protection = HexalockAutoLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Impulse Reactor
protection = ImpulseReactor.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// IndyVCD
protection = IndyVCD.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Key2Audio XS
protection = Key2AudioXS.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// LaserLock
protection = LaserLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// MediaCloQ
protection = MediaCloQ.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// MediaMax CD3
protection = MediaMaxCD3.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Origin
protection = Origin.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Protect DVD-Video
protection = ProtectDVDVideo.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// PSX Anti-modchip
protection = PSXAntiModchip.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SafeCast
protection = SafeCast.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SafeDisc
protection = SafeDisc.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SafeDisc Lite
protection = SafeDiscLite.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SafeLock
protection = SafeLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SecuROM
protection = SecuROM.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SmartE
protection = SmartE.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SoftLock
protection = SoftLock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// SolidShield
protection = SolidShield.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// StarForce
protection = StarForce.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Steam
protection = Steam.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// TAGES
protection = Tages.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// TZCopyProtector
protection = TZCopyProtector.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Uplay
protection = Uplay.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// VOB ProtectCD/DVD
protection = VOBProtectCDDVD.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Winlock
protection = Winlock.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// WTM CD Protect
protection = WTMCDProtect.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// XCP
protection = XCP.CheckPath(path, files, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Zzxzz
protection = Zzxzz.CheckPath(path, isDirectory);
if (!string.IsNullOrWhiteSpace(protection))
protections.Add(protection);
// Now combine any found protections, or null if empty
if (protections.Count() == 0)
return null;
else
return string.Join(", ", protections);
}
/// <summary>
/// Scan an individual file for copy protection
/// </summary>
/// <param name="file">File path for scanning</param>
public static string ScanInFile(string file)
{
// Get the extension for certain checks
string extension = Path.GetExtension(file).ToLower().TrimStart('.');
// Read the first 8 bytes to get the file type
string magic = "";
try
{
using (BinaryReader br = new BinaryReader(File.OpenRead(file)))
{
magic = new string(br.ReadChars(8));
}
}
catch
{
// We don't care what the issue was, we can't open the file
return null;
}
// Files can be protected in multiple ways
List<string> protections = new List<string>();
#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(file, Encoding.Default))
{
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)
|| extension == "txt") // Generic textfile (no header)
{
try
{
StreamReader sr = File.OpenText(file);
string FileContent = sr.ReadToEnd().ToLower();
sr.Close();
// 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"))
{
// 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)
{
try
{
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 { }
}
}
// Microsoft CAB
else if (magic.StartsWith("MSCF"))
{
try
{
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);
using (MSCabinet cabfile = new MSCabinet(file))
{
foreach (var sub in cabfile.GetFiles())
{
string tempfile = Path.Combine(tempPath, sub.Filename);
sub.ExtractTo(tempfile);
string protection = ScanInFile(tempfile);
File.Delete(tempfile);
if (!string.IsNullOrEmpty(protection))
protections.Add(protection);
}
try
{
Directory.Delete(tempPath, true);
}
catch { }
}
}
catch { }
}
// 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);
}
/// <summary>
/// Scan an individual stream for copy protection
/// </summary>
/// <param name="stream">Generic stream to scan</param>
/// <param name="file">File path to be used for name checks (optional)</param>
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<string> protections = new List<string>();
#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, Encoding.Default))
{
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);
}
/// <summary>
/// Scan the contents of a file for protection
/// </summary>
/// TODO: This needs to work on a byte array of file content instead of string
private static List<string> ScanFileContent(string file, string fileContent)
{
// Files can be protected in multiple ways
List<string> protections = new List<string>();
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;
}
/// <summary>
/// Scan a disc sector by sector for protection
/// </summary>
/// <remarks>
/// https://stackoverflow.com/questions/8819188/c-sharp-classes-to-undelete-files/8820157#8820157
/// TODO: Finish implementation
/// </remarks>
private static string ScanSectors(char driveLetter, int sectorsize)
{
string fsName = Utilities.GetFileSystemName(driveLetter);
// Gets a handle to the physical disk
IntPtr hDisk = Utilities.CreateFile($"\\\\.\\{driveLetter}:",
FileAccess.Read,
FileShare.ReadWrite,
IntPtr.Zero,
FileMode.Open,
0,
IntPtr.Zero);
// If we have a good pointer
if (hDisk.ToInt32() != -1)
{
// Setup vars
byte[] buffer = new byte[sectorsize];
IntPtr pt = IntPtr.Zero;
NativeOverlapped no = new NativeOverlapped();
// Set initial offset
Utilities.SetFilePointerEx(
hDisk,
0,
ref pt,
Utilities.FileBegin);
// Read a whole sector
while (true)
{
buffer = new byte[sectorsize];
Utilities.ReadFileEx(
hDisk,
buffer,
(uint)sectorsize,
ref no,
null);
Utilities.SetFilePointerEx(
hDisk,
sectorsize,
ref pt,
Utilities.FileCurrent);
}
}
Utilities.CloseHandle(hDisk);
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class AACS
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => f.Contains(Path.Combine("aacs", "VTKF000.AACS"))) > 0
&& files.Count(f => f.Contains(Path.Combine("AACS", "CPSUnit00001.cci"))) > 0)
{
return "AACS";
}
}
else
{
string filename = Path.GetFileName(path);
if (filename.Equals("VTKF000.AACS", StringComparison.OrdinalIgnoreCase)
|| filename.Equals("CPSUnit00001.cci", StringComparison.OrdinalIgnoreCase))
{
return "AACS";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,20 @@
namespace BurnOutSharp.ProtectionType
{
public class ActiveMARK
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("TMSAMVOF"))
return "ActiveMARK";
if (fileContent.Contains(" " + (char)0xC2 + (char)0x16 + (char)0x00 + (char)0xA8 + (char)0xC1 + (char)0x16
+ (char)0x00 + (char)0xB8 + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x86 + (char)0xC8 + (char)0x16 + (char)0x0
+ (char)0x9A + (char)0xC1 + (char)0x16 + (char)0x00 + (char)0x10 + (char)0xC2 + (char)0x16 + (char)0x00))
{
return "ActiveMARK 5";
}
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class Alcatraz
{
// TODO: Implement - http://www.kdg-mt.com/1/product_d_6.html
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class AlphaAudio
{
// TODO: Implement - http://settec.net/eng/pro_cd.html
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class AlphaDVD
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase)) > 0)
return "Alpha-DVD";
}
else
{
if (Path.GetFileName(path).Equals("PlayDVD.exe", StringComparison.OrdinalIgnoreCase))
return "Alpha-DVD";
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class AlphaROM
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("SETTEC"))
return "Alpha-ROM";
return null;
}
}
}

View File

@@ -0,0 +1,14 @@
namespace BurnOutSharp.ProtectionType
{
public class Armadillo
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains(".nicode" + (char)0x00)
|| fileContent.Contains("ARMDEBUG"))
return "Armadillo";
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Bitpool
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase)) > 0)
return "Bitpool";
}
else
{
if (Path.GetFileName(path).Equals("bitpool.rsc", StringComparison.OrdinalIgnoreCase))
return "Bitpool";
}
return null;
}
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class ByteShield
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetExtension(f).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "ByteShield";
}
}
else
{
if (Path.GetFileName(path).Equals("Byteshield.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("bbz", StringComparison.OrdinalIgnoreCase))
{
return "ByteShield";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,14 @@
namespace BurnOutSharp.ProtectionType
{
public class CDCheck
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("GetDriveType")
|| fileContent.Contains("GetVolumeInformation"))
return "CD Check";
return null;
}
}
}

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class CDCops
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("CD-Cops, ver. ")) > -1)
return "CD-Cops " + GetVersion(file, position);
if (fileContent.Contains(".grand" + (char)0x00))
return "CD-Cops";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)) > 0
&& (files.Count(f => Path.GetExtension(f).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetExtension(f).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetExtension(f).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetExtension(f).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase)) > 0))
{
return "CD-Cops";
}
}
else
{
if (Path.GetFileName(path).Equals("CDCOPS.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("GZ_", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("W_X", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("Qz", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("QZ_", StringComparison.OrdinalIgnoreCase))
{
return "CD-Cops";
}
}
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 15, SeekOrigin.Begin); // Begin reading after "CD-Cops, ver."
char[] version = br.ReadChars(4);
if (version[0] == 0x00)
return "";
return new string(version);
}
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class CDLock
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("2" + (char)0xF2 + (char)0x02 + (char)0x82 + (char)0xC3 + (char)0xBC + (char)0x0B
+ "$" + (char)0x99 + (char)0xAD + "'C" + (char)0xE4 + (char)0x9D + "st"
+ (char)0x99 + (char)0xFA + "2$" + (char)0x9D + ")4" + (char)0xFF + "t"))
{
return "CD-Lock";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetExtension(f).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase)) > 0)
return "CD-Lock";
}
else
{
if (Path.GetExtension(path).Trim('.').Equals("AFP", StringComparison.OrdinalIgnoreCase))
return "CD-Lock";
}
return null;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class CDProtector
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "CD-Protector";
}
}
else
{
if (Path.GetFileName(path).Equals("_cdp16.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("_cdp16.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("_cdp32.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("_cdp32.dll", StringComparison.OrdinalIgnoreCase))
{
return "CD-Protector";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class CDSHiELDSE
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("~0017.tmp"))
return "CDSHiELD SE";
return null;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class CDX
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "CD-X";
}
}
else
{
if (Path.GetFileName(path).Equals("CHKCDX16.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CHKCDX32.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CHKCDXNT.DLL", StringComparison.OrdinalIgnoreCase))
{
return "CD-X";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace BurnOutSharp.ProtectionType
{
public class CactusDataShield
{
public static string CheckContents(string file)
{
if (Path.GetFileName(file) == "CDSPlayer.app")
{
using (var sr = new StreamReader(file, Encoding.Default))
{
return "Cactus Data Shield " + sr.ReadLine().Substring(3) + "(" + sr.ReadLine() + ")";
}
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase)) > 0)
{
string file = files.First(f => Path.GetFileName(f).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase));
string protection = CheckContents(file);
if (!string.IsNullOrWhiteSpace(protection))
return protection;
}
else if (files.Count(f => Path.GetFileName(f).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "Cactus Data Shield 200";
}
}
else
{
if (Path.GetFileName(path).Equals("CDSPlayer.app", StringComparison.OrdinalIgnoreCase))
{
string protection = CheckContents(path);
if (!string.IsNullOrWhiteSpace(protection))
return protection;
}
else if (Path.GetFileName(path).Equals("yucca.cds", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("wmmp.exe", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("PJSTREAM.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CACTUSPJ.exe", StringComparison.OrdinalIgnoreCase))
{
return "Cactus Data Shield 200";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class CengaProtectDVD
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains(".cenega"))
return "Cenega ProtectDVD";
return null;
}
}
}

View File

@@ -0,0 +1,18 @@
namespace BurnOutSharp.ProtectionType
{
public class CodeLock
{
public static string CheckContents(string fileContent)
{
// TODO: Verify if these are OR or AND
if (fileContent.Contains("icd1" + (char)0x00)
|| fileContent.Contains("icd2" + (char)0x00)
|| fileContent.Contains("CODE-LOCK.OCX"))
{
return "Code Lock";
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class CopyKiller
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("Tom Commander"))
return "CopyKiller";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase)) > 0)
return "CopyKiller";
}
else
{
if (Path.GetFileName(path).Equals("Autorun.dat", StringComparison.OrdinalIgnoreCase))
return "CopyKiller";
}
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class CopyLok
{
// TODO: Implement - http://web.archive.org/web/20041215075727/http://www.panlok.com/codelok2.htm
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class CrypKey
{
// TODO: Implement - http://www.crypkey.com/products/cdlock/cdmain.html
}
}

View File

@@ -0,0 +1,14 @@
namespace BurnOutSharp.ProtectionType
{
public class Cucko
{
public static string CheckContents(string fileContent)
{
// TODO: Verify this doesn't over-match
if (fileContent.Contains("EASTL"))
return "Cucko (EA Custom)";
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class DBB
{
// TODO: Implement - http://web.archive.org/web/20040604233815/www.wkit.com/sites/wkit/setup/eng/index.asp
}
}

View File

@@ -0,0 +1,33 @@
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class DVDCops
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("DVD-Cops, ver. ")) > -1)
return "DVD-Cops " + GetVersion(file, position);
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 15, SeekOrigin.Begin); // Begin reading after "CD-Cops, ver."
char[] version = br.ReadChars(4);
if (version[0] == 0x00)
return "";
return new string(version);
}
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class DVDCrypt
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase)) > 0)
return "DVD Crypt";
}
else
{
if (Path.GetFileName(path).Equals("DvdCrypt.pdb", StringComparison.OrdinalIgnoreCase))
return "DVD Crypt";
}
return null;
}
}
}

View File

@@ -0,0 +1,29 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class DVDMoviePROTECT
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (!isDirectory)
return null;
if (Directory.Exists(Path.Combine(path, "VIDEO_TS")))
{
string[] bupfiles = files.Where(s => s.EndsWith(".bup")).ToArray();
for (int i = 0; i < bupfiles.Length; i++)
{
FileInfo bupfile = new FileInfo(bupfiles[i]);
FileInfo ifofile = new FileInfo(bupfile.DirectoryName + "\\" + bupfile.Name.Substring(0, bupfile.Name.Length - bupfile.Extension.Length) + ".ifo");
if (bupfile.Length != ifofile.Length)
return "DVD-Movie-PROTECT"; ;
}
}
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class DiscGuard
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)) > 0
&& files.Count(f => Path.GetFileName(f).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "DiscGuard";
}
}
else
{
if (Path.GetFileName(path).Equals("IOSLINK.VXD", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("IOSLINK.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("IOSLINK.SYS", StringComparison.OrdinalIgnoreCase))
{
return "DiscGuard";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class EACdKey
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("ereg.ea-europe.com"))
return "EA CdKey Registration Module";
return null;
}
}
}

View File

@@ -0,0 +1,17 @@
namespace BurnOutSharp.ProtectionType
{
public class EXEStealth
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("??[[__[[_" + (char)0x00 + "{{" + (char)0x0
+ (char)0x00 + "{{" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x0
+ (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "?;??;??"))
{
return "EXE Stealth";
}
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class FADE
{
// TODO: Implement - http://www.codemasters.com/news/displayarticles.php?showarticle=500
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class FreeLock
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase)) > 0)
return "FreeLock";
}
else
{
if (Path.GetFileName(path).Equals("FREELOCK.IMG", StringComparison.OrdinalIgnoreCase))
return "FreeLock";
}
return null;
}
}
}

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class GFWL
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("xlive.dll"))
return "Games for Windows - Live";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase)) > 0)
return "Games for Windows - Live";
}
else
{
if (Path.GetFileName(path).Equals("XLiveRedist.msi", StringComparison.OrdinalIgnoreCase))
return "Games for Windows - Live";
}
return null;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class HexalockAutoLock
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "Hexalock AutoLock";
}
}
else
{
if (Path.GetFileName(path).Equals("Start_Here.exe", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("HCPSMng.exe", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("MFINT.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("MFIMP.DLL", StringComparison.OrdinalIgnoreCase))
{
return "Hexalock AutoLock";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class ImpulseReactor
{
public static string CheckContents(string file, string fileContent)
{
if (fileContent.Contains("CVPInitializeClient"))
{
if (fileContent.Contains("A" + (char)0x00 + "T" + (char)0x00 + "T" + (char)0x00 + "L" + (char)0x00 + "I"
+ (char)0x00 + "S" + (char)0x00 + "T" + (char)0x00 + (char)0x00 + (char)0x00 + "E" + (char)0x00 + "L"
+ (char)0x00 + "E" + (char)0x00 + "M" + (char)0x00 + "E" + (char)0x00 + "N" + (char)0x00 + "T" + (char)0x00
+ (char)0x00 + (char)0x00 + "N" + (char)0x00 + "O" + (char)0x00 + "T" + (char)0x00 + "A" + (char)0x00 + "T"
+ (char)0x00 + "I" + (char)0x00 + "O" + (char)0x00 + "N"))
{
return "Impulse Reactor " + Utilities.GetFileVersion(file);
}
else
{
return "Impulse Reactor";
}
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)) > 0)
return "Impulse Reactor " + Utilities.GetFileVersion(files.First(f => Path.GetFileName(f).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase)));
}
else
{
if (Path.GetFileName(path).Equals("ImpulseReactor.dll", StringComparison.OrdinalIgnoreCase))
return "Impulse Reactor " + Utilities.GetFileVersion(path);
}
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class IndyVCD
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "IndyVCD";
}
}
else
{
if (Path.GetFileName(path).Equals("INDYVCD.AX", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("INDYMP3.idt", StringComparison.OrdinalIgnoreCase))
{
return "IndyVCD";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,48 @@
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class InnoSetup
{
public static string CheckContents(string file, string fileContent)
{
if (fileContent.IndexOf("Inno") == 0x30)
{
// TOOO: Add Inno Setup extraction
return "Inno Setup " + GetVersion(file);
}
return null;
}
private static string GetVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(0x30, SeekOrigin.Begin);
string signature = new string(br.ReadChars(12));
if (signature == "rDlPtS02" + (char)0x87 + "eVx")
return "1.2.10";
else if (signature == "rDlPtS04" + (char)0x87 + "eVx")
return "4.0.0";
else if (signature == "rDlPtS05" + (char)0x87 + "eVx")
return "4.0.3";
else if (signature == "rDlPtS06" + (char)0x87 + "eVx")
return "4.0.10";
else if (signature == "rDlPtS07" + (char)0x87 + "eVx")
return "4.1.6";
else if (signature == "rDlPtS" + (char)0xcd + (char)0xe6 + (char)0xd7 + "{" + (char)0x0b + "*")
return "5.1.5";
else if (signature == "nS5W7dT" + (char)0x83 + (char)0xaa + (char)0x1b + (char)0x0f + "j")
return "5.1.5";
return string.Empty;
}
}
}
}

View File

@@ -0,0 +1,51 @@
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class JoWooDXProt
{
public static string CheckContents(string file, string fileContent)
{
int position;
if (fileContent.Contains(".ext "))
{
if ((position = fileContent.IndexOf("kernel32.dll" + (char)0x00 + (char)0x00 + (char)0x00 + "VirtualProtect")) > -1)
{
return "JoWooD X-Prot " + GetVersion(file, --position);
}
else
{
return "JoWooD X-Prot v1";
}
}
if (fileContent.Contains("@HC09 "))
return "JoWooD X-Prot v2";
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
char[] version = new char[5];
br.BaseStream.Seek(position + 67, SeekOrigin.Begin);
version[0] = br.ReadChar();
br.ReadByte();
version[1] = br.ReadChar();
br.ReadByte();
version[2] = br.ReadChar();
br.ReadByte();
version[3] = br.ReadChar();
version[4] = br.ReadChar();
return version[0] + "." + version[1] + "." + version[2] + "." + version[3] + version[4];
}
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Key2AudioXS
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "Key2Audio XS";
}
}
else
{
if (Path.GetFileName(path).Equals("SDKHM.EXE", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SDKHM.DLL", StringComparison.OrdinalIgnoreCase))
{
return "Key2Audio XS";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class KeyLock
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("KEY-LOCK COMMAND"))
return "Key-Lock (Dongle)";
return null;
}
}
}

View File

@@ -0,0 +1,127 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class LaserLock
{
public static string CheckContents(string file, string fileContent)
{
int position;
if (fileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE")
&& (position = fileContent.IndexOf("GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
+ "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00
+ "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF")) > -1)
{
return "LaserLock " + GetVersion(fileContent, position) + " " + GetBuild(fileContent, true);
}
if (fileContent.Contains("Packed by SPEEnc V2 Asterios Parlamentas.PE"))
return "LaserLock Marathon " + GetBuild(fileContent, false);
if ((position = fileContent.IndexOf("GetModuleHandleA" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00
+ "GetProcAddress" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "LoadLibraryA" + (char)0x00 + (char)0x00
+ "KERNEL32.dll" + (char)0x00 + "ëy" + (char)0x01 + "SNIF")) > -1)
{
return "LaserLock " + GetVersion(fileContent, --position) + " " + GetBuild(fileContent, false);
}
if (file != null && Path.GetFileName(file) == "NOMOUSE.SP")
return "LaserLock " + GetVersion16Bit(file);
if (fileContent.Contains(":\\LASERLOK\\LASERLOK.IN" + (char)0x00 + "C:\\NOMOUSE.SP"))
return "LaserLock 3";
if (fileContent.Contains("LASERLOK_INIT" + (char)0xC + "LASERLOK_RUN" + (char)0xE + "LASERLOK_CHECK"
+ (char)0xF + "LASERLOK_CHECK2" + (char)0xF + "LASERLOK_CHECK3"))
{
return "LaserLock 5";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (Directory.Exists(Path.Combine(path, "LASERLOK")))
{
return "LaserLock";
}
// TODO: Verify if these are OR or AND
else if (files.Count(f => Path.GetFileName(f).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "LaserLock";
}
}
else
{
if (Path.GetFileName(path).Equals("NOMOUSE.SP", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("NOMOUSE.COM", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("l16dll.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("laserlok.in", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("laserlok.o10", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("laserlok.011", StringComparison.OrdinalIgnoreCase))
{
return "LaserLock";
}
}
return null;
}
private static string GetBuild(string fileContent, bool versionTwo)
{
// TODO: Is this supposed to be "Unknown"?
int position = fileContent.IndexOf("Unkown" + (char)0 + "Unkown");
string year, month, day;
if (versionTwo)
{
day = fileContent.Substring(position + 14, 2);
month = fileContent.Substring(position + 14 + 3, 2);
year = "20" + fileContent.Substring(position + 14 + 6, 2);
}
else
{
day = fileContent.Substring(position + 13, 2);
month = fileContent.Substring(position + 13 + 3, 2);
year = "20" + fileContent.Substring(position + 13 + 6, 2);
}
return "(Build " + year + "-" + month + "-" + day + ")";
}
private static string GetVersion(string FileContent, int position)
{
return FileContent.Substring(position + 76, 4);
}
private static string GetVersion16Bit(string file)
{
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
char[] version = new char[3];
br.BaseStream.Seek(71, SeekOrigin.Begin);
version[0] = br.ReadChar();
br.ReadByte();
version[1] = br.ReadChar();
version[2] = br.ReadChar();
if (char.IsNumber(version[0]) && char.IsNumber(version[1]) && char.IsNumber(version[2]))
return version[0] + "." + version[1] + version[2];
return "";
}
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class LockBlocks
{
// TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_lockblocks.shtml
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class MediaCloQ
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase)) > 0)
return "MediaCloQ";
}
else
{
if (Path.GetFileName(path).Equals("sunncomm.ico", StringComparison.OrdinalIgnoreCase))
return "MediaCloQ";
}
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class MediaMaxCD3
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase)) > 0)
return "MediaMax CD3";
}
else
{
if (Path.GetFileName(path).Equals("LaunchCd.exe", StringComparison.OrdinalIgnoreCase))
return "MediaMax CD3";
}
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class MusicGuard
{
// TODO: Implement - http://web.archive.org/web/20020606000647/http://www.musicguard.com
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Origin
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0)
return "Origin";
}
else
{
if (Path.GetFileName(path).Equals("OriginSetup.exe", StringComparison.OrdinalIgnoreCase))
return "Origin";
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class PECompact
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("PEC2"))
return "PE Compact 2";
return null;
}
}
}

View File

@@ -0,0 +1,47 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace BurnOutSharp.ProtectionType
{
public class PSXAntiModchip
{
public static string CheckContents(string file, string fileContent)
{
// TODO: Detect Red Hand protection
if (fileContent.Contains(" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690"))
return "PlayStation Anti-modchip (English)";
if (fileContent.Contains("強制終了しました。\n本体が改造されている\nおそれがあります。"))
return "PlayStation Anti-modchip (Japanese)";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Where(s => s.ToLowerInvariant().EndsWith(".cnf")).Count() > 0)
{
foreach (string file in files)
{
// Load the current file content
string fileContent = null;
using (StreamReader sr = new StreamReader(file, Encoding.Default))
{
fileContent = sr.ReadToEnd();
}
string protection = CheckContents(path, fileContent);
if (!string.IsNullOrWhiteSpace(protection))
return protection;
}
}
}
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class Phenoprotect
{
// TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_phenoprotect.shtml
}
}

View File

@@ -0,0 +1,28 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class ProtectDVDVideo
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (!isDirectory)
return null;
if (Directory.Exists(Path.Combine(path, "VIDEO_TS")))
{
string[] ifofiles = files.Where(s => s.EndsWith(".ifo")).ToArray();
for (int i = 0; i < ifofiles.Length; i++)
{
FileInfo ifofile = new FileInfo(ifofiles[i]);
if (ifofile.Length == 0)
return "Protect DVD-Video";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,164 @@
using System;
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class ProtectDisc
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("HúMETINF")) > -1)
{
string version = EVORE.SearchProtectDiscVersion(file);
if (version.Length > 0)
{
string[] astrVersionArray = version.Split('.');
if (astrVersionArray[0] == "9")
{
if (GetVersionBuild76till10(file, position, out int ibuild).Length > 0)
return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + astrVersionArray[2] + "." + astrVersionArray[3] + " (Build " + ibuild + ")";
}
else
return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")";
}
}
if ((position = fileContent.IndexOf("ACE-PCD")) > -1)
{
string version = EVORE.SearchProtectDiscVersion(file);
if (version.Length > 0)
{
string[] astrVersionArray = version.Split('.');
return "ProtectDisc " + astrVersionArray[0] + "." + astrVersionArray[1] + "." + astrVersionArray[2] + " (Build " + astrVersionArray[3] + ")";
}
return "ProtectDisc " + GetVersionBuild6till8(file, position);
}
return null;
}
private static string GetVersionBuild6till8(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
string version;
string strBuild;
br.BaseStream.Seek(position - 12, SeekOrigin.Begin);
if (br.ReadByte() == 0xA && br.ReadByte() == 0xD && br.ReadByte() == 0xA && br.ReadByte() == 0xD) // ProtectDisc 6-7 with Build Number in plain text
{
br.BaseStream.Seek(position - 12 - 6, SeekOrigin.Begin);
if (new string(br.ReadChars(6)) == "Henrik") // ProtectDisc 7
{
version = "7.1-7.5";
br.BaseStream.Seek(position - 12 - 6 - 6, SeekOrigin.Begin);
}
else // ProtectDisc 6
{
version = "6";
br.BaseStream.Seek(position - 12 - 10, SeekOrigin.Begin);
while (true) //search for e.g. "Build 050913 - September 2005"
{
if (Char.IsNumber(br.ReadChar()))
break;
br.BaseStream.Seek(-2, SeekOrigin.Current); //search upwards
}
br.BaseStream.Seek(-5, SeekOrigin.Current);
}
}
else
{
br.BaseStream.Seek(position + 28, SeekOrigin.Begin);
if (br.ReadByte() == 0xFB)
{
return "7.6-7.x";
}
else
{
return "8.0";
}
}
strBuild = "" + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar() + br.ReadChar();
return version + " (Build " + strBuild + ")";
}
}
private static string GetVersionBuild76till10(string file, int position, out int irefBuild)
{
irefBuild = 0;
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 37, SeekOrigin.Begin);
byte subversion = br.ReadByte();
br.ReadByte();
byte version = br.ReadByte();
br.BaseStream.Seek(position + 49, SeekOrigin.Begin);
irefBuild = br.ReadInt32();
br.BaseStream.Seek(position + 53, SeekOrigin.Begin);
byte versionindicatorPD9 = br.ReadByte();
br.BaseStream.Seek(position + 0x40, SeekOrigin.Begin);
byte subsubversionPD9x = br.ReadByte();
byte subversionPD9x2 = br.ReadByte();
byte subversionPD9x1 = br.ReadByte();
// version 7
if (version == 0xAC)
return "7." + (subversion ^ 0x43) + " (Build " + irefBuild + ")";
// version 8
else if (version == 0xA2)
{
if (subversion == 0x46)
{
if ((irefBuild & 0x3A00) == 0x3A00)
return "8.2" + " (Build " + irefBuild + ")";
else
return "8.1" + " (Build " + irefBuild + ")";
}
return "8." + (subversion ^ 0x47) + " (Build " + irefBuild + ")";
}
// version 9
else if (version == 0xA3)
{
// version removed or not given
if ((subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61) || (subversionPD9x1 == 0 && subversionPD9x2 == 0))
{
if (versionindicatorPD9 == 0xB)
return "9.0-9.4" + " (Build " + irefBuild + ")";
else if (versionindicatorPD9 == 0xC)
{
if (subversionPD9x2 == 0x5F && subversionPD9x1 == 0x61)
return "9.5-9.11" + " (Build " + irefBuild + ")";
else if (subversionPD9x1 == 0 && subversionPD9x2 == 0)
return "9.11-9.20" + " (Build " + irefBuild + ")";
}
else
return "9." + subversionPD9x1 + subversionPD9x2 + "." + subsubversionPD9x + " (Build " + irefBuild + ")";
}
}
else if (version == 0xA0)
{
// version removed
if (subversionPD9x1 != 0 || subversionPD9x2 != 0)
return "10." + subversionPD9x1 + "." + subsubversionPD9x + " (Build " + irefBuild + ")";
else
return "10.x (Build " + irefBuild + ")";
}
else
return "7.6-10.x (Build " + irefBuild + ")";
return "";
}
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class RingPROTECH
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains((char)0x00 + "Allocator" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00))
return "Ring PROTECH";
return null;
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class Roxxe
{
// TODO: Implement - http://web.archive.org/web/20050309084802/http://www.roxxe.cz
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class SAFEAUDIO
{
// TODO: Implement - https://www.cdmediaworld.com/hardware/cdrom/cd_protections_safeaudio.shtml
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class SVKProtector
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("?SVKP" + (char)0x00 + (char)0x00))
return "SVK Protector";
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SafeCast
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase)) > 0)
return "SafeCast";
}
else
{
if (Path.GetFileName(path).Equals("cdac11ba.exe", StringComparison.OrdinalIgnoreCase))
return "SafeCast";
}
return null;
}
}
}

View File

@@ -0,0 +1,223 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SafeDisc
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("BoG_ *90.0&!! Yy>")) > -1)
{
if (fileContent.IndexOf("product activation library") > 0)
return "SafeCast " + GetVersion(file, position);
else
return "SafeDisc " + GetVersion(file, position);
}
if (fileContent.Contains((char)0x00 + (char)0x00 + "BoG_")
|| fileContent.Contains("stxt774")
|| fileContent.Contains("stxt371"))
{
string version = EVORE.SearchSafeDiscVersion(file);
if (version.Length > 0)
return "SafeDisc " + version;
return "SafeDisc 3.20-4.xx (version removed)";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// 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)
{
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)
{
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)
{
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
{
// V1
if (Path.GetFileName(path).Equals("CLCD16.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CLCD32.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CLOKSPL.EXE", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("icd", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("016", StringComparison.OrdinalIgnoreCase)
|| Path.GetExtension(path).Trim('.').Equals("256", StringComparison.OrdinalIgnoreCase))
{
return "SafeDisc 1";
}
// V1 or greater
else if (Path.GetFileName(path).Equals("00000001.TMP", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CLCD32.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CLOKSPL.EXE", StringComparison.OrdinalIgnoreCase))
{
return "SafeDisc 1 or greater";
}
// V2 or greater
else if (Path.GetFileName(path).Equals("00000002.TMP", StringComparison.OrdinalIgnoreCase))
{
return "SafeDisc 2 or greater";
}
// Specific Versions
else if (Path.GetFileName(path).Equals("DPLAYERX.DLL", StringComparison.OrdinalIgnoreCase))
{
return GetDPlayerXVersion(path);
}
else if (Path.GetFileName(path).Equals("drvmgt.dll", StringComparison.OrdinalIgnoreCase))
{
return GetDrvmgtVersion(path);
}
else if (Path.GetFileName(path).Equals("secdrv.sys", StringComparison.OrdinalIgnoreCase))
{
return GetSecdrvVersion(path);
}
}
return null;
}
private static string GetDPlayerXVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
FileInfo fi = new FileInfo(file);
if (fi.Length == 81408)
return "SafeDisc 1.0x";
else if (fi.Length == 155648)
return "SafeDisc 1.1x";
else if (fi.Length == 156160)
return "SafeDisc 1.1x-1.2x";
else if (fi.Length == 163328)
return "SafeDisc 1.3x";
else if (fi.Length == 165888)
return "SafeDisc 1.35";
else if (fi.Length == 172544)
return "SafeDisc 1.40";
else if (fi.Length == 173568)
return "SafeDisc 1.4x";
else if (fi.Length == 136704)
return "SafeDisc 1.4x";
else if (fi.Length == 138752)
return "SafeDisc 1.5x";
else
return "SafeDisc 1";
}
private static string GetDrvmgtVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
FileInfo fi = new FileInfo(file);
if (fi.Length == 34816)
return "SafeDisc 1.0x";
else if (fi.Length == 32256)
return "SafeDisc 1.1x-1.3x";
else if (fi.Length == 31744)
return "SafeDisc 1.4x";
else if (fi.Length == 34304)
return "SafeDisc 1.5x-2.40";
else if (fi.Length == 35840)
return "SafeDisc 2.51-2.60";
else if (fi.Length == 40960)
return "SafeDisc 2.70";
else if (fi.Length == 23552)
return "SafeDisc 2.80";
else if (fi.Length == 41472)
return "SafeDisc 2.90-3.10";
else if (fi.Length == 24064)
return "SafeDisc 3.15-3.20";
else
return "SafeDisc 1 or greater";
}
private static string GetSecdrvVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
FileInfo fi = new FileInfo(file);
if (fi.Length == 20128)
return "SafeDisc 2.10";
else if (fi.Length == 27440)
return "SafeDisc 2.30";
else if (fi.Length == 28624)
return "SafeDisc 2.40";
else if (fi.Length == 18768)
return "SafeDisc 2.50";
else if (fi.Length == 28400)
return "SafeDisc 2.51";
else if (fi.Length == 29392)
return "SafeDisc 2.60";
else if (fi.Length == 11376)
return "SafeDisc 2.70";
else if (fi.Length == 12464)
return "SafeDisc 2.80";
else if (fi.Length == 12400)
return "SafeDisc 2.90";
else if (fi.Length == 12528)
return "SafeDisc 3.10";
else if (fi.Length == 12528)
return "SafeDisc 3.15";
else if (fi.Length == 11973)
return "SafeDisc 3.20";
else
return "SafeDisc 2 or greater";
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 20, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for old SafeDisc
int version = br.ReadInt32();
int subVersion = br.ReadInt32();
int subsubVersion = br.ReadInt32();
if (version != 0)
return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000");
br.BaseStream.Seek(position + 18 + 14, SeekOrigin.Begin); // Begin reading after "BoG_ *90.0&!! Yy>" for newer SafeDisc
version = br.ReadInt32();
subVersion = br.ReadInt32();
subsubVersion = br.ReadInt32();
if (version == 0)
return "";
return version + "." + subVersion.ToString("00") + "." + subsubVersion.ToString("000");
}
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SafeDiscLite
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase)) > 0)
return "SafeDisc Lite";
}
else
{
if (Path.GetFileName(path).Equals("00000001.LT1", StringComparison.OrdinalIgnoreCase))
return "SafeDisc Lite";
}
return null;
}
}
}

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SafeLock
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("SafeLock"))
return "SafeLock";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SafeLock";
}
}
else
{
if (Path.GetFileName(path).Equals("SafeLock.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SafeLock.001", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SafeLock.128", StringComparison.OrdinalIgnoreCase))
{
return "SafeLock";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,162 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SecuROM
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("AddD" + (char)0x03 + (char)0x00 + (char)0x00 + (char)0x00)) > -1)
return "SecuROM " + GetV4Version(file, position);
if ((position = fileContent.IndexOf("" + (char)0xCA + (char)0xDD + (char)0xDD + (char)0xAC + (char)0x03)) > -1)
return "SecuROM " + GetV5Version(file, position);
if (fileContent.Contains(".securom")
|| fileContent.StartsWith(".securom" + (char)0xE0 + (char)0xC0))
{
return "SecuROM " + GetV7Version(file);
}
if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit"))
return "SecuROM Product Activation " + Utilities.GetFileVersion(file);
if (fileContent.Contains("_and_play.dll" + (char)0x00 + "drm_pagui_doit"))
return "SecuROM Product Activation " + Utilities.GetFileVersion(file);
if (fileContent.Contains(".cms_t" + (char)0x00)
|| fileContent.Contains(".cms_d" + (char)0x00))
{
return "SecuROM 1-3";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SecuROM";
}
else if (files.Count(f => Path.GetFileName(f).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SecuROM New";
}
}
else
{
if (Path.GetFileName(path).Equals("CMS16.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CMS_95.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CMS_NT.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CMS32_95.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("CMS32_NT.DLL", StringComparison.OrdinalIgnoreCase))
{
return "SecuROM";
}
else if (Path.GetFileName(path).Equals("SINTF32.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SINTF16.DLL", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SINTFNT.DLL", StringComparison.OrdinalIgnoreCase))
{
return "SecuROM New";
}
}
return null;
}
private static string GetV4Version(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "AddD"
char version = br.ReadChar();
br.ReadByte();
char subVersion1 = br.ReadChar();
char subVersion2 = br.ReadChar();
br.ReadByte();
char subsubVersion1 = br.ReadChar();
char subsubVersion2 = br.ReadChar();
br.ReadByte();
char subsubsubVersion1 = br.ReadChar();
char subsubsubVersion2 = br.ReadChar();
char subsubsubVersion3 = br.ReadChar();
char subsubsubVersion4 = br.ReadChar();
return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4;
}
}
private static string GetV5Version(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 8, SeekOrigin.Begin); // Begin reading after "ÊÝݬ"
byte version = (byte)(br.ReadByte() & 0xF);
br.ReadByte();
byte subVersion1 = (byte)(br.ReadByte() ^ 36);
byte subVersion2 = (byte)(br.ReadByte() ^ 28);
br.ReadByte();
byte subsubVersion1 = (byte)(br.ReadByte() ^ 42);
byte subsubVersion2 = (byte)(br.ReadByte() ^ 8);
br.ReadByte();
byte subsubsubVersion1 = (byte)(br.ReadByte() ^ 16);
byte subsubsubVersion2 = (byte)(br.ReadByte() ^ 116);
byte subsubsubVersion3 = (byte)(br.ReadByte() ^ 34);
byte subsubsubVersion4 = (byte)(br.ReadByte() ^ 22);
if (version == 0 || version > 9)
return "";
return version + "." + subVersion1 + subVersion2 + "." + subsubVersion1 + subsubVersion2 + "." + subsubsubVersion1 + subsubsubVersion2 + subsubsubVersion3 + subsubsubVersion4;
}
}
private static string GetV7Version(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(236, SeekOrigin.Begin);
byte[] bytes = br.ReadBytes(4);
// if (bytes[0] == 0xED && bytes[3] == 0x5C {
if (bytes[3] == 0x5C)
{
//SecuROM 7 new and 8
return (bytes[0] ^ 0xEA).ToString() + "." + (bytes[1] ^ 0x2C).ToString("00") + "." + (bytes[2] ^ 0x8).ToString("0000");
}
else // SecuROM 7 old
{
br.BaseStream.Seek(122, SeekOrigin.Begin);
bytes = br.ReadBytes(2);
return "7." + (bytes[0] ^ 0x10).ToString("00") + "." + (bytes[1] ^ 0x10).ToString("0000");
//return "7.01-7.10"
}
}
}
}
}

View File

@@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SmartE
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("BITARTS"))
return "SmartE";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SmartE";
}
}
else
{
if (Path.GetFileName(path).Equals("00001.TMP", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("00002.TMP", StringComparison.OrdinalIgnoreCase))
{
return "SmartE";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SoftLock
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SoftLock";
}
}
else
{
if (Path.GetFileName(path).Equals("SOFTLOCKI.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SOFTLOCKC.dat", StringComparison.OrdinalIgnoreCase))
{
return "SoftLock";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,152 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class SolidShield
{
public static string CheckContents(string file, string fileContent)
{
int position;
if (fileContent.Contains("D" + (char)0x00 + "V" + (char)0x00 + "M" + (char)0x00 + " " + (char)0x00 + "L" + (char)0x00
+ "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00 + "r" + (char)0x00 + "y"))
{
return "SolidShield " + Utilities.GetFileVersion(file);
}
if (fileContent.Contains("S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00
+ "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00
+ " " + (char)0x00 + "L" + (char)0x00 + "i" + (char)0x00 + "b" + (char)0x00 + "r" + (char)0x00 + "a" + (char)0x00
+ "r" + (char)0x00 + "y")
|| fileContent.Contains("S" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "i" + (char)0x00 + "d" + (char)0x00
+ "s" + (char)0x00 + "h" + (char)0x00 + "i" + (char)0x00 + "e" + (char)0x00 + "l" + (char)0x00 + "d" + (char)0x00
+ " " + (char)0x00 + "A" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "v" + (char)0x00
+ "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 = 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);
}
if ((position = fileContent.IndexOf("" + (char)0xEF + (char)0xBE + (char)0xAD + (char)0xDE)) > -1)
{
var id1 = fileContent.Substring(position + 5, 3);
var id2 = fileContent.Substring(position + 16, 4);
if (id1 == "" + (char)0x00 + (char)0x00 + (char)0x00 && id2 == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00)
return "SolidShield 1 (SolidShield EXE Wrapper)";
else if (id1 == ".o&" && id2 == "ÛÅ›¹")
return "SolidShield 2 (SolidShield v2 EXE Wrapper)"; // TODO: Verify against other SolidShield 2 discs
}
if (fileContent.Contains("A" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00 + "i" + (char)0x00 + "v" + (char)0x00
+ "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 = 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);
}
if ((position = fileContent.IndexOf("" + (char)0xAD + (char)0xDE + (char)0xFE + (char)0xCA)) > -1)
{
if ((fileContent[position + 3] == (char)0x04 || fileContent[position + 3] == (char)0x05)
&& fileContent.Substring(position + 4, 3) == "" + (char)0x00 + (char)0x00 + (char)0x00
&& fileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x10 + (char)0x00 + (char)0x00)
{
return "SolidShield 2 (SolidShield v2 EXE Wrapper)";
}
else if (fileContent.Substring(position + 4, 3) == "" + (char)0x00 + (char)0x00 + (char)0x00
&& fileContent.Substring(position + 15, 4) == "" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00)
{
position = fileContent.IndexOf("T" + (char)0x00 + "a" + (char)0x00 + "g" + (char)0x00 + "e" + (char)0x00 + "s"
+ (char)0x00 + "S" + (char)0x00 + "e" + (char)0x00 + "t" + (char)0x00 + "u" + (char)0x00 + "p"
+ (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00 + "0" + (char)0x00 + (char)0x8
+ (char)0x00 + (char)0x1 + (char)0x0 + "F" + (char)0x00 + "i" + (char)0x00 + "l" + (char)0x00 + "e"
+ (char)0x00 + "V" + (char)0x00 + "e" + (char)0x00 + "r" + (char)0x00 + "s" + (char)0x00 + "i" + (char)0x00
+ "o" + (char)0x00 + "n" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0x00);
if (position > -1)
{
position--; // TODO: Verify this subtract
return "SolidShield 2 + Tagès " + fileContent.Substring(position + 0x38, 1) + "." + fileContent.Substring(position + 0x38 + 4, 1) + "." + fileContent.Substring(position + 0x38 + 8, 1) + "." + fileContent.Substring(position + 0x38 + 12, 1);
}
else
{
return "SolidShield 2 (SolidShield v2 EXE Wrapper)";
}
}
}
if ((position = fileContent.IndexOf("Solidshield")) > 0)
{
return "SolidShield " + GetVersion(file, position);
}
if (fileContent.Contains("B" + (char)0x00 + "I" + (char)0x00 + "N" + (char)0x00 + (char)0x7 + (char)0x00 +
"I" + (char)0x00 + "D" + (char)0x00 + "R" + (char)0x00 + "_" + (char)0x00 +
"S" + (char)0x00 + "G" + (char)0x00 + "T" + (char)0x0))
{
return "SolidShield";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("hc.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "SolidShield";
}
}
else
{
if (Path.GetFileName(path).Equals("dvm.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("hc.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("solidshield-cd.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("c11prot.dll", StringComparison.OrdinalIgnoreCase))
{
return "SolidShield";
}
}
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 12, SeekOrigin.Begin); // Begin reading after "Solidshield"
char version = br.ReadChar();
br.ReadByte();
char subVersion = br.ReadChar();
br.ReadByte();
char subsubVersion = br.ReadChar();
br.ReadByte();
char subsubsubVersion = br.ReadChar();
return version + "." + subVersion + "." + subsubVersion + "." + subsubsubVersion;
}
}
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class StarForce
{
public static string CheckContents(string file, string fileContent)
{
int position;
if (fileContent.Contains("(" + (char)0x00 + "c" + (char)0x00 + ")" + (char)0x00 + " " + (char)0x00 + "P" + (char)0x00
+ "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "c" + (char)0x00 + "t" + (char)0x00
+ "i" + (char)0x00 + "o" + (char)0x00 + "n" + (char)0x00 + " " + (char)0x00 + "T" + (char)0x00 + "e" + (char)0x00
+ "c" + (char)0x00 + "h" + (char)0x00 + "n" + (char)0x00 + "o" + (char)0x00 + "l" + (char)0x00 + "o" + (char)0x00
+ "g" + (char)0x00 + "y" + (char)0x00)
|| fileContent.Contains("Protection Technology, Ltd."))
{
//if (FileContent.Contains("PSA_GetDiscLabel")
//if (FileContent.Contains("(c) Protection Technology")
position = fileContent.IndexOf("TradeName") - 1;
if (position != -1 && position != -2)
return "StarForce " + Utilities.GetFileVersion(file) + " (" + fileContent.Substring(position + 22, 30).Split((char)0x00)[0] + ")";
else
return "StarForce " + Utilities.GetFileVersion(file);
}
if (fileContent.Contains(".sforce")
|| fileContent.Contains(".brick"))
{
return "StarForce 3-5";
}
if (fileContent.Contains("P" + (char)0x00 + "r" + (char)0x00 + "o" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00
+ "c" + (char)0x00 + "t" + (char)0x00 + "e" + (char)0x00 + "d" + (char)0x00 + " " + (char)0x00 + "M" + (char)0x00
+ "o" + (char)0x00 + "d" + (char)0x00 + "u" + (char)0x00 + "l" + (char)0x00 + "e"))
{
return "StarForce 5";
}
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("protect.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("protect.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "StarForce";
}
}
else
{
if (Path.GetFileName(path).Equals("protect.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("protect.exe", StringComparison.OrdinalIgnoreCase))
{
return "StarForce";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Steam
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "Steam";
}
}
else
{
if (Path.GetFileName(path).Equals("SteamInstall.exe", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SteamInstall.ini", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SteamInstall.msi", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SteamRetailInstaller.dmg", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("SteamSetup.exe", StringComparison.OrdinalIgnoreCase))
{
return "Steam";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,39 @@
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class Sysiphus
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("V SUHPISYSDVD")) > -1)
return "Sysiphus DVD " + GetVersion(file, position);
if ((position = fileContent.IndexOf("V SUHPISYS")) > -1)
return "Sysiphus " + GetVersion(file, position);
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position - 3, SeekOrigin.Begin);
char subVersion = br.ReadChar();
br.ReadChar();
char version = br.ReadChar();
if (char.IsNumber(version) && char.IsNumber(subVersion))
return version + "." + subVersion;
else
return "";
}
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class TZCopyProtector
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("_742893.016", StringComparison.OrdinalIgnoreCase)) > 0)
return "TZCopyProtector";
}
else
{
if (Path.GetFileName(path).Equals("_742893.016", StringComparison.OrdinalIgnoreCase))
return "TZCopyProtector";
}
return null;
}
}
}

View File

@@ -0,0 +1,104 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Tages
{
public static string CheckContents(string file, string fileContent)
{
int position;
if (fileContent.Contains("protected-tages-runtime.exe") ||
fileContent.Contains("tagesprotection.com"))
return "TAGES " + Utilities.GetFileVersion(file);
if ((position = fileContent.IndexOf("" + (char)0xE8 + "u" + (char)0x00 + (char)0x00 + (char)0x00 + (char)0xE8)) > -1
&& fileContent.Substring(--position + 8, 3) == "" + (char)0xFF + (char)0xFF + "h") // TODO: Verify this subtract
return "TAGES " + GetVersion(file, position);
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
List<string> protections = new List<string>();
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase)) > 0)
{
protections.Add("TAGES");
}
if (files.Count(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
string file = files.First(f => Path.GetFileName(f).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase));
protections.Add("TAGES Activation Client " + Utilities.GetFileVersion(file));
}
if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase));
protections.Add("TAGES Setup " + Utilities.GetFileVersion(file));
}
if (files.Count(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
string file = files.First(f => Path.GetFileName(f).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase));
protections.Add("TAGES Setup " + Utilities.GetFileVersion(file));
}
if (protections.Count() == 0)
return null;
else
return string.Join(", ", protections);
}
else
{
if (Path.GetFileName(path).Equals("Tages.dll", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("Wave.aif", StringComparison.OrdinalIgnoreCase))
{
return "TAGES";
}
else if (Path.GetFileName(path).Equals("tagesclient.exe", StringComparison.OrdinalIgnoreCase))
{
return "TAGES Activation Client " + Utilities.GetFileVersion(path);
}
else if (Path.GetFileName(path).Equals("TagesSetup.exe", StringComparison.OrdinalIgnoreCase))
{
return "TAGES Setup " + Utilities.GetFileVersion(path);
}
else if (Path.GetFileName(path).Equals("TagesSetup_x64.exe", StringComparison.OrdinalIgnoreCase))
{
return "TAGES Setup " + Utilities.GetFileVersion(path);
}
}
return null;
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position + 7, SeekOrigin.Begin);
byte bVersion = br.ReadByte();
switch (bVersion)
{
case 0x1B:
return "5.3-5.4";
case 0x14:
return "5.5.0";
case 0x4:
return "5.5.2";
}
return "";
}
}
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class TheBongle
{
// TODO: Implement - http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm
}
}

View File

@@ -0,0 +1,7 @@
namespace BurnOutSharp.ProtectionType
{
public class TheCopyProtectedCD
{
// TODO: Implement - http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm
}
}

View File

@@ -0,0 +1,17 @@
namespace BurnOutSharp.ProtectionType
{
public class ThreePLock
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains(".ldr")
|| fileContent.Contains(".ldt"))
// || fileContent.Contains("Y" + (char)0xC3 + "U" + (char)0x8B + (char)0xEC + (char)0x83 + (char)0xEC + "0SVW")
{
return "3PLock";
}
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Uplay
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase)) > 0)
return "Uplay";
}
else
{
if (Path.GetFileName(path).Equals("UplayInstaller.exe", StringComparison.OrdinalIgnoreCase))
return "Uplay";
}
return null;
}
}
}

View File

@@ -0,0 +1,123 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class VOBProtectCDDVD
{
public static string CheckContents(string file, string fileContent)
{
int position;
if ((position = fileContent.IndexOf("VOB ProtectCD")) > -1)
return "VOB ProtectCD/DVD " + GetOldVersion(file, --position); // TODO: Verify this subtract
if ((position = fileContent.IndexOf("DCP-BOV" + (char)0x00 + (char)0x00)) > -1)
{
string version = GetVersion(file, --position); // TODO: Verify this subtract
if (version.Length > 0)
{
return "VOB ProtectCD/DVD " + version;
}
version = EVORE.SearchProtectDiscVersion(file);
if (version.Length > 0)
{
if (version.StartsWith("2"))
{
version = "6" + version.Substring(1);
}
return "VOB ProtectCD/DVD " + version;
}
return "VOB ProtectCD/DVD 5.9-6.0" + GetBuild(file, position);
}
if (fileContent.Contains(".vob.pcd"))
return "VOB ProtectCD";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase)) > 0)
return "VOB ProtectCD/DVD";
}
else
{
if (Path.GetFileName(path).Equals("VOB-PCD.KEY", StringComparison.OrdinalIgnoreCase))
return "VOB ProtectCD/DVD";
}
return null;
}
private static string GetBuild(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position - 13, SeekOrigin.Begin);
if (!char.IsNumber(br.ReadChar()))
return ""; //Build info removed
br.BaseStream.Seek(position - 4, SeekOrigin.Begin);
int build = br.ReadInt16();
return " (Build " + build + ")";
}
}
private static string GetOldVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
char[] version = new char[3];
br.BaseStream.Seek(position + 16, SeekOrigin.Begin); // Begin reading after "VOB ProtectCD"
version[0] = br.ReadChar();
br.ReadByte();
version[1] = br.ReadChar();
version[2] = br.ReadChar();
if (char.IsNumber(version[0]) && char.IsNumber(version[1]) && char.IsNumber(version[2]))
return version[0] + "." + version[1] + version[2];
return "old";
}
}
private static string GetVersion(string file, int position)
{
if (file == null || !File.Exists(file))
return string.Empty;
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
using (var br = new BinaryReader(fs))
{
br.BaseStream.Seek(position - 2, SeekOrigin.Begin);
byte version = br.ReadByte();
if (version == 5)
{
br.BaseStream.Seek(position - 4, SeekOrigin.Begin);
byte subsubVersion = (byte)((br.ReadByte() & 0xF0) >> 4);
byte subVersion = (byte)((br.ReadByte() & 0xF0) >> 4);
return version + "." + subVersion + "." + subsubVersion;
}
else
{
return "";
}
}
}
}
}

View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class WTMCDProtect
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("WTM76545"))
return "WTM CD Protect";
return null;
}
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetExtension(f).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("imp.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase)) > 0)
{
return "WTM CD Protect";
}
}
else
{
if (Path.GetExtension(path).Trim('.').Equals("IMP", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("imp.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("wtmfiles.dat", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("Viewer.exe", StringComparison.OrdinalIgnoreCase))
{
return "WTM CD Protect";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class Winlock
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
if (files.Count(f => Path.GetFileName(f).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase)) > 0)
return "Winlock";
}
else
{
if (Path.GetFileName(path).Equals("WinLock.PSX", StringComparison.OrdinalIgnoreCase))
return "Winlock";
}
return null;
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace BurnOutSharp.ProtectionType
{
public class XCP
{
public static string CheckPath(string path, IEnumerable<string> files, bool isDirectory)
{
if (isDirectory)
{
// TODO: Verify if these are OR or AND
if (files.Count(f => Path.GetFileName(f).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)) > 0
|| files.Count(f => Path.GetFileName(f).Equals("go.exe", StringComparison.OrdinalIgnoreCase)) > 0) // Path.Combine("contents", "go.exe")
{
return "XCP";
}
}
else
{
if (Path.GetFileName(path).Equals("XCP.DAT", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("ECDPlayerControl.ocx", StringComparison.OrdinalIgnoreCase)
|| Path.GetFileName(path).Equals("go.exe", StringComparison.OrdinalIgnoreCase))
{
return "XCP";
}
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class XtremeProtector
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("XPROT "))
return "Xtreme-Protector";
return null;
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.IO;
namespace BurnOutSharp.ProtectionType
{
public class Zzxzz
{
public static string CheckPath(string path, bool isDirectory)
{
if (isDirectory)
{
if (File.Exists(Path.Combine(path, "Zzxzz", "Zzz.aze")))
return "Zzxzz";
else if (Directory.Exists(Path.Combine(path, "Zzxzz")))
return "Zzxzz";
}
else
{
string filename = Path.GetFileName(path);
if (filename.Equals("Zzz.aze", StringComparison.OrdinalIgnoreCase))
return "Zzxzz";
}
return null;
}
}
}

View File

@@ -0,0 +1,13 @@
namespace BurnOutSharp.ProtectionType
{
public class dotFuscator
{
public static string CheckContents(string fileContent)
{
if (fileContent.Contains("DotfuscatorAttribute"))
return "dotFuscator";
return null;
}
}
}

291
BurnOutSharp/Utilities.cs Normal file
View File

@@ -0,0 +1,291 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
namespace BurnOutSharp
{
public static class Utilities
{
/// <summary>
/// Get the file version as reported by the filesystem
/// </summary>
public static string GetFileVersion(string file)
{
if (file == null || !File.Exists(file))
return string.Empty;
FileVersionInfo fvinfo = FileVersionInfo.GetVersionInfo(file);
if (fvinfo.FileVersion == null)
return "";
if (fvinfo.FileVersion != "")
return fvinfo.FileVersion.Replace(", ", ".");
else
return fvinfo.ProductVersion.Replace(", ", ".");
}
/// <summary>
/// Get the filesystem name for the given drive letter
/// </summary>
/// <remarks>
/// http://pinvoke.net/default.aspx/kernel32/GetVolumeInformation.html
/// </remarks>
public static string GetFileSystemName(char driveLetter)
{
string fsName = null;
StringBuilder volname = new StringBuilder(261);
StringBuilder fsname = new StringBuilder(261);
if (GetVolumeInformation($"{driveLetter}:\\", volname, volname.Capacity, out uint sernum, out uint maxlen, out FileSystemFeature flags, fsname, fsname.Capacity))
{
// Now you know the file system of your drive
// NTFS or FAT16 or UDF for instance
fsName = fsname.ToString();
}
return fsName;
}
#region P/Invoke
// https://stackoverflow.com/questions/8819188/c-sharp-classes-to-undelete-files/8820157#8820157
// Move Method
public const uint FileBegin = 0;
public const uint FileCurrent = 1;
public const uint FileEnd = 2;
// Handle Constants
public const uint INVALID_HANDLE_VALUE = 0;
public const int IOCTL_STORAGE_GET_DEVICE_NUMBER = 0x2D1080;
[DllImport("kernel32.dll", SetLastError = true)]
public static extern bool CloseHandle(IntPtr handle);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr CreateFile(
[MarshalAs(UnmanagedType.LPTStr)] string filename,
[MarshalAs(UnmanagedType.U4)] FileAccess access,
[MarshalAs(UnmanagedType.U4)] FileShare share,
IntPtr securityAttributes, // optional SECURITY_ATTRIBUTES struct or IntPtr.Zero
[MarshalAs(UnmanagedType.U4)] FileMode creationDisposition,
[MarshalAs(UnmanagedType.U4)] FileAttributes flagsAndAttributes,
IntPtr templateFile);
[DllImport("Kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
public extern static bool GetVolumeInformation(
string rootPathName,
StringBuilder volumeNameBuffer,
int volumeNameSize,
out uint volumeSerialNumber,
out uint maximumComponentLength,
out FileSystemFeature fileSystemFlags,
StringBuilder fileSystemNameBuffer,
int nFileSystemNameSize);
[DllImport("Kernel32.dll", SetLastError = true)]
public extern static bool DeviceIoControl(
IntPtr hDevice,
uint IoControlCode,
IntPtr InMediaRemoval,
uint InBufferSize,
IntPtr OutBuffer,
int OutBufferSize,
out int BytesReturned,
IntPtr Overlapped);
// Used to read in a file
[DllImport("kernel32.dll")]
public static extern bool ReadFile(
IntPtr hFile,
byte[] lpBuffer,
uint nNumberOfBytesToRead,
ref uint lpNumberOfBytesRead,
IntPtr lpOverlapped);
[DllImport("kernel32.dll")]
public static extern bool ReadFileEx(
IntPtr hFile,
[Out] byte[] lpBuffer,
uint nNumberOfBytesToRead,
[In] ref NativeOverlapped lpOverlapped,
IOCompletionCallback lpCompletionRoutine);
// Used to set the offset in file to start reading
[DllImport("kernel32.dll")]
public static extern bool SetFilePointerEx(
IntPtr hFile,
long liDistanceToMove,
ref IntPtr lpNewFilePointer,
uint dwMoveMethod);
[StructLayout(LayoutKind.Sequential)]
struct STORAGE_DEVICE_NUMBER
{
public int DeviceType;
public int DeviceNumber;
public int PartitionNumber;
}
public enum MEDIA_TYPE : uint
{
Unknown,
F5_1Pt2_512,
F3_1Pt44_512,
F3_2Pt88_512,
F3_20Pt8_512,
F3_720_512,
F5_360_512,
F5_320_512,
F5_320_1024,
F5_180_512,
F5_160_512,
RemovableMedia,
FixedMedia,
F3_120M_512,
F3_640_512,
F5_640_512,
F5_720_512,
F3_1Pt2_512,
F3_1Pt23_1024,
F5_1Pt23_1024,
F3_128Mb_512,
F3_230Mb_512,
F8_256_128,
F3_200Mb_512,
F3_240M_512,
F3_32M_512
}
[StructLayout(LayoutKind.Sequential)]
public struct DISK_GEOMETRY
{
public long Cylinders;
public MEDIA_TYPE MediaType;
public int TracksPerCylinder;
public int SectorsPerTrack;
public int BytesPerSector;
public long DiskSize
{
get
{
return Cylinders * (long)TracksPerCylinder * (long)SectorsPerTrack * (long)BytesPerSector;
}
}
}
[Flags]
public enum FileSystemFeature : uint
{
/// <summary>
/// The file system preserves the case of file names when it places a name on disk.
/// </summary>
CasePreservedNames = 2,
/// <summary>
/// The file system supports case-sensitive file names.
/// </summary>
CaseSensitiveSearch = 1,
/// <summary>
/// The specified volume is a direct access (DAX) volume. This flag was introduced in Windows 10, version 1607.
/// </summary>
DaxVolume = 0x20000000,
/// <summary>
/// The file system supports file-based compression.
/// </summary>
FileCompression = 0x10,
/// <summary>
/// The file system supports named streams.
/// </summary>
NamedStreams = 0x40000,
/// <summary>
/// The file system preserves and enforces access control lists (ACL).
/// </summary>
PersistentACLS = 8,
/// <summary>
/// The specified volume is read-only.
/// </summary>
ReadOnlyVolume = 0x80000,
/// <summary>
/// The volume supports a single sequential write.
/// </summary>
SequentialWriteOnce = 0x100000,
/// <summary>
/// The file system supports the Encrypted File System (EFS).
/// </summary>
SupportsEncryption = 0x20000,
/// <summary>
/// The specified volume supports extended attributes. An extended attribute is a piece of
/// application-specific metadata that an application can associate with a file and is not part
/// of the file's data.
/// </summary>
SupportsExtendedAttributes = 0x00800000,
/// <summary>
/// The specified volume supports hard links. For more information, see Hard Links and Junctions.
/// </summary>
SupportsHardLinks = 0x00400000,
/// <summary>
/// The file system supports object identifiers.
/// </summary>
SupportsObjectIDs = 0x10000,
/// <summary>
/// The file system supports open by FileID. For more information, see FILE_ID_BOTH_DIR_INFO.
/// </summary>
SupportsOpenByFileId = 0x01000000,
/// <summary>
/// The file system supports re-parse points.
/// </summary>
SupportsReparsePoints = 0x80,
/// <summary>
/// The file system supports sparse files.
/// </summary>
SupportsSparseFiles = 0x40,
/// <summary>
/// The volume supports transactions.
/// </summary>
SupportsTransactions = 0x200000,
/// <summary>
/// The specified volume supports update sequence number (USN) journals. For more information,
/// see Change Journal Records.
/// </summary>
SupportsUsnJournal = 0x02000000,
/// <summary>
/// The file system supports Unicode in file names as they appear on disk.
/// </summary>
UnicodeOnDisk = 4,
/// <summary>
/// The specified volume is a compressed volume, for example, a DoubleSpace volume.
/// </summary>
VolumeIsCompressed = 0x8000,
/// <summary>
/// The file system supports disk quotas.
/// </summary>
VolumeQuotas = 0x20
}
#endregion
}
}

View File

@@ -1,2 +1,77 @@
# BurnOutSharp
C# port of BurnOut copy protect scanner plus enhancements
[![Build status](https://ci.appveyor.com/api/projects/status/gmdft5bk1h8a1c31?svg=true)](https://ci.appveyor.com/project/mnadareski/burnoutsharp)
C# port of the protection scanning ability of [BurnOut](http://burnout.sourceforge.net/) plus numerous updates and additions. This currently compiles as a library so it can be used in any C# application. For an example of usage, see [DICUI](https://github.com/reignstumble/DICUI).
In addition to the original BurnOut code, this port adds the ability to scan inside of Microsoft CAB files (courtesy of [libmspack4n](https://github.com/activescott/libmspack4n)) and InstallShield CAB files (courtesy of [UnshieldSharp](https://github.com/mnadareski/UnshieldSharp)).
## Protections Detected
Below is a list of the protections that can be detected using this code:
- 3PLock
- AACS
- ActiveMARK / ActiveMARK 5
- Alpha-DVD
- Alpha-ROM
- Armadillo
- Bitpool
- ByteShield
- Cactus Data Shield
- CD-Cops
- CD-Lock
- CD-Protector
- CD-X
- CDSHiELD SE
- Cenga ProtectDVD
- Code Lock
- CopyKiller
- Cucko (EA Custom) (partial)
- DiscGuard
- DVD-Cops
- DVD-Movie-PROTECT
- DVD Crypt
- EXE Stealth
- Freelock
- Games for Windows - Live (partial)
- Hexalock Autolock
- Impulse Reactor
- IndyVCD
- JoWooD X-Prot (v1/v2)
- Key2Audio XS
- Key-Lock (Dongle)
- LaserLock
- MediaCloQ
- MediaMax CD3
- Origin (partial)
- ProtectDisc
- Protect DVD-Video
- PlayStation Anti-modchip (En/Jp, not "Red Hand")
- Ring PROTECH
- SafeCast
- SafeDisc (all versions)
- SafeLock
- SecuROM (all versions)
- SmartE
- SolidShield (mostly complete)
- SoftLock
- StarForce
- Steam (partial)
- SVK Protector
- Sysiphus / Sysiphus DVD
- TAGES (mostly complete)
- TZCopyProtector
- Uplay (partial)
- VOB ProtectCD/DVD
- Winlock
- WTM CD Protect
- WTM Copy Protection
- XCP
- Xtreme-Protector
- Zzxzz
## Contributions
Contributions to the project are welcome. Please follow the current coding styles and please do not add any keys or legally dubious things to the code. Thank you to all of the testers, particularly from the DICUI project who helped get this rolling.

6
Test/App.config Normal file
View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>

28
Test/Program.cs Normal file
View File

@@ -0,0 +1,28 @@
using System;
using System.Linq;
using BurnOutSharp;
namespace Test
{
class Program
{
static void Main(string[] args)
{
var p = new Progress<FileProtection>();
p.ProgressChanged += Changed;
foreach (string arg in args)
{
Console.WriteLine(String.Join("\r\n", ProtectionFind.Scan(arg, p).Select(kvp => kvp.Key + ": " + kvp.Value)));
}
Console.ReadLine();
//ProtectionFind.ScanSectors('D', 2048);
}
private static void Changed(object source, FileProtection value)
{
Console.WriteLine($"{value.Percentage * 100:N2}%: {value.Filename} - {value.Protection}");
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("88735ba2-778d-4192-8eb2-fff6843719e2")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

59
Test/Test.csproj Normal file
View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{88735BA2-778D-4192-8EB2-FFF6843719E2}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Test</RootNamespace>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BurnOutSharp\BurnOutSharp.csproj">
<Project>{1da4212e-6071-4951-b45d-bb74a7838246}</Project>
<Name>BurnOutSharp</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>