Class: Nitro::OverlayBin

Inherits:
CodeBin show all
Includes:
NitroBind
Defined in:
lib/nitro/nitro.rb

Instance Attribute Summary collapse

Attributes inherited from CodeBin

#functions

Instance Method Summary collapse

Methods inherited from CodeBin

#bounds, #disasm_function, #each_arm_instruction, #each_byte, #each_char, #each_dword, #each_hword, #each_thumb_instruction, #each_word, #end_address, #find_hex, #get_function, #get_location, #get_section_ptr, #read, #read16, #read32, #read64, #read8, #read_arm_instruction, #read_cstring, #read_thumb_instruction, #reloc_function, #size, #start_address

Constructor Details

#initialize(id, args = {}) ⇒ OverlayBin

Returns a new instance of OverlayBin.



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/nitro/nitro.rb', line 298

def initialize(id, args = {})
  @id = id
  if [:file_path, :ram_addr, :is_compressed].all? { |k| args.key?(k) }
    @ptr = FFI::AutoPointer.new(overlayBin_alloc, method(:overlayBin_release))
    if !File.exist? args[:file_path]
      puts "Error: #{args[:file_path]} does not exist"
      raise "OverlayBin initialization failed"
    end
    overlayBin_load(@ptr, args[:file_path], args[:ram_addr], args[:is_compressed], @id)

  elsif args.has_key?(:ptr) && args[:ptr].is_a?(FFI::AutoPointer)
    @ptr = args[:ptr]

  else
    raise ArgumentError, 'OverlayBin must be initialized with a file or a pointer'
  end
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



296
297
298
# File 'lib/nitro/nitro.rb', line 296

def id
  @id
end