Skip to content

Commit

Permalink
AutomaticPlugin - Added support for logging service usage.
Browse files Browse the repository at this point in the history
AutomaticPlugin - Added detection and logging output to mention if a file is most likely not packed with SteamStub.
Core - Fixed issue with AutomaticPlugin not properly initializing.
Unpacker v2.0 (x86) - Adjusted how the code section RVA is determined. (Moved a second check to 'optional feature' state for now.)
  • Loading branch information
atom0s committed Sep 22, 2022
1 parent 1bdd96e commit b6d445f
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 8 deletions.
9 changes: 7 additions & 2 deletions Steamless.Unpacker.Variant20.x86/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,13 @@ private bool Step2()

// Determine the code section RVA..
var codeSectionRVA = this.File.NtHeaders.OptionalHeader.BaseOfCode;
if (this.StubHeader.CodeSectionVirtualAddress != 0)
codeSectionRVA = this.File.GetRvaFromVa(this.StubHeader.CodeSectionVirtualAddress);

// TODO: This is not really ideal to do but for now this breaks support for other variants of this version..
if (this.Options.UseExperimentalFeatures)
{
if (this.StubHeader.CodeSectionVirtualAddress != 0)
codeSectionRVA = this.File.GetRvaFromVa(this.StubHeader.CodeSectionVirtualAddress);
}

// Get the code section..
var codeSection = this.File.GetOwnerSection(codeSectionRVA);
Expand Down
4 changes: 2 additions & 2 deletions Steamless.Unpacker.Variant20.x86/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("4f11f26d-2946-467f-a4e9-9e2a619a1fd3")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.1")]
[assembly: AssemblyFileVersion("1.0.0.1")]
57 changes: 56 additions & 1 deletion Steamless/Model/AutomaticPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ namespace Steamless.Model
{
using API;
using API.Model;
using API.PE32;
using API.PE64;
using API.Services;
using Steamless.API.Events;
using System;
using System.Linq;
using System.Windows;
Expand All @@ -36,6 +39,11 @@ namespace Steamless.Model
[SteamlessApiVersion(1, 0)]
internal class AutomaticPlugin : SteamlessPlugin
{
/// <summary>
/// Internal logging service instance.
/// </summary>
private LoggingService m_LoggingService;

/// <summary>
/// Gets the author of this plugin.
/// </summary>
Expand All @@ -56,13 +64,24 @@ internal class AutomaticPlugin : SteamlessPlugin
/// </summary>
public override Version Version => new Version(1, 0, 0, 0);

/// <summary>
/// Internal wrapper to log a message.
/// </summary>
/// <param name="msg"></param>
/// <param name="type"></param>
private void Log(string msg, LogMessageType type)
{
this.m_LoggingService.OnAddLogMessage(this, new LogMessageEventArgs(msg, type));
}

/// <summary>
/// Initialize function called when this plugin is first loaded.
/// </summary>
/// <param name="logService"></param>
/// <returns></returns>
public override bool Initialize(LoggingService logService)
{
this.m_LoggingService = logService;
return true;
}

Expand Down Expand Up @@ -94,7 +113,43 @@ public override bool ProcessFile(string file, SteamlessOptions options)
return false;

// Query the plugin list for a plugin to process the file..
return (from p in plugins where p != this where p.CanProcessFile(file) select p.ProcessFile(file, options)).FirstOrDefault();
var ret = (from p in plugins where p != this where p.CanProcessFile(file) select p.ProcessFile(file, options)).FirstOrDefault();
if (ret)
return ret;

// Determine if the file was not packed with SteamStub..
try
{
// First attempt to read the file as 32bit..
dynamic f = new Pe32File(file);

if (f.Parse())
{
// Check if the file is 64bit..
if (f.IsFile64Bit())
{
f = new Pe64File(file);
if (!f.Parse())
return false;
}

// Ensure the file had a .bind section..
if (!f.HasSection(".bind"))
{
this.Log("", LogMessageType.Error);
this.Log("This file does not appear to be packed with SteamStub!", LogMessageType.Error);
this.Log("File missing expected '.bind' section!", LogMessageType.Error);
this.Log("", LogMessageType.Error);
return false;
}
}
}
catch
{
return false;
}

return false;
}
}
}
4 changes: 3 additions & 1 deletion Steamless/Model/Tasks/LoadPluginsTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public override Task DoTask()
});
// Add the automatic plugin at the start of the list..
sorted.Insert(0, new AutomaticPlugin());
var auto = new AutomaticPlugin();
auto.Initialize(vml.LoggingService);
sorted.Insert(0, auto);
// Set the plugins..
vml.MainWindow.Plugins = new ObservableCollection<SteamlessPlugin>(sorted);
Expand Down
4 changes: 2 additions & 2 deletions Steamless/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("3.1.0.0")]
[assembly: AssemblyFileVersion("3.1.0.0")]
[assembly: AssemblyVersion("3.1.0.1")]
[assembly: AssemblyFileVersion("3.1.0.1")]

0 comments on commit b6d445f

Please sign in to comment.