|
| 1 | +using System; |
| 2 | +#if NET40_OR_GREATER || NETCOREAPP |
| 3 | +using System.Collections.Concurrent; |
| 4 | +#endif |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | +using BinaryObjectScanner.Interfaces; |
| 8 | +using SabreTools.Matching; |
| 9 | +using SabreTools.Serialization.Wrappers; |
| 10 | + |
| 11 | +namespace BinaryObjectScanner.Protection |
| 12 | +{ |
| 13 | + /// <summary> |
| 14 | + /// Roxxe was a Czech DRM. It appears to have been a simple disc check that also relied on unusual disc manufacturing and dummy files to attempt to prevent copying. |
| 15 | + /// |
| 16 | + /// DRML: https://github.com/TheRogueArchivist/DRML/blob/main/entries/Roxxe/Roxxe.md |
| 17 | + /// </summary> |
| 18 | + public class Roxxe : IPathCheck, IPortableExecutableCheck |
| 19 | + { |
| 20 | + /// <inheritdoc/> |
| 21 | + public string? CheckPortableExecutable(string file, PortableExecutable pex, bool includeDebug) |
| 22 | + { |
| 23 | + // Get the sections from the executable, if possible |
| 24 | + var sections = pex.Model.SectionTable; |
| 25 | + if (sections == null) |
| 26 | + return null; |
| 27 | + |
| 28 | + // Get the code/CODE section strings, if they exist |
| 29 | + var strs = pex.GetFirstSectionStrings("code") ?? pex.GetFirstSectionStrings("CODE"); |
| 30 | + if (strs != null) |
| 31 | + { |
| 32 | + // Found in "Owar.exe" in IA item "game4u-22-cd". |
| 33 | + if (strs.Any(s => s.Contains("TRCHANGER.INI"))) |
| 34 | + return "Roxxe"; |
| 35 | + } |
| 36 | + |
| 37 | + // Get the .rsrc section strings, if they exist |
| 38 | + // TODO: Check for these strings specifically within the application-defined resource that they're found in, not just the generic resource section. |
| 39 | + strs = pex.GetFirstSectionStrings(".rsrc"); |
| 40 | + if (strs != null) |
| 41 | + { |
| 42 | + // Found in "Owar.exe" in IA items "game4u-22-cd" and "original-war". |
| 43 | + // These checks are less reliable, as they are still found in a version of the game that appears to have patched out Roxxe (the version present in IA item "original-war"). |
| 44 | + if (strs.Any(s => s.Contains("PRRT01"))) |
| 45 | + return "Roxxe (Possibly remnants)"; |
| 46 | + |
| 47 | + if (strs.Any(s => s.Contains("CommonPRRT"))) |
| 48 | + return "Roxxe (Possibly remnants)"; |
| 49 | + |
| 50 | + if (strs.Any(s => s.Contains("roxe"))) |
| 51 | + return "Roxxe (Possibly remnants)"; |
| 52 | + } |
| 53 | + |
| 54 | + return null; |
| 55 | + } |
| 56 | + |
| 57 | + /// <inheritdoc/> |
| 58 | +#if NET20 || NET35 |
| 59 | + public Queue<string> CheckDirectoryPath(string path, IEnumerable<string>? files) |
| 60 | +#else |
| 61 | + public ConcurrentQueue<string> CheckDirectoryPath(string path, IEnumerable<string>? files) |
| 62 | +#endif |
| 63 | + { |
| 64 | + var matchers = new List<PathMatchSet> |
| 65 | + { |
| 66 | + // Files such as "TRCHANGER.INI" may be present, but haven't been found yet. |
| 67 | + }; |
| 68 | + |
| 69 | + return MatchUtil.GetAllMatches(files, matchers, any: true); |
| 70 | + } |
| 71 | + |
| 72 | + /// <inheritdoc/> |
| 73 | + public string? CheckFilePath(string path) |
| 74 | + { |
| 75 | + var matchers = new List<PathMatchSet> |
| 76 | + { |
| 77 | + // Files such as "TRCHANGER.INI" may be present, but haven't been found yet. |
| 78 | + }; |
| 79 | + |
| 80 | + return MatchUtil.GetFirstMatch(path, matchers, any: true); |
| 81 | + } |
| 82 | + } |
| 83 | +} |
0 commit comments