-
Notifications
You must be signed in to change notification settings - Fork 14
Move Crunch to its own Packer, improve SmartE detection. #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7080856
Move Crunch to its own Packer, improve SmartE detection.
HeroponRikiBestest fef5cc8
Fix formatting by removing brackets
HeroponRikiBestest 7b23508
Remove named section checks, minor formatting fixes
HeroponRikiBestest 066cbe8
Add newline before summary.
HeroponRikiBestest 91fdb9e
Remove empty returns.
HeroponRikiBestest 4e5c258
Remove unnecessary newline
HeroponRikiBestest 967f14f
Change Crunch to use IExtractableExecutable
HeroponRikiBestest b12ba0e
Remove unnecessary whitespace.
HeroponRikiBestest ae8d89d
Add tests for Crunch.
HeroponRikiBestest File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| using System.IO; | ||
| using BinaryObjectScanner.Packer; | ||
| using Xunit; | ||
|
|
||
| namespace BinaryObjectScanner.Test.Packer | ||
| { | ||
| public class CrunchTests | ||
| { | ||
| [Fact] | ||
| public void CheckPortableExecutableTest() | ||
| { | ||
| string file = "filename"; | ||
| SabreTools.Models.PortableExecutable.Executable model = new(); | ||
| Stream source = new MemoryStream(); | ||
| SabreTools.Serialization.Wrappers.PortableExecutable pex = new(model, source); | ||
|
|
||
| var checker = new Crunch(); | ||
| string? actual = checker.CheckExecutable(file, pex, includeDebug: false); | ||
| Assert.Null(actual); | ||
| } | ||
|
|
||
| [Fact] | ||
| public void ExtractPortableExecutableTest() | ||
| { | ||
| string file = "filename"; | ||
| SabreTools.Models.PortableExecutable.Executable model = new(); | ||
| Stream source = new MemoryStream(); | ||
| SabreTools.Serialization.Wrappers.PortableExecutable pex = new(model, source); | ||
| string outputDir = string.Empty; | ||
|
|
||
| var checker = new Crunch(); | ||
| bool actual = checker.Extract(file, pex, outputDir, includeDebug: false); | ||
| Assert.False(actual); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| using BinaryObjectScanner.Interfaces; | ||
| using SabreTools.Serialization.Wrappers; | ||
|
|
||
| namespace BinaryObjectScanner.Packer | ||
| { | ||
| // Packer used by all known SmartE games, but also used by some other non-SmartE protected software as well. | ||
| // https://web.archive.org/web/20020806102129/http://www.bit-arts.com/windows_solutions.html | ||
| // TODO: Other BitArts products may also use this same string. No samples have yet been found. | ||
| public class Crunch : IExtractableExecutable<PortableExecutable> | ||
| { | ||
| /// <inheritdoc/> | ||
| public string? CheckExecutable(string file, PortableExecutable pex, bool includeDebug) | ||
| { | ||
| // Get the last section strings, if they exist | ||
| var sections = pex.Model.SectionTable ?? []; | ||
| var strs = pex.GetSectionStrings(sections.Length - 1); | ||
| if (strs != null) | ||
| { | ||
| if (strs.Exists(s => s.Contains("BITARTS"))) | ||
| return "Crunch"; | ||
| } | ||
|
|
||
| return null; | ||
| } | ||
|
|
||
| /// <inheritdoc/> | ||
| public bool Extract(string file, PortableExecutable pex, string outDir, bool includeDebug) | ||
| { | ||
| return false; | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.