aboutsummaryrefslogtreecommitdiffstats
path: root/machoparse/macho.h
diff options
context:
space:
mode:
authorCameron Katri <me@cameronkatri.com>2022-05-20 10:42:38 -0400
committerCameron Katri <me@cameronkatri.com>2022-05-20 10:42:38 -0400
commitaa035f73ce081b3f07247bd15860d72355a096b2 (patch)
tree170a83f5aa816f936df5ae906f20da3fb6b9404e /machoparse/macho.h
downloadtrustcache-aa035f73ce081b3f07247bd15860d72355a096b2.tar.gz
trustcache-aa035f73ce081b3f07247bd15860d72355a096b2.zip
Initial import
Diffstat (limited to 'machoparse/macho.h')
-rw-r--r--machoparse/macho.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/machoparse/macho.h b/machoparse/macho.h
new file mode 100644
index 0000000..858fded
--- /dev/null
+++ b/machoparse/macho.h
@@ -0,0 +1,73 @@
+#include <sys/types.h>
+
+typedef int cpu_type_t;
+typedef int cpu_subtype_t;
+
+struct mach_header {
+ uint32_t magic;
+ cpu_type_t cputype;
+ cpu_subtype_t cpusubtype;
+ uint32_t filetype;
+ uint32_t ncmds;
+ uint32_t sizeofcmds;
+ uint32_t flags;
+};
+
+
+#define MH_MAGIC 0xfeedface
+#define MH_CIGAM 0xcefaedfe
+
+struct mach_header_64 {
+ uint32_t magic;
+ cpu_type_t cputype;
+ cpu_subtype_t cpusubtype;
+ uint32_t filetype;
+ uint32_t ncmds;
+ uint32_t sizeofcmds;
+ uint32_t flags;
+ uint32_t reserved;
+};
+
+#define MH_MAGIC_64 0xfeedfacf
+#define MH_CIGAM_64 0xcffaedfe
+
+struct load_command {
+ uint32_t cmd;
+ uint32_t cmdsize;
+};
+
+#define LC_CODE_SIGNATURE 0x1d
+
+struct linkedit_data_command {
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint32_t dataoff;
+ uint32_t datasize;
+};
+
+struct fat_header {
+ uint32_t magic;
+ uint32_t nfat_arch;
+};
+
+#define FAT_MAGIC 0xcafebabe
+#define FAT_CIGAM 0xbebafeca
+
+struct fat_arch {
+ cpu_type_t cputype;
+ cpu_subtype_t cpusubtype;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t align;
+};
+
+#define FAT_MAGIC_64 0xcafebabf
+#define FAT_CIGAM_64 0xbfbafeca
+
+struct fat_arch_64 {
+ cpu_type_t cputype;
+ cpu_subtype_t cpusubtype;
+ uint32_t offset;
+ uint32_t size;
+ uint32_t align;
+};