From d66204ce9cdf93f0e5774b6184c6a062f903d967 Mon Sep 17 00:00:00 2001 From: cosine0 Date: Thu, 3 Dec 2020 14:14:07 +0900 Subject: [PATCH] clarify code --- dllhook/main.py | 11 +++++------ dllhook/mayhem | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/dllhook/main.py b/dllhook/main.py index a87311f..45bdc45 100644 --- a/dllhook/main.py +++ b/dllhook/main.py @@ -27,7 +27,7 @@ def main(): args = parser.parse_args() exe_path = args.exe - script_path = args.python_script + script_path = os.path.abspath(args.python_script) pid = subprocess.Popen(exe_path).pid injector_path = os.path.join(SCRIPT_DIR, 'mayhem', 'tools', 'python_injector.py') @@ -38,12 +38,11 @@ def main(): else: envs['PATH'] = INTERPRETER_DIR - f = tempfile.NamedTemporaryFile(suffix='.py', delete=False) - formatted_script = injected_script.format(working_dir=os.path.abspath(os.curdir), - import_path=script_path).encode('utf8') + with tempfile.NamedTemporaryFile(suffix='.py', delete=False) as f: + formatted_script = injected_script.format(working_dir=os.path.abspath(os.curdir), + import_path=script_path).encode('utf8') - f.write(formatted_script) - f.close() + f.write(formatted_script) subprocess.Popen([sys.executable, injector_path, f.name, str(pid)], env=envs).wait() diff --git a/dllhook/mayhem b/dllhook/mayhem index a8d7efe..c5fca48 160000 --- a/dllhook/mayhem +++ b/dllhook/mayhem @@ -1 +1 @@ -Subproject commit a8d7efe074b8f09fafadfa86a36f0a0fe4632b6c +Subproject commit c5fca48dd9a4022e0a6fd9fca430d73811955ff5