public UnixGameRunner(CompatibilityTools compatibility, DalamudLauncher dalamudLauncher, bool dalamudOk, DalamudLoadMethod?loadMethod, DirectoryInfo dotnetRuntime, Storage storage)
 {
     this.compatibility   = compatibility;
     this.dalamudLauncher = dalamudLauncher;
     this.dalamudOk       = dalamudOk;
     this.loadMethod      = loadMethod ?? DalamudLoadMethod.DllInject;
     this.dotnetRuntime   = dotnetRuntime;
     this.storage         = storage;
 }
Example #2
0
 public DalamudLauncher(IDalamudRunner runner, DalamudUpdater updater, DalamudLoadMethod loadMethod, DirectoryInfo gamePath, DirectoryInfo configDirectory, ClientLanguage clientLanguage, int injectionDelay)
 {
     this.runner          = runner;
     this.updater         = updater;
     this.loadMethod      = loadMethod;
     this.gamePath        = gamePath;
     this.configDirectory = configDirectory;
     this.language        = clientLanguage;
     this.injectionDelay  = injectionDelay;
 }
 public WindowsGameRunner(DalamudLauncher dalamudLauncher, bool dalamudOk, DalamudLoadMethod loadMethod)
 {
     this.dalamudLauncher = dalamudLauncher;
     this.dalamudOk       = dalamudOk;
     this.loadMethod      = loadMethod;
 }
    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();
        }
    }
Example #5
0
    public void Run(Int32 gameProcessID, FileInfo runner, DalamudStartInfo startInfo, DirectoryInfo gamePath, DalamudLoadMethod loadMethod)
    {
        var gameProcess = Process.GetProcessById(gameProcessID);

        switch (loadMethod)
        {
        case DalamudLoadMethod.EntryPoint:
            SetDllDirectory(runner.DirectoryName);

            try
            {
                if (0 != RewriteRemoteEntryPointW(gameProcess.Handle,
                                                  Path.Combine(gamePath.FullName, "game", gameProcess.ProcessName + ".exe"),
                                                  JsonConvert.SerializeObject(startInfo)))
                {
                    Log.Error("[HOOKS] RewriteRemoteEntryPointW failed");
                    throw new DalamudRunnerException("RewriteRemoteEntryPointW failed");
                }
            }
            catch (DllNotFoundException ex)
            {
                Log.Error(ex, "[HOOKS] Dalamud entrypoint DLL not found");
                throw new DalamudRunnerException("DLL not found");
            }

            break;

        case DalamudLoadMethod.DllInject:
        {
            var parameters = Convert.ToBase64String(Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(startInfo)));

            var process = new Process
            {
                StartInfo =
                {
                    FileName  = runner.FullName,                   WindowStyle      = ProcessWindowStyle.Hidden, CreateNoWindow = true,
                    Arguments = gameProcess.Id + " " + parameters, WorkingDirectory = runner.DirectoryName !
                }
            };

            process.Start();
            break;
        }

        default:
            // should not reach
            throw new ArgumentOutOfRangeException();
        }
    }