mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-25 15:56:01 +00:00
fix: ship Windows executables as add-on packs and keep them out of the APK (#2676)
* fix(rockstar): ship the launcher service as an add-on pack, not inside the APK * fix: ship the DiRT ws2_32 stand-in as an add-on pack and reject Windows executables in the APK * fix(release): reject APK entries under a packed path even when the manifest omits them * fix(dirt): fetch the ws2_32 stand-in pack once the Linux runtime is installed
This commit is contained in:
1 parent
946e9c41e0
commit
9375ed0948
17 files changed
+185
-38
No files matched your search
@@ -433,7 +433,7 @@ if [[ "${DROIDDECK_SKIP_RUST:-0}" != 1 ]]; then
|
||||
CARGO_TARGET_DIR="${cache_dir}/ubisoft-target" bash tools/ubisoft-launcher/build.sh "${upc_out}"
|
||||
save_step ubisoft "${upc_key}" "${upc_out}"
|
||||
fi
|
||||
rockstar_out="${repo_root}/app/src/main/resources/rockstar/helpers"
|
||||
rockstar_out="${linuxfs_dir}/usr/local/lib/droiddeck-rockstar"
|
||||
rockstar_key=$(inputs_hash "windows-gnu" tools/rockstar-launcher/src tools/rockstar-launcher/Cargo.toml tools/rockstar-launcher/Cargo.lock tools/rockstar-launcher/build.sh)
|
||||
if ! restore_step rockstar "${rockstar_key}" "${rockstar_out}"; then
|
||||
command -v i686-w64-mingw32-gcc >/dev/null 2>&1 || { echo "i686-w64-mingw32-gcc is required for the Rockstar launcher service." >&2; exit 1; }
|
||||
|
||||
@@ -314,6 +314,7 @@ UBISOFT_DIR = "drive_c/Program Files (x86)/Ubisoft/Ubisoft Game Launcher"
|
||||
UBISOFT_WINDOWS_DIR = "C:\\Program Files (x86)\\Ubisoft\\Ubisoft Game Launcher\\"
|
||||
UBISOFT_INSTALLER_URL = "https://static3.cdn.ubi.com/orbit/launcher_installer/UbisoftConnectInstaller.exe"
|
||||
ROCKSTAR_SERVICE = Path("/usr/local/lib/droiddeck-rockstar")
|
||||
SERVICE_WAIT = 300.0
|
||||
ROCKSTAR_FOLDER = "drive_c/Program Files/Rockstar Games/Launcher"
|
||||
ROCKSTAR_TITLES = {"gta3": "Grand Theft Auto III", "gtavc": "Grand Theft Auto: Vice City", "gtasa": "GTA: San Andreas",
|
||||
"gta4": "Grand Theft Auto IV", "lanoire": "LANoireMTL"}
|
||||
@@ -446,6 +447,15 @@ def rockstar_runtime(folder, exe, compat_data, arch):
|
||||
return "installed"
|
||||
|
||||
|
||||
def fetch_service(service, store, launch_dir, ask_app=None):
|
||||
if service.is_file():
|
||||
return True
|
||||
if not launch_dir:
|
||||
return False
|
||||
answer = (ask_app or ask)(Path(launch_dir) / "stores", {"op": "store-service", "store": store}, timeout=SERVICE_WAIT)
|
||||
return isinstance(answer, dict) and bool(answer.get("ok")) and service.is_file()
|
||||
|
||||
|
||||
def prepare_rockstar(folder, sidecar, compat_data, launch_dir, proton="", ask_app=None):
|
||||
if not compat_data:
|
||||
return "no-prefix"
|
||||
@@ -481,7 +491,7 @@ def prepare_rockstar(folder, sidecar, compat_data, launch_dir, proton="", ask_ap
|
||||
if len(signature) != 6 or signature[:4] != b"PE\0\0" or signature[4:] not in (b"\x4c\x01", b"\x64\x86"):
|
||||
return "invalid-game-exe"
|
||||
service = ROCKSTAR_SERVICE / ("Launcher32.exe" if signature[4:] == b"\x4c\x01" else "Launcher64.exe")
|
||||
if not service.is_file():
|
||||
if not fetch_service(service, "rockstar", launch_dir, ask_app):
|
||||
return "no-service"
|
||||
made = "present" if (Path(compat_data) / "pfx/user.reg").is_file() else create_prefix(compat_data, proton)
|
||||
if made not in ("created", "present"):
|
||||
@@ -723,7 +733,7 @@ def prepare_ubisoft(folder, sidecar, compat_data, launch_dir, proton="", ask_app
|
||||
product = ubisoft_product(sidecar)
|
||||
if product is None:
|
||||
return "no-product"
|
||||
if not UBISOFT_SERVICE.is_file():
|
||||
if not fetch_service(UBISOFT_SERVICE, "ubisoft", launch_dir, ask_app):
|
||||
return "no-service"
|
||||
made = create_prefix(compat_data, proton) if not (Path(compat_data) / "pfx/user.reg").is_file() else "present"
|
||||
if made not in ("present", "created"):
|
||||
|
||||
@@ -78,6 +78,8 @@ pack xbox "$linuxfs/droiddeck-xbox" version xodus-cli xodus-service
|
||||
pack comet "$linuxfs/droiddeck-comet" version comet
|
||||
pack powervr "$repo/app/src/main/assets/hybris" runtime.tzst version.txt
|
||||
[ ! -f "$linuxfs/droiddeck-ubisoft/droiddeck-upc.exe" ] || pack ubisoft "$linuxfs/droiddeck-ubisoft" droiddeck-upc.exe
|
||||
[ ! -f "$linuxfs/droiddeck-rockstar/Launcher64.exe" ] || pack rockstar "$linuxfs/droiddeck-rockstar" Launcher32.exe Launcher64.exe
|
||||
[ ! -f "$linuxfs/droiddeck-dirt/ws2_32.dll" ] || pack dirt "$linuxfs/droiddeck-dirt" ws2_32.dll
|
||||
|
||||
mkdir "$work/butler"
|
||||
fetch "https://broth.itch.zone/butler/linux-arm64/${BUTLER_VERSION}/archive/default" \
|
||||
|
||||
@@ -14,12 +14,13 @@ ROOT = Path(__file__).resolve().parents[2]
|
||||
MANIFEST = Path('app/build/runtime-inputs.json')
|
||||
PACKS = Path('app/build/packs')
|
||||
PACKED = {'assets/linuxfs/usr/local/lib/droiddeck-xbox/': 'xbox', 'assets/linuxfs/usr/local/lib/droiddeck-comet/': 'comet',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-ubisoft/': 'ubisoft', 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/': 'rockstar',
|
||||
'assets/linuxfs/usr/local/lib/droiddeck-dirt/': 'dirt',
|
||||
'assets/directaudio/': 'directaudio', 'assets/hybris/': 'powervr'}
|
||||
PACKED_FILES = {'lib/arm64-v8a/libproot.so': ('proot', 'libproot.so'),
|
||||
'lib/arm64-v8a/libproot-loader.so': ('proot', 'libproot-loader.so')}
|
||||
PACKED_LIBRARIES = ['lib/arm64-v8a/libopencv_java4.so', 'lib/arm64-v8a/libmediapipe_tasks_jni.so']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft']
|
||||
PACK_NAMES = ['proot', 'directaudio', 'tracking', 'xbox', 'comet', 'butler', 'powervr', 'ubisoft', 'rockstar', 'dirt']
|
||||
SOURCE_PATHS = ['app/build.gradle', 'app/src/main/cpp/fakeinput_steam.cpp', 'app/src/main/assets/pulseaudio.tzst',
|
||||
'tools/linuxfs', 'tools/proot', 'tools/aaudio-sink', 'tools/directaudio', 'tools/packs',
|
||||
'tools/gamescope/release.env', 'tools/droiddeck-esync/release.env',
|
||||
@@ -211,12 +212,27 @@ def pack_digests(root, name):
|
||||
return digests
|
||||
|
||||
|
||||
def windows_binaries(package):
|
||||
found = []
|
||||
for info in package.infolist():
|
||||
if info.is_dir():
|
||||
continue
|
||||
with package.open(info) as entry:
|
||||
if entry.read(2) == b'MZ':
|
||||
found.append(info.filename)
|
||||
return found
|
||||
|
||||
|
||||
def check_apk(apk, root=ROOT):
|
||||
data = verify(root)
|
||||
packs = {name: pack_digests(root, name) for name in PACK_NAMES
|
||||
if name != 'ubisoft' or (root / PACKS / 'ubisoft.tar.zst').is_file()}
|
||||
if name not in ('ubisoft', 'rockstar', 'dirt') or (root / PACKS / (name + '.tar.zst')).is_file()}
|
||||
with ZipFile(apk) as package:
|
||||
names = set(package.namelist())
|
||||
for name in sorted(names):
|
||||
prefix = next((p for p in PACKED if name.startswith(p)), None)
|
||||
if prefix:
|
||||
raise ValueError('APK still carries ' + name + ', which the ' + PACKED[prefix] + ' pack provides')
|
||||
for library in PACKED_LIBRARIES:
|
||||
if library in names:
|
||||
raise ValueError('APK still carries ' + library + ', which the tracking pack provides')
|
||||
@@ -243,6 +259,9 @@ def check_apk(apk, root=ROOT):
|
||||
raise ValueError('APK missing ' + name)
|
||||
if hashlib.sha256(content).hexdigest() != output['sha256']:
|
||||
raise ValueError('APK has stale runtime input: ' + name)
|
||||
found = windows_binaries(package)
|
||||
if found:
|
||||
raise ValueError('APK carries Windows executables, which ship in add-on packs: ' + ', '.join(found))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -12,7 +12,7 @@ GTA III defaults to full x87 precision for FEX before Wine starts, because reduc
|
||||
|
||||
Raw launcher identity requests use `INIT:<nonce>:` with a terminating colon. Framed requests carry their payload length. The reply echoes the complete challenge after `TINI:launcher:`; partial reads do not complete a raw request.
|
||||
|
||||
`build.sh` builds 32-bit and 64-bit executables with the GNU Windows targets and stages them as APK resources. `legacy-cipher.bin` contains the fixed client protocol tables, not account credentials or APK signing keys.
|
||||
`build.sh` builds 32-bit and 64-bit executables with the GNU Windows targets for the `rockstar` add-on pack. The app downloads the pack after Rockstar sign-in, or when a launch finds the service missing, and stages it in the Linux runtime. `legacy-cipher.bin` contains the fixed client protocol tables, not account credentials or APK signing keys.
|
||||
|
||||
Run the protocol tests with:
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
here=$(cd "$(dirname "$0")" && pwd)
|
||||
out=${1:-"$here/../../app/src/main/resources/rockstar/helpers"}
|
||||
out=${1:-"$here/../../app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar"}
|
||||
mkdir -p "$out"
|
||||
for target in i686-pc-windows-gnu x86_64-pc-windows-gnu; do
|
||||
rustup target add "$target" >/dev/null 2>&1 || true
|
||||
|
||||
@@ -36,6 +36,10 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
service = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-ubisoft/droiddeck-upc.exe'
|
||||
service.parent.mkdir(parents=True)
|
||||
service.write_bytes(b'MZ service')
|
||||
rockstar = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-rockstar'
|
||||
rockstar.mkdir(parents=True)
|
||||
(rockstar / 'Launcher32.exe').write_bytes(b'MZ launcher 32')
|
||||
(rockstar / 'Launcher64.exe').write_bytes(b'MZ launcher 64')
|
||||
self.audio(['pactl', 'modules/arm64/module-aaudio-sink.so', 'modules/arm64/module-directaudio-native-sink.so'])
|
||||
self.packs()
|
||||
|
||||
@@ -189,6 +193,46 @@ class RuntimeInputsTest(unittest.TestCase):
|
||||
with self.assertRaisesRegex(ValueError, 'ubisoft pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_rockstar_service_is_rejected(self):
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/Launcher32.exe'
|
||||
self.assertIn(name, runtime.outputs(self.root))
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'MZ launcher 32'})
|
||||
with self.assertRaisesRegex(ValueError, 'rockstar pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_packed_file_the_manifest_does_not_list_is_rejected(self):
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-rockstar/Unlisted.bin'
|
||||
self.assertNotIn(name, runtime.outputs(self.root))
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'helper data'})
|
||||
with self.assertRaisesRegex(ValueError, 'Unlisted.bin, which the rockstar pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_a_stale_rockstar_pack_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'current.apk')
|
||||
self.pack('rockstar', {'Launcher32.exe': b'MZ older launcher', 'Launcher64.exe': b'MZ launcher 64'})
|
||||
with self.assertRaisesRegex(ValueError, 'rockstar is missing or has a stale'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_carrying_any_windows_executable_is_rejected(self):
|
||||
for name in ('assets/linuxfs/usr/local/lib/new-helper/helper.exe', 'assets/anything/renamed.bin', 'res/raw/x.dll'):
|
||||
with self.subTest(name=name):
|
||||
apk = self.current_apk(self.root / 'windows.apk', {name: b'MZ helper'})
|
||||
with self.assertRaisesRegex(ValueError, 'Windows executables.*' + name):
|
||||
runtime.check_apk(apk, self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_dirt_stand_in_is_rejected(self):
|
||||
dirt = self.root / 'app/src/main/assets/linuxfs/usr/local/lib/droiddeck-dirt'
|
||||
dirt.mkdir(parents=True)
|
||||
(dirt / 'ws2_32.dll').write_bytes(b'MZ droiddeck-dirt-ws2_32')
|
||||
self.packs()
|
||||
name = 'assets/linuxfs/usr/local/lib/droiddeck-dirt/ws2_32.dll'
|
||||
self.assertIn(name, runtime.outputs(self.root))
|
||||
self.assertEqual('dirt', runtime.PACKED['assets/linuxfs/usr/local/lib/droiddeck-dirt/'])
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {name: b'MZ droiddeck-dirt-ws2_32'})
|
||||
with self.assertRaisesRegex(ValueError, 'dirt pack provides'):
|
||||
runtime.check_apk(apk, self.root)
|
||||
runtime.check_apk(self.current_apk(self.root / 'current.apk'), self.root)
|
||||
|
||||
def test_an_apk_still_carrying_the_powervr_runtime_is_rejected(self):
|
||||
apk = self.current_apk(self.root / 'bundled.apk', {'assets/hybris/runtime.tzst': b'runtime'})
|
||||
with self.assertRaisesRegex(ValueError, 'powervr pack provides'):
|
||||
|
||||
@@ -165,6 +165,41 @@ class RockstarLaunch(unittest.TestCase):
|
||||
self.assertEqual('rockstar-launch', requests[0]['op'])
|
||||
self.assertEqual(b'compiled-helper', path.with_name('Launcher.exe').read_bytes())
|
||||
|
||||
def test_a_missing_service_is_fetched_from_the_app_before_launch(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder, sidecar, prefix, service, answer = self.setup_game(root)
|
||||
helper = (service / 'Launcher32.exe').read_bytes()
|
||||
(service / 'Launcher32.exe').unlink()
|
||||
requests = []
|
||||
|
||||
def ask(channel, request, timeout):
|
||||
requests.append(request)
|
||||
if request['op'] == 'store-service':
|
||||
(service / 'Launcher32.exe').write_bytes(helper)
|
||||
return {'ok': True}
|
||||
return answer
|
||||
|
||||
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([{'op': 'store-service', 'store': 'rockstar'}], requests[:1])
|
||||
self.assertEqual('rockstar-launch', requests[1]['op'])
|
||||
|
||||
def test_an_unavailable_service_does_not_request_account_data(self):
|
||||
with tempfile.TemporaryDirectory() as root:
|
||||
folder, sidecar, prefix, service, _ = self.setup_game(root)
|
||||
(service / 'Launcher32.exe').unlink()
|
||||
requests = []
|
||||
|
||||
def ask(channel, request, timeout):
|
||||
requests.append(request)
|
||||
return {'ok': False, 'reason': 'service-unavailable'}
|
||||
|
||||
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('no-service', result)
|
||||
self.assertEqual(['store-service'], [request['op'] for request in requests])
|
||||
|
||||
def test_rejected_or_expired_sessions_cannot_reuse_stale_material(self):
|
||||
for update in ({'ok': False, 'reason': 'not-owned'}, {'material': 'A' * 641}, {'expiresAt': 1}):
|
||||
with self.subTest(update=update), tempfile.TemporaryDirectory() as root:
|
||||
|
||||
Reference in new issue
Block a user