1
0
Fork 0
mirror of https://github.com/atom0s/Steamless.git synced 2024-12-19 23:07:41 +01:00

Core: Added Steamless.CLI to run Steamless from the command line.

Core: Bumped version to 3.0.0.15
This commit is contained in:
atom0s 2022-04-04 21:37:35 -07:00
parent 9adc76d6da
commit 62ffbe6732
No known key found for this signature in database
GPG key ID: 37D5FD3494D79AF8
7 changed files with 373 additions and 2 deletions

6
Steamless.CLI/App.config Normal file
View file

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>

250
Steamless.CLI/Program.cs Normal file
View file

@ -0,0 +1,250 @@
/**
* Steamless - Copyright (c) 2015 - 2022 atom0s [atom0s@live.com]
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
*
* By using Steamless, you agree to the above license and its terms.
*
* Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were
* made. You must do so in any reasonable manner, but not in any way that suggests the licensor
* endorses you or your use.
*
* Non-Commercial - You may not use the material (Steamless) for commercial purposes.
*
* No-Derivatives - If you remix, transform, or build upon the material (Steamless), you may not distribute the
* modified material. You are, however, allowed to submit the modified works back to the original
* Steamless project in attempt to have it added to the original project.
*
* You may not apply legal terms or technological measures that legally restrict others
* from doing anything the license permits.
*
* No warranties are given.
*/
namespace Steamless.CLI
{
using Steamless.API;
using Steamless.API.Events;
using Steamless.API.Model;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
internal class Program
{
/// <summary>
/// Steamless API Version
///
/// Main define for this is within DataService.cs and should match that value.
/// </summary>
private static readonly Version SteamlessApiVersion = new Version(1, 0);
/// <summary>
/// Steamless logging service.
/// </summary>
private static readonly API.Services.LoggingService LoggingService = new API.Services.LoggingService();
/// <summary>
/// Prints the Steamless header information.
/// </summary>
static void PrintHeader()
{
Console.WriteLine(" _________ __ .__ ");
Console.WriteLine(" / _____// |_ ____ _____ _____ | | ____ ______ ______");
Console.WriteLine(" \\_____ \\\\ __\\/ __ \\\\__ \\ / \\| | _/ __ \\ / ___// ___/");
Console.WriteLine(" / \\| | \\ ___/ / __ \\| Y Y \\ |_\\ ___/ \\___ \\ \\___ \\ ");
Console.WriteLine("/_______ /|__| \\___ >____ /__|_| /____/\\___ >____ >____ >");
Console.WriteLine(" \\/ \\/ \\/ \\/ \\/ \\/ \\/ \n");
Console.WriteLine("Steamless - SteamStub DRM Remover");
Console.WriteLine("by atom0s\n");
Console.WriteLine("GitHub : https://github.com/atom0s/Steamless");
Console.WriteLine("Homepage : https://atom0s.com");
Console.WriteLine("Donations : https://paypal.me/atom0s");
Console.WriteLine("Donations : https://github.com/sponsors/atom0s");
Console.WriteLine("Donations : https://patreon.com/atom0s\n");
}
/// <summary>
/// Prints the Steamless command line help information.
/// </summary>
static void PrintHelp()
{
Console.WriteLine("Usage:");
Console.WriteLine(" Steamless.CLI.exe [options] [file]\n");
Console.WriteLine("Options:");
Console.WriteLine(" --quiet");
Console.WriteLine(" --keepbind - Keeps the .bind section in the unpacked file.");
Console.WriteLine(" --keepstub - Keeps the DOS stub in the unpacked file.");
Console.WriteLine(" --dumppayload - Dumps the stub payload to disk.");
Console.WriteLine(" --dumpdrmp - Dumps the SteamDRMP.dll to disk.");
Console.WriteLine(" --realign - Realigns the unpacked file sections.");
Console.WriteLine(" --recalcchecksum - Recalculates the unpacked file checksum.");
Console.WriteLine(" --exp - Use experimental features.");
}
/// <summary>
/// Obtains a list of available Steamless plugins.
/// </summary>
/// <returns></returns>
static List<SteamlessPlugin> GetSteamlessPlugins()
{
try
{
// The list of valid plugins..
var plugins = new List<SteamlessPlugin>();
// Build a path to the plugins folder..
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Plugins");
// Loop the DLL files and attempt to load them..
foreach (var dll in Directory.GetFiles(path, "*.dll"))
{
// Skip the Steamless.API.dll file..
if (dll.ToLower().Contains("steamless.api.dll"))
continue;
try
{
// Load the assembly..
var asm = Assembly.Load(File.ReadAllBytes(dll));
// Locate the class inheriting the plugin base..
var baseClass = asm.GetTypes().SingleOrDefault(t => t.BaseType == typeof(SteamlessPlugin));
if (baseClass == null)
continue;
// Locate the SteamlessApiVersion attribute on the base class..
var baseAttr = baseClass.GetCustomAttributes(typeof(SteamlessApiVersionAttribute), false);
if (baseAttr.Length == 0)
continue;
// Validate the interface version..
var apiVersion = (SteamlessApiVersionAttribute)baseAttr[0];
if (apiVersion.Version != SteamlessApiVersion)
continue;
// Create an instance of the plugin..
var plugin = (SteamlessPlugin)Activator.CreateInstance(baseClass);
if (!plugin.Initialize(LoggingService))
continue;
plugins.Add(plugin);
}
catch
{
}
}
// Order the plugins by their name..
return plugins.OrderBy(p => p.Name).ToList();
}
catch
{
return new List<SteamlessPlugin>();
}
}
/// <summary>
/// Application entry point.
/// </summary>
/// <param name="args"></param>
static int Main(string[] args)
{
PrintHeader();
var opts = new SteamlessOptions();
var file = string.Empty;
// Process command line arguments for the various Steamless options..
foreach (var arg in args)
{
if (arg.ToLower() == "--quiet")
opts.VerboseOutput = false;
if (arg.ToLower() == "--keepbind")
opts.KeepBindSection = true;
if (arg.ToLower() == "--keepstub")
opts.ZeroDosStubData = false;
if (arg.ToLower() == "--dumppayload")
opts.DumpPayloadToDisk = true;
if (arg.ToLower() == "--dumpdrmp")
opts.DumpSteamDrmpToDisk = true;
if (arg.ToLower() == "--realign")
opts.DontRealignSections = false;
if (arg.ToLower() == "--recalcchecksum")
opts.RecalculateFileChecksum = true;
if (arg.ToLower() == "--exp")
opts.UseExperimentalFeatures = true;
if (!arg.StartsWith("--"))
file = arg;
}
// Prepare the logging service..
LoggingService.AddLogMessage += (sender, e) =>
{
if (!opts.VerboseOutput && e.MessageType == LogMessageType.Debug)
return;
try
{
if (sender != null)
e.Message = $"[{sender.GetType().Assembly.GetName().Name}] {e.Message}";
else
e.Message = $"[Steamless] {e.Message}";
}
catch
{
}
Console.WriteLine(e.Message);
};
// Ensure an input file was given..
if (string.IsNullOrEmpty(file))
{
PrintHelp();
return 1;
}
// Ensure the input file exists..
if (!File.Exists(file))
{
LoggingService.OnAddLogMessage(null, new LogMessageEventArgs("Invalid input file given; cannot continue.", LogMessageType.Error));
return 1;
}
// Collect the list of available plugins..
var plugins = GetSteamlessPlugins();
plugins.ForEach(p => LoggingService.OnAddLogMessage(null, new LogMessageEventArgs($"Loaded plugin: {p.Name} - by {p.Author} (v.{p.Version})", LogMessageType.Success)));
// Ensure plugins were found and loaded..
if (plugins.Count == 0)
{
LoggingService.OnAddLogMessage(null, new LogMessageEventArgs("No plugins were loaded; be sure to fully extract Steamless before running!", LogMessageType.Error));
return 1;
}
// Loop through the plugins and try to unpack the file..
foreach (var p in plugins)
{
// Check if the plugin can process the file..
if (p.CanProcessFile(file))
{
var ret = p.ProcessFile(file, opts);
LoggingService.OnAddLogMessage(null, !ret
? new LogMessageEventArgs("Failed to unpack file.", LogMessageType.Error)
: new LogMessageEventArgs("Successfully unpacked file!", LogMessageType.Success));
if (ret) return 0;
}
}
LoggingService.OnAddLogMessage(null, new LogMessageEventArgs("All unpackers failed to unpack file.", LogMessageType.Error));
return 1;
}
}
}

