Module: Pliney::MachO
Defined Under Namespace
Modules: LoadCommandConst
Classes: CommonDylibCommandReader, CommonEncryptionInfoReader, CommonLCReader, CommonLinkeditDataCommandReader, CommonMachHeaderReader, CommonSectionReader, CommonSegmentReader, DylibStructReader, FatArchReader, FatHeaderReader, LC_CODE_SIGNATURE_Reader, LC_DATA_IN_CODE_Reader, LC_DYLIB_CODE_SIGN_DRS_Reader, LC_ENCRYPTION_INFO_64_Reader, LC_ENCRYPTION_INFO_Reader, LC_FUNCTION_STARTS_Reader, LC_ID_DYLIB_Reader, LC_LINKER_OPTIMIZATION_HINT_Reader, LC_LOAD_DYLIB_Reader, LC_LOAD_WEAK_DYLIB_Reader, LC_REEXPORT_DYLIB_Reader, LC_RPATH_Reader, LC_SEGMENT_64_Reader, LC_SEGMENT_Reader, LC_SEGMENT_SPLIT_INFO_Reader, MachHeader64Reader, MachHeaderReader, Reader, ReaderError, Section64Reader, SectionReader, UndefinedLCReader
Constant Summary
collapse
- FAT_MAGIC =
0xCAFEBABE
- MACHO_MAGIC32 =
0xCEFAEDFE
- MACHO_MAGIC64 =
0xCFFAEDFE
- LC_REQ_DYLD =
0x80000000
LoadCommandConst::LC_BUILD_VERSION, LoadCommandConst::LC_CODE_SIGNATURE, LoadCommandConst::LC_DATA_IN_CODE, LoadCommandConst::LC_DYLD_ENVIRONMENT, LoadCommandConst::LC_DYLD_INFO, LoadCommandConst::LC_DYLD_INFO_ONLY, LoadCommandConst::LC_DYLIB_CODE_SIGN_DRS, LoadCommandConst::LC_DYSYMTAB, LoadCommandConst::LC_ENCRYPTION_INFO, LoadCommandConst::LC_ENCRYPTION_INFO_64, LoadCommandConst::LC_FUNCTION_STARTS, LoadCommandConst::LC_FVMFILE, LoadCommandConst::LC_IDENT, LoadCommandConst::LC_IDFVMLIB, LoadCommandConst::LC_ID_DYLIB, LoadCommandConst::LC_ID_DYLINKER, LoadCommandConst::LC_LAZY_LOAD_DYLIB, LoadCommandConst::LC_LINKER_OPTIMIZATION_HINT, LoadCommandConst::LC_LINKER_OPTION, LoadCommandConst::LC_LOADFVMLIB, LoadCommandConst::LC_LOAD_DYLIB, LoadCommandConst::LC_LOAD_DYLINKER, LoadCommandConst::LC_LOAD_UPWARD_DYLIB, LoadCommandConst::LC_LOAD_WEAK_DYLIB, LoadCommandConst::LC_MAIN, LoadCommandConst::LC_NOTE, LoadCommandConst::LC_PREBIND_CKSUM, LoadCommandConst::LC_PREBOUND_DYLIB, LoadCommandConst::LC_PREPAGE, LoadCommandConst::LC_REEXPORT_DYLIB, LoadCommandConst::LC_ROUTINES, LoadCommandConst::LC_ROUTINES_64, LoadCommandConst::LC_RPATH, LoadCommandConst::LC_SEGMENT, LoadCommandConst::LC_SEGMENT_64, LoadCommandConst::LC_SEGMENT_SPLIT_INFO, LoadCommandConst::LC_SOURCE_VERSION, LoadCommandConst::LC_SUB_CLIENT, LoadCommandConst::LC_SUB_FRAMEWORK, LoadCommandConst::LC_SUB_LIBRARY, LoadCommandConst::LC_SUB_UMBRELLA, LoadCommandConst::LC_SYMSEG, LoadCommandConst::LC_SYMTAB, LoadCommandConst::LC_THREAD, LoadCommandConst::LC_TWOLEVEL_HINTS, LoadCommandConst::LC_UNIXTHREAD, LoadCommandConst::LC_UUID, LoadCommandConst::LC_VERSION_MIN_IPHONEOS, LoadCommandConst::LC_VERSION_MIN_MACOSX, LoadCommandConst::LC_VERSION_MIN_TVOS, LoadCommandConst::LC_VERSION_MIN_WATCHOS
Class Method Summary
collapse
Class Method Details
.is_fat_magic(magicval) ⇒ Object
17
18
19
|
# File 'lib/pliney/macho.rb', line 17
def self.is_fat_magic(magicval)
return (magicval == FAT_MAGIC)
end
|
.is_macho32_magic(magicval) ⇒ Object
25
26
27
|
# File 'lib/pliney/macho.rb', line 25
def self.is_macho32_magic(magicval)
return (magicval == MACHO_MAGIC32)
end
|
.is_macho64_magic(magicval) ⇒ Object
29
30
31
|
# File 'lib/pliney/macho.rb', line 29
def self.is_macho64_magic(magicval)
return (magicval == MACHO_MAGIC64)
end
|
.is_macho_magic(magicval) ⇒ Object
21
22
23
|
# File 'lib/pliney/macho.rb', line 21
def self.is_macho_magic(magicval)
return (is_macho32_magic(magicval) or is_macho64_magic(magicval))
end
|
.lcmap ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/pliney/macho.rb', line 33
def self.lcmap
@LCMAP ||= Hash[
LoadCommandConst.constants.map do |lc|
[lc, LoadCommandConst.const_get(lc)]
end
]
end
|
.read_stream(fh) ⇒ Object
69
70
71
72
73
|
# File 'lib/pliney/macho.rb', line 69
def self.read_stream(fh)
magic = fh.read_uint32
fh.pos -= 4
return reader_for_filemagic(magic).parse(fh)
end
|
.reader_for_filemagic(magic) ⇒ Object
.reader_for_lc(lcnum) ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/pliney/macho.rb', line 45
def self.reader_for_lc(lcnum)
lcsym = lcmap.invert[lcnum]
if lcsym
klname = "#{lcsym}_Reader"
if MachO.const_defined?(klname)
return MachO.const_get(klname)
end
end
return UndefinedLCReader
end
|
.resolve_lc(lcnum) ⇒ Object
41
42
43
|
# File 'lib/pliney/macho.rb', line 41
def self.resolve_lc(lcnum)
lcmap.invert[lcnum]
end
|