Skip to content

Instantly share code, notes, and snippets.

@samsonjs
Created January 19, 2010 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samsonjs/280635 to your computer and use it in GitHub Desktop.
Save samsonjs/280635 to your computer and use it in GitHub Desktop.
# Appears at the beginning of every Mach object file.
class MachHeader < CStruct
uint32 :magic
int32 :cputype
int32 :cpusubtype
uint32 :filetype
uint32 :ncmds
uint32 :sizeofcmds
uint32 :flags
end
# Values for the magic field.
MH_MAGIC = 0xfeedface # Mach magic number (big-endian)
MH_CIGAM = 0xcefaedfe # Little-endian version
# Values for the filetype field (there are several more)
MH_OBJECT = 0x1
MH_EXECUTE = 0x2
# CPU types and subtypes (only Intel for now).
CPU_TYPE_X86 = 7
CPU_TYPE_I386 = CPU_TYPE_X86
CPU_SUBTYPE_X86_ALL = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment