From a7776fe15f41d722100c04d944e19dd8ab509a48 Mon Sep 17 00:00:00 2001 From: AzureGem Date: Sun, 19 Apr 2020 11:23:45 -0400 Subject: [PATCH] Update Dalamud.Injector logic - Added logic determine the game install path from process in case its not installed at the default path (Line 16, 88 and 98) - Made auto-detecting the game's PID (the -1 arg) the default behavior (Line 30-33) - Added a check to ensure the PID argugemt exist (Line 31) - Fixed check to ensure for start info argument exist (Line 51) - Added missing code to display the base64 encoded start info argument to include (Line 56) --- Dalamud.Injector/Program.cs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Dalamud.Injector/Program.cs b/Dalamud.Injector/Program.cs index d25243c8e..ffd612034 100644 --- a/Dalamud.Injector/Program.cs +++ b/Dalamud.Injector/Program.cs @@ -13,6 +13,8 @@ using Newtonsoft.Json; namespace Dalamud.Injector { internal static class Program { + static private Process process = null; + private static void Main(string[] args) { #if !DEBUG AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs eventArgs) @@ -25,9 +27,10 @@ namespace Dalamud.Injector { }; #endif - var pid = int.Parse(args[0]); - - Process process = null; + var pid = -1; + if (args.Length == 1) { + pid = int.Parse(args[0]); + } switch (pid) { case -1: @@ -45,10 +48,12 @@ namespace Dalamud.Injector { } DalamudStartInfo startInfo; - if (args.Length == 1) { + if (args.Length <= 1) { startInfo = GetDefaultStartInfo(); Console.WriteLine("\nA Dalamud start info was not found in the program arguments. One has been generated for you."); Console.WriteLine("\nCopy the following contents into the program arguments:"); + Console.WriteLine(); + Console.WriteLine(Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo)))); } else { startInfo = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(Convert.FromBase64String(args[1]))); } @@ -80,6 +85,7 @@ namespace Dalamud.Injector { } private static DalamudStartInfo GetDefaultStartInfo() { + var ffxivDir = Path.GetDirectoryName(process.MainModule.FileName); var startInfo = new DalamudStartInfo { WorkingDirectory = null, ConfigurationPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @@ -89,7 +95,7 @@ namespace Dalamud.Injector { DefaultPluginDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\devPlugins", - GameVersion = File.ReadAllText(@"C:\Program Files (x86)\SquareEnix\FINAL FANTASY XIV - A Realm Reborn\game\ffxivgame.ver"), + GameVersion = File.ReadAllText(Path.Combine(ffxivDir, "ffxivgame.ver")), Language = ClientLanguage.English };