Skip to content

Commit

Permalink
Fix typos and in-place patching
Browse files Browse the repository at this point in the history
  • Loading branch information
valters-tomsons committed Apr 19, 2023
1 parent 2c7a5cc commit 2a0741f
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions DayZLauncher.UnixPatcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class Program
{
static void Main(string[] args)
{
if (args.Length != 1 || Directory.Exists(args[0]))
if (args.Length != 1 || !Directory.Exists(args[0]))
{
Console.WriteLine("Must provide path to DayZ installation folder as argument!");
Console.ReadKey();
Expand All @@ -21,15 +21,22 @@ static void Main(string[] args)
var targetAssembly = @$"{args[0].Trim()}\Launcher\Utils.dll";
if (!File.Exists(targetAssembly))
{
Console.WriteLine("Could not find Launcher/Utils.dll in target folder!");
Console.WriteLine(@"Could not find 'Launcher\Utils.dll' in target folder!");
Console.ReadKey();
return;
}

var patchAssembly = "DayZLauncher.UnixPatcher.Utils.dll";
var backupAssembly = targetAssembly + ".bak";

if (File.Exists(backupAssembly))
{
File.Delete(backupAssembly);
}

File.Move(targetAssembly, targetAssembly + ".bak");

var patchAssembly = "DayZLauncher.UnixPatcher.Utils.dll";

using var patchDefinition = AssemblyDefinition.ReadAssembly(patchAssembly);
var unixJunctionsType = patchDefinition.MainModule.GetType("DayZLauncher.UnixPatcher.Utils.UnixJunctions");

Expand All @@ -46,7 +53,7 @@ static void Main(string[] args)
Console.WriteLine("Writing patches to disk...");

targetDefinition.Write(targetAssembly);
File.Copy("DayZLauncher.UnixPatcher.Utils.dll", @$"{args[0].Trim()}\Launcher\DayZLauncher.UnixPatcher.Utils.dll");
File.Copy("DayZLauncher.UnixPatcher.Utils.dll", @$"{args[0].Trim()}\Launcher\DayZLauncher.UnixPatcher.Utils.dll", true);

Console.WriteLine("Patch applied!");
Console.ReadKey();
Expand Down

0 comments on commit 2a0741f

Please sign in to comment.