mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 12:28:40 +00:00
fix(game-env): only patch Death Stranding's allocator for Death Stranding's app id (#2644)
This commit is contained in:
1 parent
87cd74c4bf
commit
059711cfe1
2 files changed
+17
-5
No files matched your search
@@ -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 ({}, [], [])
|
||||
|
||||
@@ -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])
|
||||
|
||||
|
||||
Reference in new issue
Block a user