mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-29 01:50:24 +00:00
Convert Sysiphus to string finding
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BurnOutSharp.Interfaces;
|
||||
using BurnOutSharp.Matching;
|
||||
using BurnOutSharp.Wrappers;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
@@ -17,44 +16,28 @@ namespace BurnOutSharp.ProtectionType
|
||||
if (sections == null)
|
||||
return null;
|
||||
|
||||
// Get the .data/DATA section, if it exists
|
||||
var dataSectionRaw = pex.GetFirstSectionData(".data") ?? pex.GetFirstSectionData("DATA");
|
||||
if (dataSectionRaw != null)
|
||||
// Get the .data/DATA section strings, if they exist
|
||||
List<string> strs = pex.GetFirstSectionStrings(".data") ?? pex.GetFirstSectionStrings("DATA");
|
||||
if (strs != null)
|
||||
{
|
||||
var matchers = new List<ContentMatchSet>
|
||||
{
|
||||
// V SUHPISYS
|
||||
new ContentMatchSet(new byte?[]
|
||||
{
|
||||
0x56, 0x20, 0x53, 0x55, 0x48, 0x50, 0x49, 0x53,
|
||||
0x59, 0x53
|
||||
}, GetVersion, "Sysiphus"),
|
||||
};
|
||||
|
||||
string match = MatchUtil.GetFirstMatch(file, dataSectionRaw, matchers, includeDebug);
|
||||
if (!string.IsNullOrWhiteSpace(match))
|
||||
return match;
|
||||
string str = strs.FirstOrDefault(s => s.Contains("V SUHPISYS"));
|
||||
if (str != null)
|
||||
return $"Sysiphus {GetVersion(str)}";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
|
||||
public static string GetVersion(string matchedString)
|
||||
{
|
||||
// The version is reversed
|
||||
string version = new string(
|
||||
new ArraySegment<byte>(fileContent, positions[0] - 4, 4)
|
||||
.Reverse()
|
||||
.Select(b => (char)b)
|
||||
.ToArray())
|
||||
.Trim();
|
||||
// The string is reversed
|
||||
matchedString = new string(matchedString.Reverse().ToArray()).Trim();
|
||||
|
||||
// Check for the DVD extra string
|
||||
string extra = new string(
|
||||
new ArraySegment<byte>(fileContent, positions[0] + "V SUHPISYS".Length, 3)
|
||||
.Select(b => (char)b)
|
||||
.ToArray());
|
||||
bool isDVD = extra == "DVD";
|
||||
bool isDVD = matchedString.StartsWith("DVD");
|
||||
|
||||
// Get the version string
|
||||
string version = matchedString.Substring(isDVD ? "V SUHPISYSDVD".Length : "V SUHPISYS".Length, 4).Trim();
|
||||
|
||||
if (char.IsNumber(version[0]) && char.IsNumber(version[2]))
|
||||
return isDVD ? $"DVD {version}" : version;
|
||||
|
||||
Reference in New Issue
Block a user