mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-18 20:22:42 +00:00
Only some executables are extractable
This commit is contained in:
@@ -11,25 +11,12 @@ namespace BinaryObjectScanner.FileType
|
||||
/// <summary>
|
||||
/// Executable or library
|
||||
/// </summary>
|
||||
public abstract class Executable<T> : DetectableBase<T>, IExtractable
|
||||
public abstract class Executable<T> : DetectableBase<T>
|
||||
where T : WrapperBase
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public Executable(T? wrapper) : base(wrapper) { }
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Extract(string file, string outDir, bool includeDebug)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
return false;
|
||||
|
||||
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
return Extract(fs, file, outDir, includeDebug);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public abstract bool Extract(Stream? stream, string file, string outDir, bool includeDebug);
|
||||
|
||||
#region Check Runners
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -43,8 +43,5 @@ namespace BinaryObjectScanner.FileType
|
||||
|
||||
return string.Join(";", [.. protectionList]);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) => false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,8 +43,5 @@ namespace BinaryObjectScanner.FileType
|
||||
|
||||
return string.Join(";", [.. protectionList]);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug) => false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BinaryObjectScanner.Data;
|
||||
using BinaryObjectScanner.Interfaces;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
|
||||
namespace BinaryObjectScanner.FileType
|
||||
@@ -9,7 +9,7 @@ namespace BinaryObjectScanner.FileType
|
||||
/// <summary>
|
||||
/// New executable (NE)
|
||||
/// </summary>
|
||||
public class NewExecutable : Executable<SabreTools.Serialization.Wrappers.NewExecutable>
|
||||
public class NewExecutable : Executable<SabreTools.Serialization.Wrappers.NewExecutable>, IExtractable
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public NewExecutable(SabreTools.Serialization.Wrappers.NewExecutable? wrapper) : base(wrapper) { }
|
||||
@@ -47,7 +47,17 @@ namespace BinaryObjectScanner.FileType
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
|
||||
public bool Extract(string file, string outDir, bool includeDebug)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
return false;
|
||||
|
||||
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
return Extract(fs, file, outDir, includeDebug);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
|
||||
{
|
||||
// Create the wrapper
|
||||
var wrapper = WrapperFactory.CreateExecutableWrapper(stream);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BinaryObjectScanner.Data;
|
||||
using BinaryObjectScanner.Interfaces;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
|
||||
namespace BinaryObjectScanner.FileType
|
||||
@@ -8,7 +9,7 @@ namespace BinaryObjectScanner.FileType
|
||||
/// <summary>
|
||||
/// Portable executable (PE)
|
||||
/// </summary>
|
||||
public class PortableExecutable : Executable<SabreTools.Serialization.Wrappers.PortableExecutable>
|
||||
public class PortableExecutable : Executable<SabreTools.Serialization.Wrappers.PortableExecutable>, IExtractable
|
||||
{
|
||||
/// <inheritdoc/>
|
||||
public PortableExecutable(SabreTools.Serialization.Wrappers.PortableExecutable? wrapper) : base(wrapper) { }
|
||||
@@ -46,7 +47,17 @@ namespace BinaryObjectScanner.FileType
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
|
||||
public bool Extract(string file, string outDir, bool includeDebug)
|
||||
{
|
||||
if (!File.Exists(file))
|
||||
return false;
|
||||
|
||||
using var fs = File.Open(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
return Extract(fs, file, outDir, includeDebug);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool Extract(Stream? stream, string file, string outDir, bool includeDebug)
|
||||
{
|
||||
// Create the wrapper
|
||||
var wrapper = WrapperFactory.CreateExecutableWrapper(stream);
|
||||
|
||||
Reference in New Issue
Block a user