Class: DsymUuidExtractor::MachOReader

Inherits:
Object
  • Object
show all
Defined in:
lib/dsym_uuid_extractor/macho_reader.rb

Overview

Direct Known Subclasses

MachOBinaryReader, MachOFileReader

Defined Under Namespace

Classes: ArchIsNil, EmptySymbolicationFile, MachOReaderError, UnkownCpuSubtype, UnkownCpuType

Constant Summary collapse

CPU_ARCH_ABI64 =

Constants CPU Types

0x01000000
CPU_TYPE_I386 =
7
CPU_TYPE_X86_64 =
CPU_TYPE_I386 | CPU_ARCH_ABI64
CPU_TYPE_ARM =
12
CPU_TYPE_ARM64 =
CPU_TYPE_ARM | CPU_ARCH_ABI64
CPU_SUBTYPE_ARM_V7 =

CPU Subtypes

9
CPU_SUBTYPE_ARM_V7S =
11

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ MachOReader

Methods



22
23
24
25
26
# File 'lib/dsym_uuid_extractor/macho_reader.rb', line 22

def initialize(opts = {})
  @file = File.open(opts[:file_path], mode: 'rb')

  @file.seek(opts[:seek_to_pos]) if opts[:seek_to_pos]
end

Instance Attribute Details

#fileObject (readonly)

Readers



19
20
21
# File 'lib/dsym_uuid_extractor/macho_reader.rb', line 19

def file
  @file
end

Instance Method Details

#read_struct(struct_class, opts = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/dsym_uuid_extractor/macho_reader.rb', line 28

def read_struct(struct_class, opts = {})
  struct_size = struct_class.size
  buffer      = FFI::Buffer.new(:char, struct_size)
  buffer      = buffer.order(opts[:byte_order]) if opts[:byte_order]

  buffer.put_bytes(0, @file.read(struct_size))

  struct_class.new(buffer)
end