From 00a2f1a7d68f4c4bd0b67cfde319661d1d5220c3 Mon Sep 17 00:00:00 2001 From: hakril Date: Sat, 18 Jan 2025 22:35:38 +0100 Subject: [PATCH] add utils.image_file_machine_to_processor_architecture() --- windows/utils/winutils.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/windows/utils/winutils.py b/windows/utils/winutils.py index 1220333..f7ffee3 100644 --- a/windows/utils/winutils.py +++ b/windows/utils/winutils.py @@ -36,14 +36,6 @@ def get_remote_func_addr(target, dll_name, func_name): return mod.pe.exports[func_name] -def is_wow_64(handle): - if not windows.winproxy.is_implemented(windows.winproxy.IsWow64Process): - return False - Wow64Process = gdef.BOOL() - windows.winproxy.IsWow64Process(handle, Wow64Process) - return bool(Wow64Process) - - def create_file_from_handle(handle, mode="r"): """Return a Python :class:`file` around a ``Windows`` HANDLE""" flags = os.O_BINARY if "b" in mode else os.O_TEXT @@ -295,6 +287,16 @@ def datetime_from_systemtime(systime): microsecond=systime.wMilliseconds * 1000, ) +IMAGE_FILE_MACHINE_TO_PROC_ARCH = { + gdef.IMAGE_FILE_MACHINE_I386: gdef.PROCESSOR_ARCHITECTURE_INTEL, + gdef.IMAGE_FILE_MACHINE_AMD64: gdef.PROCESSOR_ARCHITECTURE_AMD64, + gdef.IMAGE_FILE_MACHINE_ARM64: gdef.PROCESSOR_ARCHITECTURE_ARM64, + gdef:IMAGE_FILE_MACHINE_UNKNOWN: gdef.PROCESSOR_ARCHITECTURE_UNKNOWN +} + +def image_file_machine_to_processor_architecture(image_file_machine): + return IMAGE_FILE_MACHINE_TO_PROC_ARCH[image_file_machine] + class FixedInteractiveConsole(code.InteractiveConsole): def raw_input(self, prompt=">>>"): sys.stdout.write(prompt)