mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-08 18:06:34 +00:00
Add UPX checking
This commit is contained in:
@@ -228,6 +228,11 @@ namespace BurnOutSharp.FileType
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
protections.Add(protection);
|
||||
|
||||
// UPX
|
||||
protection = UPX.CheckContents(fileContent, includePosition);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
protections.Add(protection);
|
||||
|
||||
// VOB ProtectCD/DVD
|
||||
protection = VOBProtectCDDVD.CheckContents(file, fileContent, includePosition);
|
||||
if (!string.IsNullOrWhiteSpace(protection))
|
||||
|
||||
33
BurnOutSharp/ProtectionType/UPX.cs
Normal file
33
BurnOutSharp/ProtectionType/UPX.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Text;
|
||||
|
||||
namespace BurnOutSharp.ProtectionType
|
||||
{
|
||||
public class UPX
|
||||
{
|
||||
public static string CheckContents(byte[] fileContent, bool includePosition = false)
|
||||
{
|
||||
// UPX!
|
||||
byte[] check = new byte[] { 0x55, 0x50, 0x58, 0x21 };
|
||||
if (fileContent.Contains(check, out int position))
|
||||
{
|
||||
string version = GetVersion(fileContent, position);
|
||||
return $"UPX {version}" + (includePosition ? $" (Index {position})" : string.Empty);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetVersion(byte[] fileContent, int index)
|
||||
{
|
||||
try
|
||||
{
|
||||
index -= 5;
|
||||
return Encoding.ASCII.GetString(fileContent, index, 4);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "(Unknown Version)";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user