Class: MachO::LoadCommand::LCStr

Inherits:
Object
  • Object
show all
Defined in:
lib/macho/load_commands.rb

Overview

Represents a Load Command string. A rough analogue to the lc_str struct used internally by OS X. This class allows ruby-macho to pretend that strings stored in LCs are immediately available without explicit operations on the raw Mach-O data.

Instance Method Summary collapse

Constructor Details

#initialize(raw_data, lc, lc_str) ⇒ LCStr

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of LCStr.

Parameters:

  • raw_data (String)

    the raw Mach-O data.

  • lc (MachO::LoadCommand)

    the load command

  • lc_str (Fixnum)

    the offset to the beginning of the string



190
191
192
193
194
195
# File 'lib/macho/load_commands.rb', line 190

def initialize(raw_data, lc, lc_str)
  @raw_data = raw_data
  @lc = lc
  @lc_str = lc_str
  @str = @raw_data.slice(@lc.offset + @lc_str...@lc.offset + @lc.cmdsize).delete("\x00")
end

Instance Method Details

#to_iFixnum

Returns the offset to the beginning of the string in the load command.

Returns:

  • (Fixnum)

    the offset to the beginning of the string in the load command



203
204
205
# File 'lib/macho/load_commands.rb', line 203

def to_i
  @lc_str
end

#to_sString

Returns a string representation of the LCStr.

Returns:

  • (String)

    a string representation of the LCStr



198
199
200
# File 'lib/macho/load_commands.rb', line 198

def to_s
  @str
end