mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-07-09 02:16:46 +00:00
Introduce OptionalEndsWith
This commit is contained in:
@@ -68,6 +68,19 @@ namespace BinaryObjectScanner
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="string.EndsWith(string)"/>
|
||||
public static bool OptionalEndsWith(this string? self, string value)
|
||||
=> OptionalEndsWith(self, value, StringComparison.Ordinal);
|
||||
|
||||
/// <inheritdoc cref="string.EndsWith(string, StringComparison)"/>
|
||||
public static bool OptionalEndsWith(this string? self, string value, StringComparison comparisonType)
|
||||
{
|
||||
if (self == null)
|
||||
return false;
|
||||
|
||||
return self.EndsWith(value, comparisonType);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="string.Equals(string)"/>
|
||||
public static bool OptionalEquals(this string? self, string value)
|
||||
=> OptionalEquals(self, value, StringComparison.Ordinal);
|
||||
|
||||
@@ -28,17 +28,14 @@ namespace BinaryObjectScanner.Protection
|
||||
return "Armadillo";
|
||||
|
||||
// Loop through all "extension" sections -- usually .data1 or .text1
|
||||
if (exe.SectionNames != null)
|
||||
foreach (var sectionName in Array.FindAll(exe.SectionNames, s => s.OptionalEndsWith("1")))
|
||||
{
|
||||
foreach (var sectionName in Array.FindAll(exe.SectionNames ?? [], s => s != null && s.EndsWith("1")))
|
||||
// Get the section strings, if they exist
|
||||
var strs = exe.GetFirstSectionStrings(sectionName);
|
||||
if (strs != null)
|
||||
{
|
||||
// Get the section strings, if they exist
|
||||
var strs = exe.GetFirstSectionStrings(sectionName);
|
||||
if (strs != null)
|
||||
{
|
||||
if (strs.Exists(s => s.Contains("ARMDEBUG")))
|
||||
return "Armadillo";
|
||||
}
|
||||
if (strs.Exists(s => s.Contains("ARMDEBUG")))
|
||||
return "Armadillo";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user