View file

@ -0,0 +1,40 @@
/**
* Steamless - Copyright (c) 2015 - 2022 atom0s [atom0s@live.com]
*
* This work is licensed under the Creative Commons Attribution-NonCommercial-NoDerivatives 4.0 International License.
* To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/ or send a letter to
* Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.
*
* By using Steamless, you agree to the above license and its terms.
*
* Attribution - You must give appropriate credit, provide a link to the license and indicate if changes were
* made. You must do so in any reasonable manner, but not in any way that suggests the licensor
* endorses you or your use.
*
* Non-Commercial - You may not use the material (Steamless) for commercial purposes.
*
* No-Derivatives - If you remix, transform, or build upon the material (Steamless), you may not distribute the
* modified material. You are, however, allowed to submit the modified works back to the original
* Steamless project in attempt to have it added to the original project.
*
* You may not apply legal terms or technological measures that legally restrict others
* from doing anything the license permits.
*
* No warranties are given.
*/
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Steamless.CLI")]
[assembly: AssemblyDescription("Removes the SteamStub DRM protection from Steam applications.")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCompany("atom0s")]
[assembly: AssemblyProduct("Steamless")]
[assembly: AssemblyCopyright("Copyright © atom0s 2015 - 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("d128d7ad-2e6f-43bd-ba36-bea3b9b77437")]
[assembly: AssemblyVersion("3.0.0.15")]
[assembly: AssemblyFileVersion("3.0.0.15")]

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Steamless.CLI</RootNamespace>
<AssemblyName>Steamless.CLI</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\Steamless\bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\Steamless\bin\x86\Debug\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>steam.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Steamless.API\Steamless.API.csproj">
<Project>{56c95629-3b34-47fe-b988-04274409294f}</Project>
<Name>Steamless.API</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="steam.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

BIN
Steamless.CLI/steam.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

View file

@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steamless.Unpacker.Variant2
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steamless.Unpacker.Variant10.x86", "Steamless.Unpacker.Variant10.x86\Steamless.Unpacker.Variant10.x86.csproj", "{02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steamless.Unpacker.Variant10.x86", "Steamless.Unpacker.Variant10.x86\Steamless.Unpacker.Variant10.x86.csproj", "{02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Steamless.CLI", "Steamless.CLI\Steamless.CLI.csproj", "{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -111,6 +113,14 @@ Global
{02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|Any CPU.Build.0 = Release|Any CPU {02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|Any CPU.Build.0 = Release|Any CPU
{02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|x86.ActiveCfg = Release|Any CPU {02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|x86.ActiveCfg = Release|Any CPU
{02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|x86.Build.0 = Release|Any CPU {02B58AB0-9B00-4B31-8D61-9D22D13D2C4A}.Release|x86.Build.0 = Release|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Debug|x86.ActiveCfg = Debug|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Debug|x86.Build.0 = Debug|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Release|Any CPU.Build.0 = Release|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Release|x86.ActiveCfg = Release|Any CPU
{D128D7AD-2E6F-43BD-BA36-BEA3B9B77437}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View file

@ -37,5 +37,5 @@ using System.Windows;
[assembly: AssemblyCulture("")] [assembly: AssemblyCulture("")]
[assembly: ComVisible(false)] [assembly: ComVisible(false)]
[assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
[assembly: AssemblyVersion("3.0.0.14")] [assembly: AssemblyVersion("3.0.0.15")]
[assembly: AssemblyFileVersion("3.0.0.14")] [assembly: AssemblyFileVersion("3.0.0.15")]