Skip to content

Commit

Permalink
add utils.image_file_machine_to_processor_architecture()
Browse files Browse the repository at this point in the history
  • Loading branch information
hakril committed Jan 18, 2025
1 parent 0d481ca commit f774769
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions windows/utils/winutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f774769

Please sign in to comment.