Skip to content

Commit

Permalink
Added option for CLI to keep scanning for processes
Browse files Browse the repository at this point in the history
Fixed issue where legacy GUI also has a console
  • Loading branch information
LennardF1989 committed Jun 29, 2024
1 parent 17da414 commit a48831c
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 70 deletions.
6 changes: 6 additions & 0 deletions patcher/HitmanPatcher.CLI/Cli.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ internal class CliOptions

internal bool? OptionalDynRes { get; set; }

internal bool? KeepScanning { get; set; }

internal static CliOptions FromArguments(string[] args)
{
var options = new CliOptions();
Expand Down Expand Up @@ -53,13 +55,17 @@ internal static CliOptions FromArguments(string[] args)
case "--use-http":
options.UseHttp = true;
break;
case "--keep-scanning":
options.KeepScanning = true;
break;
case "--help":
Console.WriteLine(CliLocale.HelpHeader);
Console.WriteLine("");
Console.WriteLine("Options:");
Console.WriteLine($" --optional-dynamic-resources : {CliLocale.OptionalDynResDescription}");
Console.WriteLine($" --domain <url> : {CliLocale.DomainDescription}");
Console.WriteLine($" --use-http : {CliLocale.UseHttpDescription}");
Console.WriteLine($" --keep-scanning : {CliLocale.KeepScanning}");
Environment.Exit(0);
break;
}
Expand Down
12 changes: 6 additions & 6 deletions patcher/HitmanPatcher.CLI/CliLocale.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

187 changes: 134 additions & 53 deletions patcher/HitmanPatcher.CLI/CliLocale.resx
Original file line number Diff line number Diff line change
@@ -1,57 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>

<!--
- The Peacock Project - a HITMAN server replacement.
- Copyright (C) 2021-2024 The Peacock Project Team
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->

<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">

</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="HeadlessDescription" xml:space="preserve">
<value>If the patcher should be run without the GUI.</value>
</data>
<data name="DomainDescription" xml:space="preserve">
<value>The domain for the game to connect to.</value>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="UseHttpDescription" xml:space="preserve">
<value>If the game should connect using "http://" instead of the default, "https://".</value>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
<data name="OptionalDynResDescription" xml:space="preserve">
<value>If the game should not force the user offline if the dynamic resources are missing or invalid.</value>
</data>
<data name="HeadlessBanner" xml:space="preserve">
<value>====== Peacock Patcher - Headless mode ======</value>
</data>
<data name="HelpHeader" xml:space="preserve">
<value>Peacock Patcher CLI - Copyright (c) 2020-2024 grappigegovert &amp; The Peacock Project</value>
</data>
</root>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="KeepScanning" xml:space="preserve">
<value>If the patcher should keep scanning for processes after patching.</value>
</data>
<data name="DomainDescription" xml:space="preserve">
<value>The domain for the game to connect to.</value>
</data>
<data name="UseHttpDescription" xml:space="preserve">
<value>If the game should connect using "http://" instead of the default, "https://".</value>
</data>
<data name="OptionalDynResDescription" xml:space="preserve">
<value>If the game should not force the user offline if the dynamic resources are missing or invalid.</value>
</data>
<data name="HeadlessBanner" xml:space="preserve">
<value>====== Peacock Patcher - Headless mode ======</value>
</data>
<data name="HelpHeader" xml:space="preserve">
<value>Peacock Patcher CLI - Copyright (c) 2020-2024 grappigegovert &amp; The Peacock Project</value>
</data>
</root>
20 changes: 10 additions & 10 deletions patcher/HitmanPatcher.CLI/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ private static void Main(string[] args)
Console.WriteLine($"- DisableForceDynamicResources = {settings.patchOptions.DisableForceOfflineOnFailedDynamicResources}");
Console.WriteLine();

bool result = false;
// Set the active values
settings.patchOptions.CustomConfigDomain = o.Domain ?? settings.patchOptions.CustomConfigDomain;
settings.patchOptions.DisableForceOfflineOnFailedDynamicResources = o.OptionalDynRes ?? settings.patchOptions.DisableForceOfflineOnFailedDynamicResources;
settings.patchOptions.UseHttp = o.UseHttp ?? settings.patchOptions.UseHttp;

while(!result)
var keepScanning = o.KeepScanning ?? false;

while (true)
{
result = MemoryPatcher.PatchAllProcesses(Compositions.Logger, settings.patchOptions with
{
CustomConfigDomain = o.Domain ?? settings.patchOptions.CustomConfigDomain,
DisableForceOfflineOnFailedDynamicResources = o.OptionalDynRes ?? settings.patchOptions.DisableForceOfflineOnFailedDynamicResources,
UseHttp = o.UseHttp ?? settings.patchOptions.UseHttp
});
var result = MemoryPatcher.PatchAllProcesses(Compositions.Logger, settings.patchOptions);

if (result)
if (result && !keepScanning)
{
continue;
break;
}

Console.WriteLine("Waiting...");
Expand Down
2 changes: 1 addition & 1 deletion patcher/HitmanPatcher.UI/ILRepack.targets
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<ILRepack
InputAssemblies="@(InputAssemblies)"
TargetKind="Exe"
TargetKind="WinExe"
OutputFile="$(PublishDir)\ILRepack\PeacockPatcher.UI.exe" />
</Target>
</Project>

0 comments on commit a48831c

Please sign in to comment.