From 2974c2db92b92787c285751b2437656568ea8dec Mon Sep 17 00:00:00 2001 From: maxjivi05 Date: Tue, 1 Dec 2026 13:55:12 -0500 Subject: [PATCH] fix(rockstar): preserve legacy launches when the SDK pipe is unused --- tools/rockstar-launcher/src/lib.rs | 31 +++++++++++++++++++++++++++ tools/rockstar-launcher/src/main.rs | 10 +++++++-- tools/tests/test_rockstar_launcher.py | 20 +++++++++++++++++ 3 files changed, 59 insertions(+), 2 deletions(-) create mode 100644 tools/tests/test_rockstar_launcher.py diff --git a/tools/rockstar-launcher/src/lib.rs b/tools/rockstar-launcher/src/lib.rs index e37ff76d85..937a1cc516 100644 --- a/tools/rockstar-launcher/src/lib.rs +++ b/tools/rockstar-launcher/src/lib.rs @@ -9,6 +9,17 @@ pub mod sdk; pub const MAX_FRAME_BYTES: usize = 64 * 1024; const OVERHEAD: usize = 4 + 4 + 1; +pub fn sdk_connection( + connection: io::Result, + legacy_authenticated: bool, +) -> io::Result> { + match connection { + Ok(pipe) => Ok(Some(pipe)), + Err(error) if legacy_authenticated && error.kind() == io::ErrorKind::TimedOut => Ok(None), + Err(error) => Err(error), + } +} + pub fn wait_for_game( child: &mut std::process::Child, handshake: std::sync::mpsc::Receiver>, @@ -162,6 +173,26 @@ mod tests { assert!(child.try_wait().unwrap().is_some()); } + #[test] + fn an_unused_sdk_connection_is_optional_only_after_legacy_authentication() { + for authenticated in [false, true] { + assert_eq!(sdk_connection(Ok(42), authenticated).unwrap(), Some(42)); + for kind in [ + io::ErrorKind::TimedOut, + io::ErrorKind::PermissionDenied, + io::ErrorKind::InvalidData, + io::ErrorKind::BrokenPipe, + ] { + let result = sdk_connection::<()>(Err(io::Error::from(kind)), authenticated); + if authenticated && kind == io::ErrorKind::TimedOut { + assert_eq!(result.unwrap(), None); + } else { + assert_eq!(result.unwrap_err().kind(), kind); + } + } + } + } + #[test] fn stopped_handshake_worker_terminates_and_reaps_the_game() { let mut child = sleeping_child(); diff --git a/tools/rockstar-launcher/src/main.rs b/tools/rockstar-launcher/src/main.rs index cc2d294218..04eabe991f 100644 --- a/tools/rockstar-launcher/src/main.rs +++ b/tools/rockstar-launcher/src/main.rs @@ -26,7 +26,7 @@ fn run() -> Result> { use droiddeck_rockstar_launcher::{ pipe::Listener, sdk::{Message, Session}, - wait_for_game, Frame, Length, + sdk_connection, wait_for_game, Frame, Length, }; use std::io::{Read, Write}; use std::time::{Duration, SystemTime, UNIX_EPOCH}; @@ -195,6 +195,7 @@ fn run() -> Result> { let (result, handshake) = std::sync::mpsc::sync_channel(1); std::thread::spawn(move || { let serve = || -> std::io::Result<()> { + let mut legacy_authenticated = false; if let Some((listener, material, terminated)) = legacy { let mut pipe = listener.accept()?; log("legacy launcher pipe connected"); @@ -225,9 +226,14 @@ fn run() -> Result> { }, )?; log("legacy launcher handshake complete"); + legacy_authenticated = true; } if let (Some(listener), Some(session)) = (sdk_listener, session) { - let mut pipe = listener.accept()?.with_deadline(Duration::from_secs(90)); + let Some(pipe) = sdk_connection(listener.accept(), legacy_authenticated)? else { + log("SDK pipe unused after legacy launcher handshake"); + return Ok(()); + }; + let mut pipe = pipe.with_deadline(Duration::from_secs(90)); if pipe.client_pid()? != pid { return Err(std::io::Error::new( std::io::ErrorKind::PermissionDenied, diff --git a/tools/tests/test_rockstar_launcher.py b/tools/tests/test_rockstar_launcher.py new file mode 100644 index 0000000000..23f52751dd --- /dev/null +++ b/tools/tests/test_rockstar_launcher.py @@ -0,0 +1,20 @@ +import pathlib +import subprocess +import unittest + + +class RockstarLauncherTest(unittest.TestCase): + def test_protocol_and_process_lifecycle(self): + root = pathlib.Path(__file__).resolve().parents[2] + subprocess.run( + [ + "cargo", + "test", + "--locked", + "--manifest-path", + "tools/rockstar-launcher/Cargo.toml", + ], + cwd=root, + check=True, + timeout=180, + )