Compare commits

...

5 Commits

Author SHA1 Message Date
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
7 changed files with 89 additions and 29 deletions

View File

@@ -44,8 +44,8 @@
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="UnshieldSharp, Version=1.4.2.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UnshieldSharp.1.4.2.1\lib\net461\UnshieldSharp.dll</HintPath>
<Reference Include="UnshieldSharp, Version=1.4.2.2, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\UnshieldSharp.1.4.2.2\lib\net461\UnshieldSharp.dll</HintPath>
</Reference>
<Reference Include="zlib.net, Version=1.0.3.0, Culture=neutral, PublicKeyToken=47d7877cb3620160">
<HintPath>..\packages\zlib.net.1.0.4.0\lib\zlib.net.dll</HintPath>
@@ -54,6 +54,7 @@
<ItemGroup>
<Compile Include="CaseInsensitiveDictionary.cs" />
<Compile Include="EVORE.cs" />
<Compile Include="Progress.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProtectionFind.cs" />
</ItemGroup>

View File

@@ -2,7 +2,7 @@
<package >
<metadata>
<id>BurnOutSharp</id>
<version>1.03.6</version>
<version>1.03.7.1</version>
<title>BurnOutSharp</title>
<authors>Matt Nadareski, Gernot Knippen</authors>
<owners>Matt Nadareski, Gernot Knippen</owners>
@@ -15,7 +15,7 @@
<dependencies>
<dependency id="LessIO" version="0.5.0" />
<dependency id="libmspack4n" version="0.8.0" />
<dependency id="UnshieldSharp" version="1.4.2.1" />
<dependency id="UnshieldSharp" version="1.4.2.2" />
</dependencies>
</metadata>
<files>

16
BurnOutSharp/Progress.cs Normal file
View File

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

View File

@@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// 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.6")]
[assembly: AssemblyFileVersion("1.03.6.0")]
[assembly: AssemblyVersion("1.03.7.1")]
[assembly: AssemblyFileVersion("1.03.7.1")]

View File

@@ -33,6 +33,7 @@ namespace BurnOutSharp
/// 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>
/// <remarks>
/// TODO: Sector scanning?
@@ -51,10 +52,13 @@ namespace BurnOutSharp
/// - The Bongle (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
/// - The Copy-Protected CD (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
/// </remarks>
public static Dictionary<string, string> Scan(string path)
public static Dictionary<string, string> Scan(string path, IProgress<Progress> progress = null)
{
var protections = new Dictionary<string, string>();
// Checkpoint
progress?.Report(new Progress(null, 0, null));
// Create mappings for checking against
var mappings = CreateFilenameProtectionMapping();
@@ -73,6 +77,9 @@ namespace BurnOutSharp
string protectionname = ScanInFile(path)?.Replace("" + (char)0x00, "");
if (!String.IsNullOrEmpty(protectionname))
protections[path] = protectionname;
// Checkpoint
progress?.Report(new Progress(path, 1, protectionname));
}
// If we have a directory
else if (Directory.Exists(path))
@@ -92,13 +99,20 @@ namespace BurnOutSharp
if (ProtectDVDVideo(path, files))
protections[path] = "Protect DVD-Video";
// PSX Anti-modchip
if (PSXAntiModchip(path, files))
protections[path] = "PlayStation Anti-modchip";
// Zzxzz
if (Directory.Exists(Path.Combine(path, "Zzxzz")))
protections[path] = "Zzxzz";
// Loop through all files and scan them
foreach (string file in files)
for (int i = 0; i < files.Length; i++)
{
// Get the current file
string file = files[i];
// If the file is in the list of known files, add that to the protections found
if (mappings.ContainsKey(Path.GetFileName(file)))
protections[file] = mappings[Path.GetFileName(file)];
@@ -111,6 +125,9 @@ namespace BurnOutSharp
string protectionname = ScanInFile(file)?.Replace("" + (char)0x00, "");
if (!String.IsNullOrEmpty(protectionname))
protections[file] = protectionname;
// Checkpoint
progress?.Report(new Progress(file, i / files.Length, protectionname));
}
}
@@ -445,6 +462,7 @@ namespace BurnOutSharp
{
try
{
List<string> protections = new List<string>();
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);
@@ -462,16 +480,17 @@ namespace BurnOutSharp
catch { }
if (!String.IsNullOrEmpty(protection))
{
try
{
Directory.Delete(tempPath, true);
}
catch { }
return protection;
}
protections.Add(protection);
}
}
try
{
Directory.Delete(tempPath, true);
}
catch { }
return string.Join(", ", protections);
}
catch { }
}
@@ -481,6 +500,7 @@ namespace BurnOutSharp
{
try
{
List<string> protections = new List<string>();
string tempPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
Directory.CreateDirectory(tempPath);
@@ -493,15 +513,16 @@ namespace BurnOutSharp
File.Delete(tempfile);
if (!String.IsNullOrEmpty(protection))
{
try
{
Directory.Delete(tempPath, true);
}
catch { }
return protection;
}
protections.Add(protection);
}
try
{
Directory.Delete(tempPath, true);
}
catch { }
return string.Join(", ", protections);
}
catch { }
}
@@ -678,6 +699,31 @@ namespace BurnOutSharp
return false;
}
private static bool PSXAntiModchip(string path, string[] files)
{
if (files.Where(s => s.ToLower().EndsWith(".cnf")).Count() > 0)
{
foreach (string file in files)
{
try
{
// Load the current file and check for specialty strings first
StreamReader sr = new StreamReader(file, Encoding.Default);
string FileContent = sr.ReadToEnd();
sr.Close();
if (FileContent.Contains(" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690")
|| FileContent.Contains("強制終了しました。\n本体が改造されている\nおそれがあります。"))
return true;
}
catch { }
}
}
return false;
}
#endregion
#region Version detections
@@ -1144,9 +1190,6 @@ namespace BurnOutSharp
// Origin
mapping.Add("OriginSetup.exe", "Origin");
// PSX LibCrypt - TODO: That's... not accurate
mapping.Add(".cnf", "PSX LibCrypt");
// SafeCast
mapping.Add("cdac11ba.exe", "SafeCast");

View File

@@ -2,6 +2,6 @@
<packages>
<package id="LessIO" version="0.5.0" targetFramework="net461" />
<package id="libmspack4n" version="0.8.0" targetFramework="net461" />
<package id="UnshieldSharp" version="1.4.2.1" targetFramework="net461" />
<package id="UnshieldSharp" version="1.4.2.2" targetFramework="net461" />
<package id="zlib.net" version="1.0.4.0" targetFramework="net461" />
</packages>

View File

@@ -45,7 +45,7 @@ Below is a list of the protections that can be detected using this code:
- Origin (partial)
- ProtectDisc
- Protect DVD-Video
- PSX LibCrypt (partial)
- PlayStation Anti-modchip (En/Jp, not "Red Hand")
- Ring PROTECH
- SafeCast
- SafeDisc (all versions)