예제 #1
0
        static void Main()
        {
            // Mutex
            Mutex self = new Mutex(true, Application.StartupPath.GetHashCode().ToString(), out bool allow);

            if (!allow)
            {
                MessageBox.Show("已有一个CSI在运行中了 ...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(-1);
            }

            // Load local native
            Logging.Initialize();

            // Load native steam binaries.
            SteamNative.Initialize();

            // Check steam is running
            if (!SteamApi.IsSteamRunning())
            {
                MessageBox.Show("请先运行Steam客户端.", "EZConfig4CSGO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            // Provide appId so it automatically creates a "steam_appid.txt" file.
            if (!SteamApi.Initialize(AppId))
            {
                MessageBox.Show("初始化SteamApi失败.", "EZConfig4CSGO", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new MainForm());
        }
예제 #2
0
        private static void Main(string[] args)
        {
            const int appId = 480;

            // Load native steam binaries.
            SteamNative.Initialize();

            // Use steam stuff.
            if (SteamApi.IsSteamRunning())
            {
                // Provide appId so it automatically creates a "steam_appid.txt" file.
                if (SteamApi.Initialize(appId))
                {
                    Console.WriteLine($"Logged in as: {SteamApi.SteamFriends.GetPersonaName()}");
                }
                else
                {
                    Console.WriteLine("SteamApi failed to initialize.");
                }
            }
            else
            {
                Console.WriteLine("Steam is not running.");
            }

            Console.WriteLine("Press any key to exit.");
            Console.ReadKey();
        }
예제 #3
0
        static void Main(string[] args)
        {
            JObject settings = JObject.Parse(File.ReadAllText("settings.txt"));

            Console.CursorVisible = false;
            Console.Title         = "DS3 Connection Info V3.3";

            SteamNative.Initialize();
            mem = new MemoryManager();

            Console.WriteLine("Dark Souls III: Closed");
            do
            {
                try { mem.OpenProcess("DarkSoulsIII"); }
                catch { }
                Thread.Sleep(2000);
            } while (mem.ProcHandle == IntPtr.Zero);

            if (!SteamApi.Initialize(374320))
            {
                Console.WriteLine("ERROR: Could not initalize SteamAPI.");
                Console.Read();
                return;
            }

            ETWPingMonitor.Start();

            if ((bool)settings["overlay"])
            {
                Overlay.Enable(settings);
            }


            Console.Clear();
            while (!mem.HasExited)
            {
                Player.UpdatePlayerList();
                Player.UpdateInGameInfo(mem.Process);
                PrintConnInfo();

                Thread.Sleep(1000);
            }

            Overlay.Disable();
            ETWPingMonitor.Stop();
        }
예제 #4
0
        /// <summary>
        /// Launches FFXIV with the supplied parameters.
        /// </summary>
        /// <param name="realsid">Real SessionID</param>
        /// <param name="language">language(0=japanese,1=english,2=french,3=german)</param>
        /// <param name="dx11">Runs the game in dx11 mode if true</param>
        /// <param name="steam">Initializes Steam library if true</param>
        /// <param name="expansionlevel">current level of expansions loaded(0=ARR/default,1=Heavensward)</param>
        public static void LaunchGame(string realsid, int language, bool dx11, bool steam, int expansionlevel)
        {
            try
            {
                if (steam)
                {
                    SteamNative.Initialize();

                    if (SteamApi.IsSteamRunning())
                    {
                        SteamApi.Initialize(39210);
                    }
                }

                Process ffxivgame = new Process();
                if (dx11)
                {
                    ffxivgame.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv_dx11.exe";
                }
                else
                {
                    ffxivgame.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv.exe";
                }
                ffxivgame.StartInfo.Arguments = $"DEV.TestSID={realsid} DEV.MaxEntitledExpansionID={expansionlevel} language={language} region=1";
                ffxivgame.Start();

                if (steam)
                {
                    SteamApi.Uninitialize();
                    SteamNative.Uninitialize();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("Could not launch executable. Is your game path correct?\n\n" + exc, "Launch failed", MessageBoxButtons.OK);
            }
        }
예제 #5
0
        private static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments,
                                          bool closeMutants = false)
        {
            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId))
                        {
                            Log.Information("Steam initialized.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var game = new Process {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardError  = false,
                        RedirectStandardInput  = false,
                        RedirectStandardOutput = false
                    }
                };

                if (Settings.IsDX11())
                {
                    game.StartInfo.FileName = Settings.GamePath + "/game/ffxiv_dx11.exe";
                }
                else
                {
                    game.StartInfo.FileName = Settings.GamePath + "/game/ffxiv.exe";
                }

                game.StartInfo.Arguments =
                    $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) Settings.GetLanguage()} ver={GetLocalGameVer()}";
                game.StartInfo.Arguments += " " + additionalArguments;

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    game.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    game.StartInfo.Arguments += " IsSteam=1";
                }

                /*
                 * var ticks = (uint) Environment.TickCount;
                 * var key = ticks & 0xFFF0_0000;
                 *
                 * var argumentBuilder = new ArgumentBuilder()
                 *  .Append("T", ticks.ToString())
                 *  .Append("DEV.DataPathType", "1")
                 *  .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                 *  .Append("DEV.TestSID", sessionId)
                 *  .Append("DEV.UseSqPack", "1")
                 *  .Append("SYS.Region", region.ToString())
                 *  .Append("language", ((int) Settings.GetLanguage()).ToString())
                 *  .Append("ver", GetLocalGameVer());
                 *
                 * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key);
                 */

                game.StartInfo.WorkingDirectory = Path.Combine(Settings.GamePath.FullName, "game");

                game.Start();

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    if (closeMutants)
                    {
                        CloseMutants(game);
                    }
                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                                "XG LaunchGame").ShowDialog();
            }

            return(null);
        }
