コード例 #1
0
 public static void SetValue(IntPtr windowHandle, double progressValue, double progressMax)
 {
     if (taskbarSupported && !(DetectLinux.WineDetected() || DetectLinux.NativeLinuxDetected()))
     {
         taskbarInstance.SetProgressValue(windowHandle, (ulong)progressValue, (ulong)progressMax);
     }
 }
コード例 #2
0
 public static void SetState(IntPtr windowHandle, TaskbarStates taskbarState)
 {
     if (taskbarSupported && !(DetectLinux.WineDetected() || DetectLinux.NativeLinuxDetected()))
     {
         taskbarInstance.SetProgressState(windowHandle, taskbarState);
     }
 }
コード例 #3
0
        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);

            request.UserAgent = "GameLauncher (+https://github.com/worldunitedgg/GameLauncher_NFSW)";
            if (!DetectLinux.NativeLinuxDetected())
            {
                request.Headers["X-HWID"] = Security.FingerPrint.Value();
            }
            else
            {
                request.Headers["X-HWID"] = "1234";
            }
            request.Headers["X-GameLauncherHash"] = Value();
            request.Timeout = 30000;

            return(request);
        }
コード例 #4
0
        protected override WebRequest GetWebRequest(Uri address)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);

            request.UserAgent = "GameLauncher (+https://github.com/SoapboxRaceWorld/GameLauncher_NFSW)";
            if (!DetectLinux.NativeLinuxDetected())
            {
                request.Headers["X-HWID"] = Security.FingerPrint.Value();
            }
            else
            {
                request.Headers["X-HWID"] = "1234";
            }
            request.Headers["X-GameLauncherHash"] = Value();
            request.Headers["secret"]             = "0148e7cc5b47aa2fb09c12caae2a4b65";
            request.Timeout = 30000;

            return(request);
        }
コード例 #5
0
        static void Main()
        {
            bool mono  = DetectLinux.MonoDetected();
            bool wine  = DetectLinux.WineDetected();
            bool linux = DetectLinux.NativeLinuxDetected();

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            if (Self.isTempFolder(Directory.GetCurrentDirectory()))
            {
                MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
            }

            if (!Directory.Exists("Languages"))
            {
                Directory.CreateDirectory("Languages");
            }

            try {
                File.Delete("Languages/Default.lng");
                File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng"));
            }
            catch { }

            try {
                File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip");
            } catch { }

            if (!File.Exists("LZMA.dll"))
            {
                File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll"));
            }

            if (!linux && !File.Exists("discord-rpc.dll"))
            {
                File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll"));
            }

            if (linux && !File.Exists("libdiscord-rpc.so"))
            {
                File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so"));
            }

            if (File.Exists("GameLauncherUpdater.exe"))
            {
                File.Delete("GameLauncherUpdater.exe");
            }

            try {
                File.Delete("GL_Update.exe");
                File.WriteAllBytes("GL_Update.exe", ExtractResource.AsByte("GameLauncher.Updater.GL_Update.exe"));
            } catch { }

            if (!File.Exists("servers.txt"))
            {
                try {
                    File.Create("servers.txt");
                } catch { }
            }

            if (Debugger.IsAttached)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new mainScreen());
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try {
                    if (mutex.WaitOne(0, false))
                    {
                        String[]      files        = { "Newtonsoft.Json.dll", "INIFileParser.dll", "Microsoft.WindowsAPICodePack.dll", "Microsoft.WindowsAPICodePack.Shell.dll" };
                        List <string> missingfiles = new List <string>();

                        foreach (string file in files)
                        {
                            if (!File.Exists(file))
                            {
                                missingfiles.Add(file);
                            }
                        }

                        if (missingfiles.Count != 0)
                        {
                            string message = "Cannot launch GameLauncher. The following files are missing:\n\n";

                            foreach (string file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            message += "\nCurrent directory: " + Directory.GetCurrentDirectory();

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Environment.Exit(1);
                        }

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new mainScreen());
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                } finally {
                    if (mutex != null)
                    {
                        mutex.Close();
                        mutex = null;
                    }
                }
            }
        }
