Skip to content

Commit

Permalink
Always hook, but split out API hooks (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
jmctune authored Oct 8, 2023
1 parent de7d70a commit 6acb620
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 5 additions & 3 deletions app/hooking/hook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down
11 changes: 3 additions & 8 deletions app/main.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -18,7 +13,6 @@
import sys
import threading
import time
import traceback


# fmt: off
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 6acb620

Please sign in to comment.