예제 #6
0
        public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language,
                                         bool closeMutants = false)
        {
            Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId))
                        {
                            Log.Information("Steam initialized.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var nativeLauncher = new Process {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardError  = false,
                        RedirectStandardInput  = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow         = true
                    }
                };

                var exePath = gamePath + "/game/ffxiv_dx11.exe";
                if (!isDx11)
                {
                    exePath = gamePath + "/game/ffxiv.exe";
                }

                if (!File.Exists("NativeLauncher.exe"))
                {
                    MessageBox.Show(
                        "Your Anti-Virus may have deleted a file necessary for XIVLauncher to function.\nPlease check its logs and reinstall XIVLauncher.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                nativeLauncher.StartInfo.FileName = "NativeLauncher.exe";

                nativeLauncher.StartInfo.Arguments =
                    $"\"{exePath}\" \"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) language} ver={GetLocalGameVer(gamePath)} {additionalArguments}";

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    nativeLauncher.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    nativeLauncher.StartInfo.Arguments += " IsSteam=1";
                }

                nativeLauncher.StartInfo.Arguments += "\"";

                /*
                 * var ticks = (uint) Environment.TickCount;
                 * var key = ticks & 0xFFF0_0000;
                 *
                 * var argumentBuilder = new ArgumentBuilder()
                 *  .Append("T", ticks.ToString())
                 *  .Append("DEV.DataPathType", "1")
                 *  .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                 *  .Append("DEV.TestSID", sessionId)
                 *  .Append("DEV.UseSqPack", "1")
                 *  .Append("SYS.Region", region.ToString())
                 *  .Append("language", ((int) Settings.GetLanguage()).ToString())
                 *  .Append("ver", GetLocalGameVer());
                 *
                 * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key);
                 */

                nativeLauncher.StartInfo.WorkingDirectory = Path.Combine(gamePath.FullName, "game");

                nativeLauncher.Start();
                if (!nativeLauncher.WaitForExit(10000))
                {
                    MessageBox.Show(
                        "Could not start the game correctly. Please report this error.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                var pidStr = nativeLauncher.StandardOutput.ReadToEnd();

                if (!int.TryParse(pidStr, out var gamePid))
                {
                    MessageBox.Show(
                        "Could not start the game correctly. Please report this error.\n\n" + pidStr, "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }

                var game = Process.GetProcessById(gamePid);

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    if (closeMutants)
                    {
                        CloseMutants(game);
                    }
                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                                "XG LaunchGame").ShowDialog();
            }

            return(null);
        }
예제 #7
0
        private static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteam, bool closeMutants = false)
        {
            try
            {
                if (isSteam)
                {
                    SteamNative.Initialize();

                    if (SteamApi.IsSteamRunning() && SteamApi.Initialize(SteamAppId))
                    {
                        Serilog.Log.Information("Steam initialized.");
                    }
                }

                var game = new Process();
                if (Settings.IsDX11())
                {
                    game.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv_dx11.exe";
                }
                else
                {
                    game.StartInfo.FileName = Settings.GetGamePath() + "/game/ffxiv.exe";
                }
                game.StartInfo.Arguments = $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int)Settings.GetLanguage()} ver={GetLocalGameVer()}";

                /*
                 * var ticks = (uint) Environment.TickCount;
                 * var key = ticks & 0xFFF0_0000;
                 *
                 * var argumentBuilder = new ArgumentBuilder()
                 *  .Append("T", ticks.ToString())
                 *  .Append("DEV.DataPathType", "1")
                 *  .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                 *  .Append("DEV.TestSID", sessionId)
                 *  .Append("DEV.UseSqPack", "1")
                 *  .Append("SYS.Region", region.ToString())
                 *  .Append("language", ((int) Settings.GetLanguage()).ToString())
                 *  .Append("ver", GetLocalGameVer());
                 *
                 * game.StartInfo.Arguments = argumentBuilder.BuildEncrypted(key);
                 */

                game.StartInfo.WorkingDirectory = Path.Combine(Settings.GetGamePath(), "game");

                game.Start();
                //Serilog.Log.Information("Starting game process with key ({1}): {0}", argumentBuilder.Build(), key);

                if (isSteam)
                {
                    SteamApi.Uninitialize();
                    SteamNative.Uninitialize();
                }

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    if (closeMutants)
                    {
                        CloseMutants(game);
                    }
                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.", "XG LaunchGame").Show();
            }

            return(null);
        }
