public void Run(Int32 gameProcessID, FileInfo runner, DalamudStartInfo startInfo, DirectoryInfo gamePath, DalamudLoadMethod loadMethod) { // Wine wants Windows paths here, so we need to fix up the startinfo dirs startInfo.WorkingDirectory = compatibility.UnixToWinePath(startInfo.WorkingDirectory); startInfo.ConfigurationPath = compatibility.UnixToWinePath(startInfo.ConfigurationPath); startInfo.PluginDirectory = compatibility.UnixToWinePath(startInfo.PluginDirectory); startInfo.DefaultPluginDirectory = compatibility.UnixToWinePath(startInfo.DefaultPluginDirectory); startInfo.AssetDirectory = compatibility.UnixToWinePath(startInfo.AssetDirectory); switch (loadMethod) { case DalamudLoadMethod.EntryPoint: throw new NotImplementedException(); break; case DalamudLoadMethod.DllInject: { var parameters = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo))); var launchArguments = new string[] { runner.FullName, gameProcessID.ToString(), parameters }; var environment = new Dictionary <string, string>(); environment.Add("DALAMUD_RUNTIME", compatibility.UnixToWinePath(dotnetRuntime.FullName)); compatibility.RunInPrefix(launchArguments, environment: environment); break; } default: // should not reach throw new ArgumentOutOfRangeException(); } }
public object?Start(string path, string workingDirectory, string arguments, IDictionary <string, string> environment, DpiAwareness dpiAwareness) { var wineHelperPath = Path.Combine(AppContext.BaseDirectory, "Resources", "binaries", "DalamudWineHelper.exe"); var helperCopy = this.storage.GetFile("DalamudWineHelper.exe"); if (!helperCopy.Exists) { File.Copy(wineHelperPath, helperCopy.FullName); } var launchArguments = new string[] { helperCopy.FullName, path, arguments }; environment.Add("DALAMUD_RUNTIME", compatibility.UnixToWinePath(dotnetRuntime.FullName)); var process = compatibility.RunInPrefix(launchArguments, workingDirectory, environment); Int32 gameProcessId = 0; Log.Verbose("Trying to get game pid via winedbg..."); while (gameProcessId == 0) { Thread.Sleep(50); var allGamePids = new HashSet <Int32>(compatibility.GetProcessIds("ffxiv_dx11.exe")); allGamePids.ExceptWith(RunningPids); gameProcessId = allGamePids.ToArray().FirstOrDefault(); } Log.Verbose("Got game pid: {Pid}", gameProcessId); RunningPids.Add(gameProcessId); if (this.dalamudOk) { Log.Verbose("[UnixGameRunner] Now running DLL inject"); this.dalamudLauncher.Run(gameProcessId); } return(gameProcessId); }