From 372848c321795a9c7dfd2dc9471e5e8881d96a14 Mon Sep 17 00:00:00 2001 From: Karmaz95 Date: Wed, 6 Nov 2024 17:48:18 +0100 Subject: [PATCH] Generate Mach-O files with ARM64 headers for specified file types. --- I. Mach-O/python/create_macho_samples.py | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 I. Mach-O/python/create_macho_samples.py diff --git a/I. Mach-O/python/create_macho_samples.py b/I. Mach-O/python/create_macho_samples.py new file mode 100644 index 0000000..d79a9c5 --- /dev/null +++ b/I. Mach-O/python/create_macho_samples.py @@ -0,0 +1,43 @@ +import struct + +# Mach-O magic number for 64-bit +MAGIC_64 = 0xFEEDFACF + +# Correct file type codes for each specified Mach-O file type +file_types = { + "FVMLIB": 0x3, # MH_FVMLIB + "PRELOAD": 0x5, # MH_PRELOAD + "CORE": 0x4, # MH_CORE + "DYLIB_STUB": 0x9, # MH_DYLIB_STUB +} + +def create_macho_file(file_type_name, file_type_code): + # Updated settings for ARM64 architecture + magic = MAGIC_64 + cpu_type = 0x100000C # CPU_TYPE_ARM64 + cpu_subtype = 0x0 # ARM64 subtype + ncmds = 0 # Number of load commands + sizeofcmds = 0 # Total size of all load commands + flags = 0x0 # No special flags + + # Pack the Mach-O header for a 64-bit file + header = struct.pack( + "