fix(rockstar): show the launcher service log in the session log after a Rockstar game exits

This commit is contained in:
maxjivi05 committed 2026-11-13 20:44:46 -05:00
1 parent 0b1b4f4d86
commit a51441b365
3 files changed
+107 -5

No files matched your search

@@ -7,6 +7,7 @@ import os
import re
import shlex
import shutil
import stat
import sys
import time
import subprocess
@@ -291,6 +292,8 @@ def exited(argv, code=0):
compat_data = os.environ.get("STEAM_COMPAT_DATA_PATH")
if compat_data:
(Path(compat_data) / "pfx" / ROCKSTAR_FOLDER / "launch.json").unlink(missing_ok=True)
for line in rockstar_launcher_log(compat_data):
log("rockstar launcher: " + line)
return 0
if found is not None and str(found[1].get("store")) == "epic" and os.environ.get(EPIC_HANDLED) != "1" \
and os.access(EPIC_CLIENT, os.X_OK):
@@ -319,6 +322,29 @@ ROCKSTAR_TITLES = {"gta3": "Grand Theft Auto III", "gtavc": "Grand Theft Auto: V
"gta4": "Grand Theft Auto IV", "lanoire": "LANoireMTL"}
def rockstar_launcher_log(compat_data, limit=65536):
pfx = Path(compat_data) / "pfx"
target = pfx / ROCKSTAR_FOLDER
if not target.resolve().is_relative_to(pfx.resolve()):
return []
path = target / "launcher.log"
try:
descriptor = os.open(path, os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK)
except OSError:
return []
try:
if not stat.S_ISREG(os.fstat(descriptor).st_mode):
return []
with os.fdopen(descriptor, "rb", closefd=False) as source:
data = source.read(limit)
path.unlink(missing_ok=True)
except OSError:
return []
finally:
os.close(descriptor)
return [line.strip() for line in data.decode("utf-8", "replace").splitlines() if line.strip()]
def rockstar_sdk(folder, sidecar):
if str(sidecar.get("id")) in ("gta4", "lanoire"):
return True
@@ -454,6 +480,7 @@ def prepare_rockstar(folder, sidecar, compat_data, launch_dir, proton="", ask_ap
return "invalid-service-path"
config = target / "launch.json"
config.unlink(missing_ok=True)
(target / "launcher.log").unlink(missing_ok=True)
legacy = str(sidecar.get("id")) in ROCKSTAR_TITLES
sdk = rockstar_sdk(folder, sidecar)
title = ROCKSTAR_TITLES.get(str(sidecar.get("id")))
+15 -4
View File
@@ -146,12 +146,21 @@ fn run() -> Result<i32, Box<dyn std::error::Error>> {
None
};
let mut identity_listeners = Vec::new();
let mut identity_names = Vec::new();
if session.is_some() {
for name in droiddeck_rockstar_launcher::identity::title_pipe_names(&exe)? {
identity_listeners.push(Listener::new(&name, Duration::from_secs(90))?);
identity_names = droiddeck_rockstar_launcher::identity::title_pipe_names(&exe)?;
for name in &identity_names {
identity_listeners.push(Listener::new(name, Duration::from_secs(90))?);
}
}
log("launcher pipes created");
log(&format!(
"launcher pipes created, identity: {}",
if identity_names.is_empty() {
"none".to_owned()
} else {
identity_names.join(", ")
}
));
let mut command = std::process::Command::new(exe);
command.current_dir(workdir).args(args?);
if session.is_some() {
@@ -254,7 +263,9 @@ fn run() -> Result<i32, Box<dyn std::error::Error>> {
}
let _ = result.send(outcome);
});
Ok(wait_for_game(&mut child, handshake)?.code().unwrap_or(1))
let code = wait_for_game(&mut child, handshake)?.code().unwrap_or(1);
log(&format!("game exited with code {code}"));
Ok(code)
}
fn main() {
+65 -1
View File
@@ -6,7 +6,7 @@ import time
import unittest
from unittest.mock import patch
from test_store_launch import store
from test_store_launch import game, store
class RockstarLaunch(unittest.TestCase):
@@ -182,6 +182,70 @@ class RockstarLaunch(unittest.TestCase):
self.assertEqual([], requests)
self.assertFalse(config.exists())
def test_each_launch_starts_a_fresh_launcher_log(self):
with tempfile.TemporaryDirectory() as root:
stale = []
def ask(channel, request, timeout):
stale.append((config.parent / 'launcher.log').exists())
return answer
folder, sidecar, prefix, service, answer = self.setup_game(root)
config = prefix / 'pfx' / store.ROCKSTAR_FOLDER / 'launch.json'
config.parent.mkdir(parents=True)
(config.parent / 'launcher.log').write_bytes(b'x' * 70000)
with patch.object(store, 'ROCKSTAR_SERVICE', service), patch.object(store, 'rockstar_registry', return_value=True):
result = store.prepare_rockstar(folder, sidecar, str(prefix), str(Path(root) / 'channel'), ask_app=ask)
self.assertEqual('ready', result)
self.assertEqual([False], stale)
def exit_game(self, root, store_id, log_text=None, link=None):
folder = game(root, store_id=store_id, ident='gta5')
prefix = Path(root) / 'prefix'
target = prefix / 'pfx' / store.ROCKSTAR_FOLDER
target.mkdir(parents=True)
if log_text is not None:
(target / 'launcher.log').write_text(log_text)
if link is not None:
(target / 'launcher.log').symlink_to(link)
lines = []
with patch.dict(os.environ, {'BL_LAUNCH_DIR': str(Path(root) / 'session'), 'STEAM_COMPAT_DATA_PATH': str(prefix)}), \
patch.object(store, 'ask', return_value={'ok': True}), patch.object(store, 'log', lines.append):
self.assertEqual(0, store.main(['--exited', str(folder / '.droiddeck-launch.bat')]))
return lines, target / 'launcher.log'
def test_launcher_log_reaches_the_session_log_when_the_game_exits(self):
with tempfile.TemporaryDirectory() as root:
text = 'launch handoff accepted\r\nlauncher pipes created, identity: none\r\n\r\ngame exited with code 0\r\n'
lines, path = self.exit_game(root, 'rockstar', log_text=text)
self.assertEqual(['rockstar launcher: launch handoff accepted',
'rockstar launcher: launcher pipes created, identity: none',
'rockstar launcher: game exited with code 0'], lines)
self.assertFalse(path.exists())
def test_launcher_log_relay_does_not_follow_links(self):
with tempfile.TemporaryDirectory() as root:
outside = Path(root) / 'outside.txt'
outside.write_text('private\n')
lines, path = self.exit_game(root, 'rockstar', link=outside)
self.assertEqual([], lines)
self.assertTrue(path.is_symlink())
self.assertEqual('private\n', outside.read_text())
def test_other_stores_do_not_relay_the_launcher_log(self):
with tempfile.TemporaryDirectory() as root:
lines, path = self.exit_game(root, 'gog', log_text='launch handoff accepted\n')
self.assertFalse(any(line.startswith('rockstar launcher:') for line in lines))
self.assertTrue(path.exists())
def test_relay_is_bounded(self):
with tempfile.TemporaryDirectory() as root:
prefix = Path(root) / 'prefix'
target = prefix / 'pfx' / store.ROCKSTAR_FOLDER
target.mkdir(parents=True)
(target / 'launcher.log').write_text('a' * 10 + '\n' + 'b' * 100 + '\n')
self.assertEqual(['a' * 10, 'b' * 5], store.rockstar_launcher_log(str(prefix), limit=16))
def test_writes_both_registry_views_and_escapes_values(self):
with tempfile.TemporaryDirectory() as root:
folder, _, prefix, _, _ = self.setup_game(root)