mirror of
https://github.com/gurrgur/er-patcher.git
synced 2026-06-13 09:47:54 +00:00
Merge branch 'main' into main
This commit is contained in:
commit
e4060666b5
2 changed files with 58 additions and 58 deletions
120
er-patcher
Executable file → Normal file
120
er-patcher
Executable file → Normal file
|
|
@ -13,19 +13,19 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
patcher_args = sys.argv[1:sys.argv.index("--")]
|
patcher_args = sys.argv[1:sys.argv.index("--")]
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description="Patch `eldenring.exe` and run it without EAC.")
|
parser = argparse.ArgumentParser(description="Patch Elden Ring executable and launch it without EAC.")
|
||||||
|
|
||||||
parser.add_argument("--all", action='store_true', help="Enable all options but `--rate` and gameplay changes like `--disable-rune-loss`.")
|
parser.add_argument("-r", "--rate", type=int, default=60, help="Modify the frame rate limit (e.g. 30, 120, 165 or whatever).")
|
||||||
parser.add_argument("-l", "--disable-rune-loss", action='store_true', help="Disable rune loss on death.")
|
parser.add_argument("-x", "--executable", action='store', type=str, default="eldenring.exe", help="The executable to launch, relative to the games folder.")
|
||||||
parser.add_argument("-x", "--executable", action='store', type=str, default="eldenring.exe", help="Set the executable to run, relative to the game's folder.")
|
parser.add_argument("--with-eac", action='store_true', help="Run game with EAC (Use at own your risk)")
|
||||||
parser.add_argument("-a", "--increase-animation-distance", action='store_true', help="Fix low frame rate animations for distant entities or at screen edges.")
|
parser.add_argument("--disable-rune-loss", action='store_true', help="Disable losing runes upon death.")
|
||||||
parser.add_argument("-r", "--rate", type=int, default=60, help="Set a custom frame rate limit (default: 60).")
|
parser.add_argument("--all", action='store_true', help="Enable all options except rate adjustment and gamplay changes like `--disable-rune-loss`.")
|
||||||
parser.add_argument("-f", "--remove-60-hz-fullscreen", action='store_true', help="Remove 60 Hz lock in fullscreen (unneeded in Proton).")
|
parser.add_argument("-u", "--ultrawide", action='store_true', help="Removes black bars when using a resolution with an aspect ratio other than 16:9.")
|
||||||
parser.add_argument("-c", "--remove-ca", action='store_true', help="Remove chromatic abberation.")
|
parser.add_argument("-v", "--disable-vigniette", action='store_true', help="Disables the vigniette overlay.")
|
||||||
parser.add_argument("-v", "--remove-vignette", action='store_true', help="Remove the vignette.")
|
parser.add_argument("-c", "--disable-ca", action='store_true', help="Disables chromatic abberation.")
|
||||||
parser.add_argument("-s", "--skip-intro", action='store_true', help="Skip intro logos on startup.")
|
parser.add_argument("-a", "--increase-animation-distance", action='store_true', help="Increase animation distance.")
|
||||||
parser.add_argument("-u", "--ultrawide", action='store_true', help="Remove black bars in non 16:9 screens.")
|
parser.add_argument("-s", "--skip-intro", action='store_true', help="Skip intro logos.")
|
||||||
parser.add_argument("-w", "--with-eac", action='store_true', help="Run the game with EAC (use it at own your risk).")
|
parser.add_argument("-f", "--remove-60hz-fullscreen", action='store_true', help="Remove 60hz lock in fullscreen.")
|
||||||
patch = parser.parse_args(patcher_args)
|
patch = parser.parse_args(patcher_args)
|
||||||
|
|
||||||
if patch.with_eac and patch.executable != "eldenring.exe":
|
if patch.with_eac and patch.executable != "eldenring.exe":
|
||||||
|
|
@ -36,6 +36,15 @@ if __name__ == "__main__":
|
||||||
with open(game_dir / "eldenring.exe", "rb") as f:
|
with open(game_dir / "eldenring.exe", "rb") as f:
|
||||||
exe_hex = f.read().hex()
|
exe_hex = f.read().hex()
|
||||||
|
|
||||||
|
if patch.rate != 60 and patch.rate > 0:
|
||||||
|
r_pattern = "c7 43 20 89 88 88 3c eb 43 89 73 18 eb ca 89 73 18".replace(" ", "")
|
||||||
|
if (res := re.search(r_pattern, exe_hex)) is not None:
|
||||||
|
r_addr = res.span()[0] + 6
|
||||||
|
r_patch = struct.pack('<f', 1 / patch.rate).hex()
|
||||||
|
exe_hex = exe_hex[:r_addr] + r_patch + exe_hex[r_addr + len(r_patch):]
|
||||||
|
else:
|
||||||
|
print("er-patcher: rate pattern scan failed")
|
||||||
|
|
||||||
if patch.disable_rune_loss:
|
if patch.disable_rune_loss:
|
||||||
rl_pattern = "b0 01 .. 8b .. e8 .. .. .. .. .. 8b .. .. .. 32 c0 .. 83 .. 28 c3".replace(" ", "")
|
rl_pattern = "b0 01 .. 8b .. e8 .. .. .. .. .. 8b .. .. .. 32 c0 .. 83 .. 28 c3".replace(" ", "")
|
||||||
if (res := re.search(rl_pattern, exe_hex)) is not None:
|
if (res := re.search(rl_pattern, exe_hex)) is not None:
|
||||||
|
|
@ -45,6 +54,35 @@ if patch.disable_rune_loss:
|
||||||
else:
|
else:
|
||||||
print("er-patcher: disable rune loss pattern scan failed")
|
print("er-patcher: disable rune loss pattern scan failed")
|
||||||
|
|
||||||
|
if patch.ultrawide or patch.all:
|
||||||
|
uw_pattern = "74 4f 45 8b 94 cc".replace(" ", "")
|
||||||
|
if (res := re.search(uw_pattern, exe_hex)) is not None:
|
||||||
|
uw_addr = res.span()[0]
|
||||||
|
uw_patch = "eb"
|
||||||
|
exe_hex = exe_hex[:uw_addr] + uw_patch + exe_hex[uw_addr + len(uw_patch):]
|
||||||
|
else:
|
||||||
|
print("er-patcher: ultrawide pattern scan failed")
|
||||||
|
|
||||||
|
if patch.disable_vigniette or patch.all:
|
||||||
|
v_pattern = 'f3 0f 10 .. .. f3 0f 59 .. .. .. .. .. e8 .. .. .. .. f3 41 0f .. .. f3 45 0f .. .. 4c 8d .. .. .. .. .. .. 48'.replace(" ", "")
|
||||||
|
if (res := re.search(v_pattern, exe_hex)) is not None:
|
||||||
|
v_addr = res.span()[0] + 46
|
||||||
|
v_patch = "f3 0f 5c c0 90".replace(" ", "") # SUBSS XMM0,XMM0; NOP; all NOP does work too
|
||||||
|
exe_hex = exe_hex[:v_addr] + v_patch + exe_hex[v_addr + len(v_patch):]
|
||||||
|
else:
|
||||||
|
print("er-patcher: disable_vigniette pattern scan failed")
|
||||||
|
|
||||||
|
if patch.disable_ca or patch.all:
|
||||||
|
ca_pattern = "0f 11 43 60 48 8d 8b 80 00 00 00 0f 10 87 a0 00 00 00 0f 11 41 f0 48 8d 87 b0 00 00 00 0f 10 08 0f 11 09".replace(" ", "")
|
||||||
|
if (res := re.search(ca_pattern, exe_hex)) is not None:
|
||||||
|
ca_addr = res.span()[0] + 94
|
||||||
|
ca_orig = "0f 11 49 20".replace(" ", "")
|
||||||
|
ca_patch = "66 0f ef c9".replace(" ", "") # PXOR XMM1,XMM1
|
||||||
|
if exe_hex[ca_addr:ca_addr + len(ca_patch)] == ca_orig:
|
||||||
|
exe_hex = exe_hex[:ca_addr] + ca_patch + exe_hex[ca_addr + len(ca_patch):]
|
||||||
|
else:
|
||||||
|
print("er-patcher: disable_ca pattern scan failed")
|
||||||
|
|
||||||
if patch.increase_animation_distance or patch.all:
|
if patch.increase_animation_distance or patch.all:
|
||||||
iad_pattern = "e8 .. .. .. .. 0f 28 .. 0f 28 .. e8 .. .. .. .. f3 0f .. .. 0f 28 .. f3 41 0f 5e 4c 24 54".replace(" ", "")
|
iad_pattern = "e8 .. .. .. .. 0f 28 .. 0f 28 .. e8 .. .. .. .. f3 0f .. .. 0f 28 .. f3 41 0f 5e 4c 24 54".replace(" ", "")
|
||||||
if (res := re.search(iad_pattern, exe_hex)) is not None:
|
if (res := re.search(iad_pattern, exe_hex)) is not None:
|
||||||
|
|
@ -54,44 +92,6 @@ if patch.increase_animation_distance or patch.all:
|
||||||
else:
|
else:
|
||||||
print("er-patcher: increase_animation_distance pattern scan failed")
|
print("er-patcher: increase_animation_distance pattern scan failed")
|
||||||
|
|
||||||
if patch.rate != 60 and patch.rate > 0:
|
|
||||||
r_pattern = "c7 43 20 89 88 88 3c eb 43 89 73 18 eb ca 89 73 18".replace(" ", "")
|
|
||||||
if (res := re.search(r_pattern, exe_hex)) is not None:
|
|
||||||
r_addr = res.span()[0] + 6
|
|
||||||
r_patch = struct.pack('<f', 1 / patch.rate).hex()
|
|
||||||
exe_hex = exe_hex[:r_addr] + r_patch + exe_hex[r_addr + len(r_patch):]
|
|
||||||
else:
|
|
||||||
print("er-patcher: rate pattern scan failed")
|
|
||||||
|
|
||||||
if patch.remove_60_hz_fullscreen or patch.all:
|
|
||||||
fs_pattern = "c7 45 ef 3c 00 00 00".replace(" ", "")
|
|
||||||
if (res := re.search(fs_pattern, exe_hex)) is not None:
|
|
||||||
fs_addr = res.span()[0] + 6
|
|
||||||
fs_patch = "00"
|
|
||||||
exe_hex = exe_hex[:fs_addr] + fs_patch + exe_hex[fs_addr + len(fs_patch):]
|
|
||||||
else:
|
|
||||||
print("er-patcher: remove_60_hz_fullscreen pattern scan failed")
|
|
||||||
|
|
||||||
if patch.remove_ca or patch.all:
|
|
||||||
ca_pattern = "0f 11 43 60 48 8d 8b 80 00 00 00 0f 10 87 a0 00 00 00 0f 11 41 f0 48 8d 87 b0 00 00 00 0f 10 08 0f 11 09".replace(" ", "")
|
|
||||||
if (res := re.search(ca_pattern, exe_hex)) is not None:
|
|
||||||
ca_addr = res.span()[0] + 94
|
|
||||||
ca_orig = "0f 11 49 20".replace(" ", "")
|
|
||||||
ca_patch = "66 0f ef c9".replace(" ", "") # PXOR XMM1,XMM1
|
|
||||||
if exe_hex[ca_addr:ca_addr + len(ca_patch)] == ca_orig:
|
|
||||||
exe_hex = exe_hex[:ca_addr] + ca_patch + exe_hex[ca_addr + len(ca_patch):]
|
|
||||||
else:
|
|
||||||
print("er-patcher: remove_ca pattern scan failed")
|
|
||||||
|
|
||||||
if patch.remove_vignette or patch.all:
|
|
||||||
v_pattern = 'f3 0f 10 .. .. f3 0f 59 .. .. .. .. .. e8 .. .. .. .. f3 41 0f .. .. f3 45 0f .. .. 4c 8d .. .. .. .. .. .. 48'.replace(" ", "")
|
|
||||||
if (res := re.search(v_pattern, exe_hex)) is not None:
|
|
||||||
v_addr = res.span()[0] + 46
|
|
||||||
v_patch = "f3 0f 5c c0 90".replace(" ", "") # SUBSS XMM0,XMM0; NOP; all NOP does work too
|
|
||||||
exe_hex = exe_hex[:v_addr] + v_patch + exe_hex[v_addr + len(v_patch):]
|
|
||||||
else:
|
|
||||||
print("er-patcher: remove_vignette pattern scan failed")
|
|
||||||
|
|
||||||
if patch.skip_intro or patch.all:
|
if patch.skip_intro or patch.all:
|
||||||
si_pattern = "80 bf b8 00 00 00 00 74 53 48".replace(" ", "")
|
si_pattern = "80 bf b8 00 00 00 00 74 53 48".replace(" ", "")
|
||||||
if (res := re.search(si_pattern, exe_hex)) is not None:
|
if (res := re.search(si_pattern, exe_hex)) is not None:
|
||||||
|
|
@ -101,14 +101,14 @@ if patch.increase_animation_distance or patch.all:
|
||||||
else:
|
else:
|
||||||
print("er-patcher: skip_intro pattern scan failed")
|
print("er-patcher: skip_intro pattern scan failed")
|
||||||
|
|
||||||
if patch.ultrawide or patch.all:
|
if patch.remove_60hz_fullscreen or patch.all:
|
||||||
uw_pattern = "74 4f 45 8b 94 cc".replace(" ", "")
|
fs_pattern = "c7 45 ef 3c 00 00 00".replace(" ", "")
|
||||||
if (res := re.search(uw_pattern, exe_hex)) is not None:
|
if (res := re.search(fs_pattern, exe_hex)) is not None:
|
||||||
uw_addr = res.span()[0]
|
fs_addr = res.span()[0] + 6
|
||||||
uw_patch = "eb"
|
fs_patch = "00"
|
||||||
exe_hex = exe_hex[:uw_addr] + uw_patch + exe_hex[uw_addr + len(uw_patch):]
|
exe_hex = exe_hex[:fs_addr] + fs_patch + exe_hex[fs_addr + len(fs_patch):]
|
||||||
else:
|
else:
|
||||||
print("er-patcher: ultrawide pattern scan failed")
|
print("er-patcher: remove_60hz_fullscreen pattern scan failed")
|
||||||
|
|
||||||
game_dir_patched = Path("er-patcher-tmp")
|
game_dir_patched = Path("er-patcher-tmp")
|
||||||
if not game_dir_patched.is_dir():
|
if not game_dir_patched.is_dir():
|
||||||
|
|
@ -128,7 +128,7 @@ if patch.increase_animation_distance or patch.all:
|
||||||
(game_dir_patched / d).mkdir(parents=True)
|
(game_dir_patched / d).mkdir(parents=True)
|
||||||
|
|
||||||
# hard link game files to game_dir_patched; symbolic links would be easier
|
# hard link game files to game_dir_patched; symbolic links would be easier
|
||||||
# to handle, but Windows 10 does not allow them by default
|
# to handle but by default windows 10 doesn't allow them
|
||||||
game_files = [f for f in game_dir.rglob("*") if f.is_file()]
|
game_files = [f for f in game_dir.rglob("*") if f.is_file()]
|
||||||
for f in game_files:
|
for f in game_files:
|
||||||
if f.name in ["eldenring.exe", "er-patcher"]:
|
if f.name in ["eldenring.exe", "er-patcher"]:
|
||||||
|
|
@ -136,9 +136,9 @@ if patch.increase_animation_distance or patch.all:
|
||||||
if not (game_dir_patched / f).is_file():
|
if not (game_dir_patched / f).is_file():
|
||||||
f.link_to(game_dir_patched / f)
|
f.link_to(game_dir_patched / f)
|
||||||
|
|
||||||
# run patched exe directly to avoid EAC
|
# start patched exe directly to avoid EAC
|
||||||
steam_cmd = sys.argv[1 + sys.argv.index("--"):]
|
steam_cmd = sys.argv[1 + sys.argv.index("--"):]
|
||||||
steam_cmd[-1] = Path(steam_cmd[-1]).parent.absolute() / game_dir_patched / ("start_protected_game.exe" if patch.with_eac else "patch.executable")
|
steam_cmd[-1] = Path(steam_cmd[-1]).parent.absolute() / game_dir_patched / ("start_protected_game.exe" if patch.with_eac else patch.executable)
|
||||||
subprocess.run(steam_cmd, cwd=steam_cmd[-1].parent.absolute())
|
subprocess.run(steam_cmd, cwd=steam_cmd[-1].parent.absolute())
|
||||||
|
|
||||||
# cleanup
|
# cleanup
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue