From 6acb620c0564a1e80af3b9524b4869c0a91e6684 Mon Sep 17 00:00:00 2001 From: Joey <17505625+jmctune@users.noreply.github.com> Date: Sun, 8 Oct 2023 11:25:14 -0500 Subject: [PATCH] Always hook, but split out API hooks (#122) --- app/hooking/hook.py | 8 +++++--- app/main.py | 11 +++-------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/app/hooking/hook.py b/app/hooking/hook.py index 9095fe8..17baa0e 100644 --- a/app/hooking/hook.py +++ b/app/hooking/hook.py @@ -131,7 +131,7 @@ def player_name_detour(simple_str_addr: int): return hook_obj -def activate_hooks(player_names: bool): +def activate_hooks(player_names: bool, communication_window: bool): """Activates all hooks and kicks off hook manager.""" # configure logging. this function runs in multiprocessing, so it does not # have the same access to the main log handler. @@ -145,11 +145,13 @@ def activate_hooks(player_names: bool): # activates all hooks. add any new hooks to this list hooks = [] - hooks.append(translate_detour(simple_str_addr=simple_str_addr)) - hooks.append(quest_text_detour(simple_str_addr=simple_str_addr)) hooks.append(player_name_detour(simple_str_addr=simple_str_addr)) hooks.append(network_text_detour(simple_str_addr=simple_str_addr)) + if communication_window: + hooks.append(translate_detour(simple_str_addr=simple_str_addr)) + hooks.append(quest_text_detour(simple_str_addr=simple_str_addr)) + # construct our asm to detach hooks unhook_bytecode = b"" for hook in hooks: diff --git a/app/main.py b/app/main.py index 2f436c2..4ddd3d9 100644 --- a/app/main.py +++ b/app/main.py @@ -1,10 +1,5 @@ from common.db_ops import ensure_db_structure -from common.lib import ( - get_project_root, - is_dqx_process_running, - setup_logging, - wait_for_dqx_to_launch, -) +from common.lib import get_project_root, setup_logging, wait_for_dqx_to_launch from common.update import ( check_for_updates, download_custom_files, @@ -18,7 +13,6 @@ import sys import threading import time -import traceback # fmt: off @@ -76,8 +70,9 @@ def start_process(name: str, target, args: tuple): while not p.is_alive(): time.sleep(0.25) + start_process(name="Hook loader", target=activate_hooks, args=(player_names,communication_window,)) + if communication_window: - start_process(name="Hook loader", target=activate_hooks, args=(player_names,)) start_process(name="Walkthrough scanner", target=loop_scan_for_walkthrough, args=()) if community_logging: