From 5aed3d615a589d12bb367fc573eb93e7ad68a67e Mon Sep 17 00:00:00 2001 From: liam Date: Sun, 16 Feb 2020 19:51:10 -0500 Subject: [PATCH] automatic default StartInfo creation if not found --- Dalamud.Injector/Program.cs | 38 +++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/Dalamud.Injector/Program.cs b/Dalamud.Injector/Program.cs index 5db47c2dd..d40e52170 100644 --- a/Dalamud.Injector/Program.cs +++ b/Dalamud.Injector/Program.cs @@ -42,9 +42,17 @@ namespace Dalamud.Injector { break; } + if (args.Length == 1) { + var defaultStartInfo = 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(defaultStartInfo); + return; + } + var startInfo = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(Convert.FromBase64String(args[1]))); startInfo.WorkingDirectory = Directory.GetCurrentDirectory(); - + // Seems to help with the STATUS_INTERNAL_ERROR condition Thread.Sleep(1000); @@ -63,8 +71,34 @@ namespace Dalamud.Injector { } RemoteHooking.Inject(process.Id, InjectionOptions.DoNotRequireStrongName, libPath, libPath, info); - + Console.WriteLine("Injected"); } + + private static string GetDefaultStartInfo() { + DalamudStartInfo startInfo = new DalamudStartInfo(); + + startInfo.WorkingDirectory = null; + + startInfo.ConfigurationPath = + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + + @"\XIVLauncher\dalamudConfig.json"; + + startInfo.PluginDirectory = + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\plugins"; + + startInfo.DefaultPluginDirectory = + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + @"\XIVLauncher\defaultplugins"; + + startInfo.Language = ClientLanguage.English; + + Console.WriteLine("Creating a StartInfo with:\n" + + $"ConfigurationPath: {startInfo.ConfigurationPath}\n" + + $"PluginDirectory: {startInfo.PluginDirectory}\n" + + $"DefaultPluginDirectory: {startInfo.DefaultPluginDirectory}\n" + + $"Language: {startInfo.Language}"); + + return Convert.ToBase64String(Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(startInfo))); + } } }