diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env index 637e02a2dc..9b4b711705 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-game-env @@ -361,6 +361,7 @@ def engine_fixes(exe, args): return env, extra, notes +DS_APP_IDS = {"1190460", "1850570"} DS_SIZE = 86479872 DS_WINDOW_OFFSET = 0x38FE190 DS_WINDOW = bytes.fromhex("48895c240848896c2410488974241848897c242041564883ec70458bf1498bf0488bfa488be94885c9") @@ -368,10 +369,10 @@ DS_ORIGINAL = bytes.fromhex("0f85a5000000") DS_FIXED = bytes.fromhex("e9a600000090") -def death_stranding_allocator(exe): +def death_stranding_allocator(app_id, exe): # The game's bundled mimalloc tries one random address between 4 and 8 TiB and never falls back, # but a 39-bit kernel cannot map anything above 512 GiB. Jumping straight to its aligned path avoids it. - if os.path.basename(exe).lower() != "ds.exe": + if app_id not in DS_APP_IDS or os.path.basename(exe).lower() != "ds.exe": return False try: with open(exe, "r+b") as game: @@ -1330,7 +1331,7 @@ def main(): if waiting: command = skip_red_launcher(command) if len(command) > 2: - death_stranding_allocator(command[2]) + death_stranding_allocator(app_id, command[2]) ubisoft_overlay_off(env) project_zomboid_jvm(command) fixes, extra, notes = engine_fixes(command[2], command[3:]) if len(command) > 2 else ({}, [], []) diff --git a/tools/tests/test_game_environment.py b/tools/tests/test_game_environment.py index 46d74ab93d..768ee0660d 100644 --- a/tools/tests/test_game_environment.py +++ b/tools/tests/test_game_environment.py @@ -49,10 +49,10 @@ class DeathStrandingAllocatorTest(unittest.TestCase): game.seek(MODULE["DS_WINDOW_OFFSET"] - 1) return game.read(len(MODULE["DS_WINDOW"]) + len(MODULE["DS_ORIGINAL"]) + 2) - def run_fix(self, path): + def run_fix(self, path, app_id="1850570"): errors = io.StringIO() with mock.patch("sys.stderr", errors): - return MODULE["death_stranding_allocator"](path), errors.getvalue() + return MODULE["death_stranding_allocator"](app_id, path), errors.getvalue() def test_window_and_patch_have_the_measured_shape(self): self.assertEqual(41, len(MODULE["DS_WINDOW"])) @@ -101,6 +101,17 @@ class DeathStrandingAllocatorTest(unittest.TestCase): self.assertEqual((False, ""), self.run_fix(path)) self.assertEqual(before, self.read_tail(path)) + def test_other_games_are_not_touched_even_with_a_matching_file(self): + for app_id in ("440", "", None): + path = self.make_exe() + before = self.read_tail(path) + self.assertEqual((False, ""), self.run_fix(path, app_id)) + self.assertEqual(before, self.read_tail(path)) + + def test_both_death_stranding_app_ids_are_patched(self): + for app_id in ("1850570", "1190460"): + self.assertTrue(self.run_fix(self.make_exe(), app_id)[0]) + def test_the_file_name_check_ignores_case(self): self.assertTrue(self.run_fix(self.make_exe(name="DS.EXE"))[0])