Module: MachO
- Defined in:
- lib/macho.rb,
lib/macho/view.rb,
lib/macho/tools.rb,
lib/macho/utils.rb,
lib/macho/headers.rb,
lib/macho/fat_file.rb,
lib/macho/sections.rb,
lib/macho/structure.rb,
lib/macho/exceptions.rb,
lib/macho/macho_file.rb,
lib/macho/code_signing.rb,
lib/macho/load_commands.rb
Overview
The primary namespace for ruby-macho.
Defined Under Namespace
Modules: CodeSigning, Headers, LoadCommands, Sections, Tools, Utils Classes: CPUSubtypeError, CPUTypeError, CPUTypeMismatchError, CodeSigningError, CompressedMachOError, DecompressionError, DylibIdMissingError, DylibUnknownError, FatArchOffsetOverflowError, FatBinaryError, FatFile, FiletypeError, HeaderPadError, JavaClassFileError, LCStrMalformedError, LoadCommandCreationArityError, LoadCommandError, LoadCommandNotCreatableError, LoadCommandNotSerializableError, LoadCommandSizeError, MachOBinaryError, MachOError, MachOFile, MachOStructure, MachOView, MagicError, ModificationError, NotAMachOError, OffsetInsertionError, RecoverableModificationError, RpathExistsError, RpathUnknownError, TruncatedFileError, UnimplementedError, ZeroArchitectureError
Constant Summary collapse
- VERSION =
release version
"6.0.0"
Class Method Summary collapse
-
.codesign!(filename) ⇒ void
Signs a thin or fat Mach-O using an ad-hoc identity.
-
.open(filename) ⇒ MachOFile, FatFile
Opens the given filename as a MachOFile or FatFile, depending on its magic.
Class Method Details
.codesign!(filename) ⇒ void
This method returns an undefined value.
Signs a thin or fat Mach-O using an ad-hoc identity. Necessary after changing signed Mach-O data because the signature covers the header, load commands and all bytes preceding the signature.
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/macho.rb', line 50 def self.codesign!(filename) raise ArgumentError, "#{filename}: no such file" unless File.file?(filename) file = MachO.open(filename) file.codesign! file.write! nil rescue MachOError => e raise CodeSigningError, "#{filename}: signing failed: #{e.}" end |
.open(filename) ⇒ MachOFile, FatFile
Opens the given filename as a MachOFile or FatFile, depending on its magic.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/macho.rb', line 27 def self.open(filename) raise ArgumentError, "#{filename}: no such file" unless File.file?(filename) raise TruncatedFileError unless File.stat(filename).size >= 4 magic = File.open(filename, "rb") { |f| f.read(4) }.unpack1("N") if Utils.fat_magic?(magic) file = FatFile.new(filename) elsif Utils.magic?(magic) file = MachOFile.new(filename) else raise MagicError, magic end file end |