From add4475d51caaf03aca07337e9ad5405ecf2a05c Mon Sep 17 00:00:00 2001 From: aszlig Date: Tue, 16 Mar 2021 02:36:21 +0100 Subject: factorio: Fix patcher to work with Radare2 5.x Version 5.0.0 of Radare2 introduced a few changes in symbol naming, which causes our patcher to fail because it's unable to find the "/usr/share/factorio" string and the getSystemWriteData() method. The upstream change[1] in question for example now uses underscores for certain characters in the symbol/comment name, so for us to be backwards-compatible I added a check against the major version of Radare2 to determine whether we should add underscores when needed. [1]: https://github.com/radareorg/radare2/commit/aaa930ab261a31e58b1257df06db02481cd3bd55 Signed-off-by: aszlig --- pkgs/games/gog/factorio/patch.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'pkgs/games/gog/factorio') diff --git a/pkgs/games/gog/factorio/patch.py b/pkgs/games/gog/factorio/patch.py index 9ffd9bb6..4544e2da 100644 --- a/pkgs/games/gog/factorio/patch.py +++ b/pkgs/games/gog/factorio/patch.py @@ -327,7 +327,11 @@ def patch_read_data_path(patcher: Patcher, out: Path) -> None: data_path = str(out / 'share' / 'factorio') data_path_offset = patcher.write_cstring_to_compost(data_path) - matches = patcher.raw_command_json('/vj str.usr_share_factorio') + if patcher.raw_command_json('?V0') >= 5: + name = 'str._usr_share_factorio' + else: + name = 'str.usr_share_factorio' + matches = patcher.raw_command_json(f'/vj {name}') assert len(matches) > 0, \ f'no matches found for /usr/share/factorio: {matches}' @@ -340,7 +344,11 @@ def patch_read_data_path(patcher: Patcher, out: Path) -> None: def patch_write_data_path(patcher: Patcher) -> None: # This is the function which returns fs::path("$HOME/.factorio"), but since # we want to conform to XDG, we need to rewrite that function. - fun = patcher.load_function('method.Paths.getSystemWriteData') + if patcher.raw_command_json('?V0') >= 5: + name = 'method.Paths.getSystemWriteData__' + else: + name = 'method.Paths.getSystemWriteData' + fun = patcher.load_function(name) # The function in question uses getpwuid(getuid())->pw_dir, so let's find # out the register that references the value of the home directory. -- cgit 1.4.1