Skip to content

Commit d316edf

Browse files
committed
Be smarter about SecuROM v4
1 parent 9af871c commit d316edf

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

BinaryObjectScanner/Protection/SecuROM.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,9 @@ public class SecuROM : IExecutableCheck<PortableExecutable>, IPathCheck
4141
return $"SecuROM SLL Protected (for SecuROM v8.x)";
4242

4343
// Search after the last section
44-
if (exe.OverlayStrings != null)
45-
{
46-
if (exe.OverlayStrings.Exists(s => s == "AddD"))
47-
return $"SecuROM {GetV4Version(exe)}";
48-
}
44+
string? v4Version = GetV4Version(exe);
45+
if (v4Version != null)
46+
return $"SecuROM {v4Version}";
4947

5048
// Get the sections 5+, if they exist (example names: .fmqyrx, .vcltz, .iywiak)
5149
var sections = exe.SectionTable ?? [];
@@ -144,12 +142,17 @@ public List<string> CheckDirectoryPath(string path, List<string>? files)
144142
return MatchUtil.GetFirstMatch(path, matchers, any: true);
145143
}
146144

147-
private static string GetV4Version(PortableExecutable exe)
145+
/// <summary>
146+
/// Try to get the SecuROM v4 version from the overlay, if possible
147+
/// </summary>
148+
/// <param name="exe">Executable to retrieve the overlay from</param>
149+
/// <returns>The version on success, null otherwise</returns>
150+
private static string? GetV4Version(PortableExecutable exe)
148151
{
149152
// Cache the overlay data for easier access
150153
var overlayData = exe.OverlayData;
151154
if (overlayData == null || overlayData.Length < 20)
152-
return "(very old, v3 or less)";
155+
return null;
153156

154157
// Search for the "AddD" string in the overlay
155158
bool found = false;
@@ -167,7 +170,7 @@ private static string GetV4Version(PortableExecutable exe)
167170

168171
// If the string wasn't found in the first 0x100 bytes
169172
if (!found)
170-
return "(very old, v3 or less)";
173+
return null;
171174

172175
// Read the version starting 4 bytes after the signature
173176
index += 8;

0 commit comments

Comments
 (0)