private void LaunchWorker_DoWork(object sender, DoWorkEventArgs e) { SetStatusText("Loading Synapse...", 25); var BaseDirectory = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)) .FullName; try { Directory.SetCurrentDirectory(BaseDirectory); CInterface.Init(); } catch (Exception) { Dispatcher.Invoke(() => { Topmost = false; MessageBox.Show( "Failed to load Synapse libraries. Please check you have the Visual Studio 2017 Redistrutable installed.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(0); }); } SetStatusText("Getting version...", 50); var RawArgs = Environment.GetCommandLineArgs(); var DecodedArgs = DecodeUrlString(RawArgs[1]).Split(' '); var Args = DecodedArgs.Select(Arg => Arg.Split(':')).ToDictionary(Split => Split[0], CombineArgs); int SecureSeed; using (var RNG = new RNGCryptoServiceProvider()) { var Data = new byte[4]; RNG.GetBytes(Data); SecureSeed = BitConverter.ToInt32(Data, 0); } var SpoofBrowserTracker = new Random(SecureSeed).Next(); var UnixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); var UnixTime = (long)(DateTime.UtcNow - UnixEpoch).TotalMilliseconds; string CurrentVersion; using (var WC = new WebClient()) { CurrentVersion = WC.DownloadString( "https://versioncompatibility.api.roblox.com/GetCurrentClientVersionUpload/?apiKey=76e5a40c-3ae1-4028-9f10-7c62520bd94f&binaryType=WindowsPlayer") .Replace("\"", ""); } SetStatusText("Launching...", 75); var VersionFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), $"Roblox\\Versions\\{CurrentVersion}\\"); if (!Directory.Exists(VersionFolder)) { VersionFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86), $"Roblox\\Versions\\{CurrentVersion}\\"); if (!Directory.Exists(VersionFolder)) { VersionFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), $"Roblox\\Versions\\{CurrentVersion}\\"); if (!Directory.Exists(VersionFolder)) { if (!DataInterface.Exists("launcherbackup") || !File.Exists(DataInterface.Read <string>("launcherbackup"))) { Dispatcher.Invoke(() => { MessageBox.Show( "Synapse X has detected a Roblox update and could not find its backup executable. Please reinstall Roblox.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Warning); }); Environment.Exit(0); return; } Process.Start(DataInterface.Read <string>("launcherbackup"), RawArgs[1]); Environment.Exit(0); return; } } } var SI = new STARTUPINFO(); var Suc = CreateProcess(Path.Combine(VersionFolder, "RobloxPlayerBeta.exe"), $"--play -a https://www.roblox.com/Login/Negotiate.ashx -t {Args["gameinfo"]} -j {Args["placelauncherurl"].Replace(Args["browsertrackerid"], SpoofBrowserTracker.ToString())} -b {SpoofBrowserTracker} --launchtime={UnixTime} --rloc {Args["robloxLocale"]} --gloc {Args["gameLocale"]}", IntPtr.Zero, IntPtr.Zero, false, ProcessCreationFlags.CREATE_SUSPENDED, IntPtr.Zero, null, ref SI, out var PI); if (Suc) { if (!SendData("SynapseLaunch", "SYN_LAUNCH_NOTIIFCATION|" + PI.dwProcessId)) { DataInterface.Save("savedpid", new Data.SavedPid { Pid = Convert.ToInt32(PI.dwProcessId), StartTime = Process.GetProcessById(Convert.ToInt32(PI.dwProcessId)).StartTime }); StreamReader InteractReader; new Thread(() => { try { var PS = new PipeSecurity(); var Rule = new PipeAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), PipeAccessRights.ReadWrite, AccessControlType.Allow); PS.AddAccessRule(Rule); var Server = new NamedPipeServerStream("SynapseInteract", PipeDirection.InOut, 1, PipeTransmissionMode.Byte, PipeOptions.None, 0, 0, PS); Server.WaitForConnection(); InteractReader = new StreamReader(Server); while (true) { string Line; try { Line = InteractReader.ReadLine(); } catch (Exception) { Line = "SYN_INTERRUPT"; } InteractMessageRecieved?.Invoke(this, Line); if (Line != "SYN_READY" && Line != "SYN_REATTACH_READY" && Line != "SYN_INTERRUPT") { continue; } Thread.Sleep(1500); Environment.Exit(0); } } catch (Exception) { Environment.Exit(0); } }).Start(); InteractMessageRecieved += delegate(object Sender, string Input) { Dispatcher.Invoke(() => { switch (Input) { case "SYN_CHECK_WL": SetStatusText("Checking whitelist...", 80); break; case "SYN_SCANNING": SetStatusText("Scanning...", 95); break; case "SYN_INTERRUPT": Environment.Exit(0); break; case "SYN_READY": { SetStatusText("Ready!", 100); break; } } }); if (Input == "SYN_READY") { var Read = DataInterface.Read <Data.OptionsHolder>("options"); var Options = JsonConvert.DeserializeObject <Data.Options>(Read.Data); var EnableUnlock = Options.UnlockFPS ? "TRUE" : "FALSE"; var EnableInternalUI = Options.InternalUI ? "TRUE" : "FALSE"; var EnableIngameChat = Options.IngameChat ? "TRUE" : "FALSE"; Execute(Convert.ToInt32(PI.dwProcessId), "SYN_FILE_PATH|" + Path.Combine(BaseDirectory, "workspace") + "|" + EnableUnlock + "|FALSE|" + EnableInternalUI + "|" + EnableIngameChat); Thread.Sleep(1500); Environment.Exit(0); } }; CInterface.Inject(BaseDirectory + "\\bin\\" + Utils.CreateFileName("Synapse.dll"), BaseDirectory + "\\bin\\redis\\D3DCompiler_43.dll", BaseDirectory + "\\bin\\redis\\xinput1_3.dll", Convert.ToInt32(PI.dwProcessId), true); ResumeThread(PI.hThread); return; } CInterface.Inject(BaseDirectory + "\\bin\\" + Utils.CreateFileName("Synapse.dll"), BaseDirectory + "\\bin\\redis\\D3DCompiler_43.dll", BaseDirectory + "\\bin\\redis\\xinput1_3.dll", Convert.ToInt32(PI.dwProcessId), true); ResumeThread(PI.hThread); } SetStatusText("Ready!", 100); Thread.Sleep(1500); Environment.Exit(0); }
private void CloseButton_Click(object sender, RoutedEventArgs e) { Globals.Options = new Data.Options { AutoAttach = AutoAttachBox.IsChecked.Value, AutoLaunch = AutoLaunchBox.IsChecked.Value, MultiRoblox = false, UnlockFPS = UnlockBox.IsChecked.Value, InternalUI = InternalUIBox.IsChecked.Value, IngameChat = IngameChatBox.IsChecked.Value, BetaRelease = BetaReleaseBox.IsChecked.Value, WindowScale = ScaleSlider.Value }; DataInterface.Save("options", new Data.OptionsHolder { Version = Data.OptionsVersion, Data = JsonConvert.SerializeObject(Globals.Options) }); if (BetaStatus != BetaReleaseBox.IsChecked) { MessageBox.Show( "You have chosen to either enable/disable Synapse X beta releases. You must now restart Synapse X in order to install the beta release.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Information); Environment.Exit(0); } if (LaunchStatus != AutoLaunchBox.IsChecked) { try { var Key = Registry.ClassesRoot.OpenSubKey("roblox-player\\shell\\open\\command", true); var BaseDirectory = Path.Combine(Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName); if (Key == null) { throw new Exception("SubKey is invalid."); } if (AutoLaunchBox.IsChecked == true) { var Value = ((string)Key.GetValue("")).Split('"').Where((Item, Idx) => Idx % 2 != 0).ToArray()[0]; Key.SetValue("", $"\"{BaseDirectory + "\\" + Globals.LauncherPath}\" %1"); DataInterface.Save("launcherbackup", Value); } else { if (!DataInterface.Exists("launcherbackup")) { MessageBox.Show("Failed to get launcher backup. You should reinstall Roblox.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Warning); Main.OptionsOpen = false; Close(); return; } Key.SetValue("", $"\"{DataInterface.Read<string>("launcherbackup")}\" %1"); DataInterface.Delete("launcherbackup"); } } catch (Exception) { MessageBox.Show($"Failed to {((bool)AutoLaunchBox.IsChecked ? "setup" : "remove")} AutoLaunch. Please check your anti-virus software.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Warning); return; } } if (Main.Ready()) { MessageBox.Show("Some options may not apply until you reinject Synapse.", "Synapse X", MessageBoxButton.OK, MessageBoxImage.Warning); } Main.OptionsOpen = false; Main.ScaleTransform.ScaleX = ScaleSlider.Value; Main.ScaleTransform.ScaleY = ScaleSlider.Value; Close(); }