예제 #8
0
        public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language,
                                         bool encryptArguments)
        {
            Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(STEAM_APP_ID))
                        {
                            Log.Information("Steam initialized.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var exePath = gamePath + "/game/ffxiv_dx11.exe";
                if (!isDx11)
                {
                    exePath = gamePath + "/game/ffxiv.exe";
                }

                var environment = new Dictionary <string, string>();

                var argumentBuilder = new ArgumentBuilder()
                                      .Append("DEV.DataPathType", "1")
                                      .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                                      .Append("DEV.TestSID", sessionId)
                                      .Append("DEV.UseSqPack", "1")
                                      .Append("SYS.Region", region.ToString())
                                      .Append("language", ((int)language).ToString())
                                      .Append("ver", Repository.Ffxiv.GetVer(gamePath));

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    argumentBuilder.Append("IsSteam", "1");
                }

                // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure
                if (!string.IsNullOrEmpty(additionalArguments))
                {
                    var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled);
                    foreach (Match match in regex.Matches(additionalArguments))
                    {
                        argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value);
                    }
                }


                var workingDir = Path.Combine(gamePath.FullName, "game");

                Process game;
                try
                {
                    var arguments = encryptArguments
                        ? argumentBuilder.BuildEncrypted()
                        : argumentBuilder.Build();
                    game = NativeAclFix.LaunchGame(workingDir, exePath, arguments, environment);
                }
                catch (Win32Exception ex)
                {
                    MessageBox.Show(
                        "Could not start the game correctly. Please report this error.", "XIVLauncher Error", MessageBoxButton.OK, MessageBoxImage.Error);

                    Log.Error(ex, $"NativeLauncher error; {ex.NativeErrorCode}: {ex.Message}");

                    return(null);
                }

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                                "XG LaunchGame").ShowDialog();
            }

            return(null);
        }