コード例 #6
0
        static void Main()
        {
            int  SysVersion = (int)Environment.OSVersion.Platform;
            bool mono       = DetectLinux.MonoDetected();
            bool wine       = DetectLinux.WineDetected();
            bool linux      = DetectLinux.NativeLinuxDetected();

            try {
            } catch {
                MessageBox.Show("This should fake antivirus :v");
            }

            /*if(Environment.OSVersion.Version.Major <= 5 && !linux) {
             *  MessageBox.Show(null, "Windows XP Support has been terminated. Please upgrade your Operating System to 'Vista' or newer.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             *  Environment.Exit(Environment.ExitCode);
             * }*/

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));

            if (!Directory.Exists("Languages"))
            {
                Directory.CreateDirectory("Languages");
            }

            try {
                File.Delete("Languages/Default.lng");
                File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng"));
            }
            catch { }

            try {
                File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip");
            } catch { }

            if (linux)
            {
                MessageBox.Show(null, "Native Linux support is still under alpha stage. Therefore, launcher or game could crash.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else if (mono == true)
            {
                MessageBox.Show(null, "Mono support is still under alpha stage. Therefore, launcher could not launch.", "GameLauncher.exe", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }

            if (!File.Exists("LZMA.dll"))
            {
                File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll"));
            }

            if (!linux && !File.Exists("discord-rpc.dll"))
            {
                File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll"));
            }

            if (linux && !File.Exists("libdiscord-rpc.so"))
            {
                File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so"));
            }

            if (File.Exists("GameLauncherUpdater.exe"))
            {
                File.Delete("GameLauncherUpdater.exe");
            }

            try {
                File.Delete("GL_Update.exe");
                File.WriteAllBytes("GL_Update.exe", ExtractResource.AsByte("GameLauncher.Updater.GL_Update.exe"));
            } catch { }

            if (!File.Exists("servers.txt"))
            {
                try {
                    File.Create("servers.txt");
                } catch { }
            }

            if (Debugger.IsAttached)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new mainScreen());
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                Mutex mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try {
                    if (mutex.WaitOne(0, false))
                    {
                        String[]      files        = { "Newtonsoft.Json.dll", "LZMA.dll" };
                        List <string> missingfiles = new List <string>();

                        foreach (string file in files)
                        {
                            if (!File.Exists(file))
                            {
                                missingfiles.Add(file);
                            }
                        }

                        if (missingfiles.Count != 0)
                        {
                            string message = "Cannot launch GameLauncher. The following files are missing:\n\n";

                            foreach (string file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            message += "\nCurrent directory: " + Directory.GetCurrentDirectory();
                            message += "\nYou will be moved to the project page for re-download.";

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Process.Start(@"https://github.com/SoapboxRaceWorld/GameLauncher_NFSW/releases");
                            Environment.Exit(1);
                        }

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new mainScreen());
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                } finally {
                    if (mutex != null)
                    {
                        mutex.Close();
                        mutex = null;
                    }
                }
            }
        }
コード例 #7
0
        internal static void Main()
        {
            var linux = DetectLinux.NativeLinuxDetected();

            Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath) ?? throw new InvalidOperationException());

            if (Self.isTempFolder(Directory.GetCurrentDirectory()))
            {
                MessageBox.Show(null, "Please, extract me and my DLL files before executing...", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                Environment.Exit(0);
            }

            if (!Directory.Exists("Languages"))
            {
                Directory.CreateDirectory("Languages");
            }

            try
            {
                File.Delete("Languages/Default.lng");
                File.WriteAllText("Languages/Default.lng", ExtractResource.AsString("GameLauncher.Language.Default.lng"));
            }
            catch
            {
                // ignored
            }

            try
            {
                File.Delete(Directory.GetCurrentDirectory() + "\\tempname.zip");
            }
            catch
            {
                // ignored
            }

            if (!File.Exists("LZMA.dll"))
            {
                File.WriteAllBytes("LZMA.dll", ExtractResource.AsByte("GameLauncher.LZMA.LZMA.dll"));
            }

            if (!linux && !File.Exists("discord-rpc.dll"))
            {
                File.WriteAllBytes("discord-rpc.dll", ExtractResource.AsByte("GameLauncher.Discord.discord-rpc.dll"));
            }

            if (linux && !File.Exists("libdiscord-rpc.so"))
            {
                File.WriteAllBytes("libdiscord-rpc.so", ExtractResource.AsByte("GameLauncher.Discord.libdiscord-rpc.so"));
            }

            if (File.Exists("GL_Update.exe"))
            {
                File.Delete("GL_Update.exe");
            }

            if (!File.Exists("GameLauncherUpdater.exe"))
            {
                try
                {
                    File.WriteAllBytes("GameLauncherUpdater.exe", new WebClientWithTimeout().DownloadData("http://launcher.soapboxrace.world/GameLauncherUpdater.exe"));
                }
                catch
                {
                    // ignored
                }
            }
            if (!File.Exists("servers.json"))
            {
                try
                {
                    File.WriteAllText("servers.json", "[]");
                }
                catch
                {
                    // ignored
                }
            }

            if (Debugger.IsAttached)
            {
                ServerProxy.Instance.Start();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainScreen());
            }
            else
            {
                if (NFSW.isNFSWRunning())
                {
                    MessageBox.Show(null, "An instance of Need for Speed: World is already running", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    Process.GetProcessById(Process.GetCurrentProcess().Id).Kill();
                }

                var mutex = new Mutex(false, "GameLauncherNFSW-MeTonaTOR");
                try
                {
                    if (mutex.WaitOne(0, false))
                    {
                        string[] files =
                        {
                            "Newtonsoft.Json.dll",
                            "INIFileParser.dll",
                            "Microsoft.WindowsAPICodePack.dll",
                            "Microsoft.WindowsAPICodePack.Shell.dll",
                            "Flurl.dll",
                            "Flurl.Http.dll",
                            "BlackListedServers.dat"
                        };
                        var missingfiles = new List <string>();

                        foreach (var file in files)
                        {
                            if (!File.Exists(file))
                            {
                                missingfiles.Add(file);
                            }
                        }

                        if (missingfiles.Count != 0)
                        {
                            var message = "Cannot launch GameLauncher. The following files are missing:\n\n";

                            foreach (var file in missingfiles)
                            {
                                message += "• " + file + "\n";
                            }

                            message += "\nCurrent directory: " + Directory.GetCurrentDirectory();

                            MessageBox.Show(null, message, "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Environment.Exit(1);
                        }

                        ServerProxy.Instance.Start();

                        Application.EnableVisualStyles();
                        Application.SetCompatibleTextRenderingDefault(false);
                        Application.Run(new MainScreen());
                    }
                    else
                    {
                        MessageBox.Show(null, "An instance of the application is already running.", "GameLauncher", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
                finally
                {
                    mutex.Close();
                    mutex = null;
                }
            }
        }
コード例 #8
0
        private void DebugWindow_Load(object sender, EventArgs e)
        {
            data.AutoGenerateColumns = true;

            IniFile SettingFile = new IniFile("Settings.ini");

            string TracksHigh = (SettingFile.Read("TracksHigh") == "1") ? "True" : "False";
            string Password   = (!String.IsNullOrEmpty(SettingFile.Read("Password"))) ? "True" : "False";
            string SkipUpdate = (SettingFile.Read("SkipUpdate") == "1") ? "True" : "False";

            string Antivirus   = String.Empty;
            string Firewall    = String.Empty;
            string AntiSpyware = String.Empty;

            if (!DetectLinux.NativeLinuxDetected())
            {
                try
                {
                    Antivirus   = (String.IsNullOrEmpty(AntivirusInstalled())) ? "---" : AntivirusInstalled();
                    Firewall    = (String.IsNullOrEmpty(AntivirusInstalled("FirewallProduct"))) ? "---" : AntivirusInstalled("FirewallProduct");
                    AntiSpyware = (String.IsNullOrEmpty(AntivirusInstalled("AntiSpywareProduct"))) ? "---" : AntivirusInstalled("AntiSpywareProduct");
                }
                catch
                {
                    Antivirus   = "Unknown";
                    Firewall    = "Unknown";
                    AntiSpyware = "Unknown";
                }
            }

            string LauncherPosition = "";
            string OS = "";

            if (DetectLinux.WineDetected())
            {
                OS = "Wine";
            }
            else if (DetectLinux.NativeLinuxDetected())
            {
                OS = "Native Linux";
            }
            else
            {
                OS = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast <ManagementObject>()
                      select x.GetPropertyValue("Caption")).FirstOrDefault().ToString();
            }

            if (SettingFile.Read("LauncherPosX") + "x" + SettingFile.Read("LauncherPosY") == "x")
            {
                LauncherPosition = "Windows Default Position";
            }
            else
            {
                LauncherPosition = SettingFile.Read("LauncherPosX") + "x" + SettingFile.Read("LauncherPosY");
            }

            long          memKb = 0;
            ulong         lpFreeBytesAvailable = 0;
            List <string> GPUs            = new List <string>();
            string        Win32_Processor = "";

            if (!DetectLinux.NativeLinuxDetected())
            {
                GetPhysicallyInstalledSystemMemory(out memKb);

                ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Name FROM Win32_VideoController");
                string graphicsCard = string.Empty;
                foreach (ManagementObject mo in searcher.Get())
                {
                    foreach (PropertyData property in mo.Properties)
                    {
                        GPUs.Add(property.Value.ToString());
                    }
                }

                Win32_Processor = (from x in new ManagementObjectSearcher("SELECT Name FROM Win32_Processor").Get().Cast <ManagementObject>()
                                   select x.GetPropertyValue("Name")).FirstOrDefault().ToString();

                Kernel32.GetDiskFreeSpaceEx(SettingFile.Read("InstallationDirectory"), out lpFreeBytesAvailable, out ulong lpTotalNumberOfBytes, out ulong lpTotalNumberOfFreeBytes);
            }

            var Win32_VideoController = string.Join(" | ", GPUs);

            var settings = new List <ListType> {
                new ListType {
                    Name = "InstallationDirectory", Value = SettingFile.Read("InstallationDirectory")
                },
                new ListType {
                    Name = "Server Address", Value = ServerIP
                },
                new ListType {
                    Name = "Server Name", Value = ServerName
                },
                new ListType {
                    Name = "Credentials Saved", Value = Password
                },
                new ListType {
                    Name = "Language", Value = SettingFile.Read("Language")
                },
                new ListType {
                    Name = "TracksHigh", Value = TracksHigh
                },
                new ListType {
                    Name = "UILanguage", Value = SettingFile.Read("UILanguage")
                },
                new ListType {
                    Name = "SkipUpdate", Value = SkipUpdate
                },
                new ListType {
                    Name = "LauncherPos", Value = LauncherPosition
                },

                new ListType {
                    Name = "", Value = ""
                },
            };

            if (DetectLinux.NativeLinuxDetected())
            {
                var embedded = Directory.Exists("wine");
                settings.Add(new ListType {
                    Name = "Embedded Wine", Value = embedded.ToString()
                });
                if (!embedded)
                {
                    settings.Add(new ListType {
                        Name = "Wine version", Value = WineManager.GetWineVersion()
                    });
                }
                settings.Add(new ListType {
                    Name = "", Value = ""
                });
            }

            if (!DetectLinux.NativeLinuxDetected())
            {
                settings.AddRange(new[] {
                    new ListType {
                        Name = "Antivirus", Value = Antivirus
                    },
                    new ListType {
                        Name = "Firewall", Value = Firewall
                    },
                    new ListType {
                        Name = "AntiSpyware", Value = AntiSpyware
                    },
                    new ListType {
                        Name = "", Value = ""
                    },
                    new ListType {
                        Name = "CPU", Value = Win32_Processor
                    },
                    new ListType {
                        Name = "GPU", Value = Win32_VideoController
                    },
                    new ListType {
                        Name = "RAM", Value = (memKb / 1024).ToString() + "MB"
                    },
                    new ListType {
                        Name = "Disk Space Left", Value = FormatFileSize(lpFreeBytesAvailable)
                    },
                    new ListType {
                        Name = "", Value = ""
                    }
                });
            }
            settings.AddRange(new[] {
                new ListType {
                    Name = "Operating System", Value = OS
                },
                new ListType {
                    Name = "Environment Version", Value = Environment.OSVersion.Version.ToString()
                },
                new ListType {
                    Name = "Screen Resolution", Value = Screen.PrimaryScreen.Bounds.Width + "x" + Screen.PrimaryScreen.Bounds.Height
                }
            });

            data.DataSource = settings;

            DataGridViewCellStyle style = new DataGridViewCellStyle();

            style.Font = new Font(data.Font, FontStyle.Bold);
            data.Columns[0].DefaultCellStyle = style;

            data.Columns[0].Width += 50;

            int size_x = 1024;
            int size_y = 450;

            data.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.Size = new Size(size_x, size_y);
        }