-
Notifications
You must be signed in to change notification settings - Fork 4
Add extraction for installshield executables. #27
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
Changes from all commits
e2242fb
616d2dd
a8c36f0
afc0b30
0c20542
6caf368
796c3d0
f89e92c
e64ad48
19d87ac
cd1c52b
6878c5f
36efd38
31160d0
518794b
3e31138
6d431f9
efec0fb
477244a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| namespace SabreTools.Data.Models.InstallShieldExecutable | ||
| { | ||
| public class ExtractableFile | ||
| { | ||
| /// <summary> | ||
| /// Name of the file, only ASCII characters(?) | ||
| /// </summary> | ||
| public string? Name { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Path of the file, only ASCII characters(?), seems to usually use \ filepaths | ||
| /// </summary> | ||
| public string? Path { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Version of the file | ||
| /// </summary> | ||
| public string? Version { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Length of the file. Stored in the installshield executable as a string. | ||
| /// </summary> | ||
| public ulong Length { get; set; } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| using System.IO; | ||
| using SabreTools.Data.Models.InstallShieldExecutable; | ||
| using SabreTools.IO.Extensions; | ||
|
|
||
| namespace SabreTools.Serialization.Readers | ||
| { | ||
| public class InstallShieldExecutableFile : BaseBinaryReader<ExtractableFile> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Future note: This will likely be expanded to cover an entire overlay section and not a singular entry.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will I need to do that? I'd be fine with doing it if I understood how it would be expanded to cover that.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not in this PR |
||
| { | ||
| public override ExtractableFile? Deserialize(Stream? data) | ||
| { | ||
| // If the data is invalid | ||
| if (data == null || !data.CanRead) | ||
| return null; | ||
|
|
||
| try | ||
| { | ||
| // Cache the initial offset | ||
| long initialOffset = data.Position; | ||
|
|
||
| // Try to parse the header | ||
| var header = ParseExtractableFileHeader(data); | ||
| if (header == null) | ||
| return null; | ||
|
|
||
| return header; | ||
| } | ||
| catch | ||
| { | ||
| // Ignore the actual error | ||
| return null; | ||
| } | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Parse a Stream into an InstallShield Executable file header | ||
| /// </summary> | ||
| /// <param name="data">Stream to parse</param> | ||
| /// <returns>Filled InstallShield Executable file header on success, null on error</returns> | ||
| public static ExtractableFile? ParseExtractableFileHeader(Stream? data) | ||
| { | ||
| var obj = new ExtractableFile(); | ||
|
|
||
| obj.Name = data.ReadNullTerminatedAnsiString(); | ||
mnadareski marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| if (obj.Name == null) | ||
| return null; | ||
|
|
||
| obj.Path = data.ReadNullTerminatedAnsiString(); | ||
| if (obj.Path == null) | ||
| return null; | ||
|
|
||
| obj.Version = data.ReadNullTerminatedAnsiString(); | ||
| if (obj.Version == null) | ||
| return null; | ||
|
|
||
| var versionString = data.ReadNullTerminatedAnsiString(); | ||
| if (versionString == null || !ulong.TryParse(versionString, out var foundVersion)) | ||
| return null; | ||
|
|
||
| obj.Length = foundVersion; | ||
| if (obj.Name == null) | ||
| return null; | ||
|
|
||
| return obj; | ||
| } | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.