mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-05-06 20:43:44 +00:00
Separate protections into their own classes
This commit is contained in:
53
BurnOutSharp/ProtectionType/PSXAntiModchip.cs
Normal file
53
BurnOutSharp/ProtectionType/PSXAntiModchip.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
public class PSXAntiModchip
|
||||
{
|
||||
public static string CheckContents(string file, string fileContent)
|
||||
{
|
||||
if (fileContent.Contains(" SOFTWARE TERMINATED\nCONSOLE MAY HAVE BEEN MODIFIED\n CALL 1-888-780-7690"))
|
||||
return "PlayStation Anti-modchip (English)";
|
||||
else 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)
|
||||
{
|
||||
using (var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
string fileContent = sr.ReadToEnd();
|
||||
string protection = CheckContents(path, fileContent);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
return protection;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var fs = File.Open(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
|
||||
using (var sr = new StreamReader(fs))
|
||||
{
|
||||
string fileContent = sr.ReadToEnd();
|
||||
string protection = CheckContents(path, fileContent);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
return protection;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user