Skip to content

Commit 11034a7

Browse files
Move PA Module detection into its own helper method. (#379)
* Move PA Module detection into its own helper method. * Fix review changes.
1 parent a76a8d0 commit 11034a7

File tree

1 file changed

+53
-38
lines changed

1 file changed

+53
-38
lines changed

BinaryObjectScanner/Protection/SecuROM.cs

Lines changed: 53 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -15,46 +15,12 @@ public class SecuROM : IExecutableCheck<PortableExecutable>, IPathCheck
1515
/// <inheritdoc/>
1616
public string? CheckExecutable(string file, PortableExecutable exe, bool includeDebug)
1717
{
18-
var name = exe.FileDescription;
19-
if (name.OptionalContains("SecuROM PA"))
20-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
21-
22-
name = exe.InternalName;
23-
if (name.OptionalEquals("paul.dll", StringComparison.OrdinalIgnoreCase))
18+
// Check if executable is a Securom PA Module
19+
var paModule = CheckProductActivation(exe);
20+
if (paModule != null)
2421
{
25-
if (exe.ProductName.OptionalEquals("drEAm"))
26-
return $"SecuROM Product Activation v{exe.GetInternalVersion()} - EA Game Authorization Management";
27-
else
28-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
29-
}
30-
else if (name.OptionalEquals("paul_dll_activate_and_play.dll"))
31-
{
32-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
22+
return paModule;
3323
}
34-
else if (name.OptionalEquals("paul_dll_preview_and_review.dll"))
35-
{
36-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
37-
}
38-
39-
name = exe.OriginalFilename;
40-
if (name.OptionalEquals("paul_dll_activate_and_play.dll"))
41-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
42-
43-
name = exe.ProductName;
44-
if (name.OptionalContains("SecuROM Activate & Play"))
45-
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
46-
47-
// Fallback for PA if none of the above occur, in the case of companies that used their own modified PA
48-
// variants. PiD refers to this as "SecuROM Modified PA Module".
49-
// Found in Redump entries 111997 (paul.dll) and 56373+56374 (AurParticleSystem.dll). The developers of
50-
// both, Softstar and Aurogon respectively(?), seem to have some connection, and use similar-looking
51-
// modified PA. It probably has its own name like EA's GAM, but I don't currently know what that would be.
52-
// Regardless, even if these are given their own named variant later, this check should remain in order to
53-
// catch other modified PA variants (this would have also caught EA GAM, for example) and to match PiD's
54-
// detection abilities.
55-
name = exe.ExportTable?.ExportNameTable?.Strings?[0];
56-
if (name.OptionalEquals("drm_pagui_doit"))
57-
return $"SecuROM Product Activation - Modified";
5824

5925
// Get the matrosch section, if it exists
6026
if (exe.ContainsSection("matrosch", exact: true))
@@ -301,5 +267,54 @@ private static string GetV8WhiteLabelVersion(PortableExecutable exe)
301267

302268
return $"{major}.{minor:00}.{patch:0000}";
303269
}
270+
271+
272+
/// <summary>
273+
/// Helper method to check if a given PortableExecutable is a SecuROM PA module.
274+
/// </summary>
275+
private static string? CheckProductActivation(PortableExecutable exe)
276+
{
277+
var name = exe.FileDescription;
278+
if (name.OptionalContains("SecuROM PA"))
279+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
280+
281+
name = exe.InternalName;
282+
283+
// Checks if ProductName isn't drEAm to organize custom module checks at the end.
284+
if (name.OptionalEquals("paul.dll", StringComparison.OrdinalIgnoreCase) ^ exe.ProductName.OptionalEquals("drEAm"))
285+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
286+
else if (name.OptionalEquals("paul_dll_activate_and_play.dll"))
287+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
288+
else if (name.OptionalEquals("paul_dll_preview_and_review.dll"))
289+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
290+
291+
name = exe.OriginalFilename;
292+
if (name.OptionalEquals("paul_dll_activate_and_play.dll"))
293+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
294+
295+
name = exe.ProductName;
296+
if (name.OptionalContains("SecuROM Activate & Play"))
297+
return $"SecuROM Product Activation v{exe.GetInternalVersion()}";
298+
299+
// Custom Module Checks
300+
301+
if (exe.ProductName.OptionalEquals("drEAm"))
302+
return $"SecuROM Product Activation v{exe.GetInternalVersion()} - EA Game Authorization Management";
303+
304+
// Fallback for PA if none of the above occur, in the case of companies that used their own modified PA
305+
// variants. PiD refers to this as "SecuROM Modified PA Module".
306+
// Found in Redump entries 111997 (paul.dll) and 56373+56374 (AurParticleSystem.dll). The developers of
307+
// both, Softstar and Aurogon respectively(?), seem to have some connection, and use similar-looking
308+
// modified PA. It probably has its own name like EA's GAM, but I don't currently know what that would be.
309+
// Regardless, even if these are given their own named variant later, this check should remain in order to
310+
// catch other modified PA variants (this would have also caught EA GAM, for example) and to match PiD's
311+
// detection abilities.
312+
// TODO: Decide whether to get internal version or not in the future.
313+
name = exe.ExportTable?.ExportNameTable?.Strings?[0];
314+
if (name.OptionalEquals("drm_pagui_doit"))
315+
return $"SecuROM Product Activation - Modified";
316+
317+
return null;
318+
}
304319
}
305320
}

0 commit comments

Comments
 (0)