Fix version finding for MS-CAB SFX

This commit is contained in:
Matt Nadareski
2021-09-11 16:58:05 -07:00
parent 6ab7a06dd5
commit 1bc8fe7ff6

View File

@@ -40,12 +40,12 @@ namespace BurnOutSharp.PackerType
{
0x77, 0x65, 0x78, 0x74, 0x72, 0x61, 0x63, 0x74,
0x5F, 0x63, 0x6C, 0x65, 0x61, 0x6E, 0x75, 0x70,
}, GetVersion, "Microsoft CAB SFX"),
}, "Microsoft CAB SFX"),
};
string match = MatchUtil.GetFirstMatch(file, pex.DataSectionRaw, matchers, includeDebug);
if (!string.IsNullOrWhiteSpace(match))
return match;
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(pex)}".TrimEnd('v');
}
// Get the .text section, if it exists
@@ -56,12 +56,12 @@ namespace BurnOutSharp.PackerType
/* This detects a different but similar type of SFX that uses Microsoft CAB files.
Further research is needed to see if it's just a different version or entirely separate. */
// MSCFu
new ContentMatchSet(new byte?[] { 0x4D, 0x53, 0x43, 0x46, 0x75 }, GetVersion, "Microsoft CAB SFX"),
new ContentMatchSet(new byte?[] { 0x4D, 0x53, 0x43, 0x46, 0x75 }, "Microsoft CAB SFX"),
};
string match = MatchUtil.GetFirstMatch(file, pex.TextSectionRaw, matchers, includeDebug);
if (!string.IsNullOrWhiteSpace(match))
return match;
return $"Microsoft CAB SFX v{Utilities.GetFileVersion(pex)}".TrimEnd('v');
}
return null;
@@ -84,15 +84,5 @@ namespace BurnOutSharp.PackerType
{
return null;
}
// This method of version detection is suboptimal because the version is sometimes the version of the included software, not the SFX itself.
public static string GetVersion(string file, byte[] fileContent, List<int> positions)
{
string version = Utilities.GetFileVersion(fileContent);
if (!string.IsNullOrWhiteSpace(version))
return $"v{version}";
return string.Empty;
}
}
}