예제 #9
0
        public static Process LaunchGame(string sessionId, int region, int expansionLevel, bool isSteamIntegrationEnabled, bool isSteamServiceAccount, string additionalArguments, DirectoryInfo gamePath, bool isDx11, ClientLanguage language)
        {
            Log.Information($"XivGame::LaunchGame(steamIntegration:{isSteamIntegrationEnabled}, steamServiceAccount:{isSteamServiceAccount}, args:{additionalArguments})");

            try
            {
                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamNative.Initialize();

                        if (SteamApi.IsSteamRunning() && SteamApi.Initialize(STEAM_APP_ID))
                        {
                            Log.Information("Steam initialized.");
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not initialize Steam.");
                    }
                }

                var game = new Process {
                    StartInfo =
                    {
                        UseShellExecute        = false,
                        RedirectStandardError  = false,
                        RedirectStandardInput  = false,
                        RedirectStandardOutput = false
                    }
                };

                if (isDx11)
                {
                    game.StartInfo.FileName = gamePath + "/game/ffxiv_dx11.exe";
                }
                else
                {
                    game.StartInfo.FileName = gamePath + "/game/ffxiv.exe";
                }

                game.StartInfo.Arguments =
                    $"DEV.DataPathType=1 DEV.MaxEntitledExpansionID={expansionLevel} DEV.TestSID={sessionId} DEV.UseSqPack=1 SYS.Region={region} language={(int) language} ver={GetLocalGameVer(gamePath)}";
                game.StartInfo.Arguments += " " + additionalArguments;

                var ticks = (uint)Environment.TickCount;
                var key   = ticks & 0xFFF0_0000;

                var argumentBuilder = new ArgumentBuilder()
                                      .Append("DEV.DataPathType", "1")
                                      .Append("DEV.MaxEntitledExpansionID", expansionLevel.ToString())
                                      .Append("DEV.TestSID", sessionId)
                                      .Append("DEV.UseSqPack", "1")
                                      .Append("SYS.Region", region.ToString())
                                      .Append("language", ((int)language).ToString())
                                      .Append("ver", GetLocalGameVer(gamePath));

                if (isSteamServiceAccount)
                {
                    // These environment variable and arguments seems to be set when ffxivboot is started with "-issteam" (27.08.2019)
                    game.StartInfo.Environment.Add("IS_FFXIV_LAUNCH_FROM_STEAM", "1");
                    argumentBuilder.Append("IsSteam", "1");
                }

                // This is a bit of a hack; ideally additionalArguments would be a dictionary or some KeyValue structure
                if (additionalArguments != null && additionalArguments != "")
                {
                    var regex = new Regex(@"\s*(?<key>[^=]+)\s*=\s*(?<value>[^\s]+)\s*", RegexOptions.Compiled);
                    foreach (Match match in regex.Matches(additionalArguments))
                    {
                        argumentBuilder.Append(match.Groups["key"].Value, match.Groups["value"].Value);
                    }
                }


                game.StartInfo.WorkingDirectory = Path.Combine(gamePath.FullName, "game");

                game.Start();

                if (isSteamIntegrationEnabled)
                {
                    try
                    {
                        SteamApi.Uninitialize();
                        SteamNative.Uninitialize();
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex, "Could not uninitialize Steam.");
                    }
                }

                Thread.Sleep(4000);

                Environment.Exit(0);

                for (var tries = 0; tries < 30; tries++)
                {
                    game.Refresh();

                    // Something went wrong here, why even bother
                    if (game.HasExited)
                    {
                        throw new Exception("Game exited prematurely");
                    }

                    // Is the main window open? Let's wait so any addons won't run into nothing
                    if (game.MainWindowHandle == IntPtr.Zero)
                    {
                        Thread.Sleep(1000);
                        continue;
                    }

                    break;
                }

                return(game);
            }
            catch (Exception ex)
            {
                new ErrorWindow(ex, "Your game path might not be correct. Please check in the settings.",
                                "XG LaunchGame").ShowDialog();
            }

            return(null);
        }