Class: Nitro::ArmBin

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

Defined Under Namespace

Classes: AutoLoadEntry, ModuleParams

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(args = {}) ⇒ ArmBin

Returns a new instance of ArmBin.



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/nitro/nitro.rb', line 257

def initialize(args = {})
  if args.has_key? :file_path
    @ptr = FFI::AutoPointer.new(armBin_alloc, method(:armBin_release))
    if !File.exist?(args[:file_path])
      puts "Error: #{args[:file_path]} does not exist"
      raise 'ArmBin initialization failed'
    end
    armBin_load(@ptr, args[:file_path], args[:entry_addr], args[:ram_addr], args[:auto_load_hook_offset],
                args[:is_arm9] || true)

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

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

  @module_params = ModuleParams.new(armBin_getModuleParams(@ptr))
  @autoload_entries = []
  autoload_entry_count = armBin_getAutoloadEntryCount(@ptr)
  autoload_entry_count.times {|id| autoload_entries << AutoLoadEntry.new(armBin_getAutoloadEntry(@ptr,id)) }
end

Instance Attribute Details

#autoload_entriesObject (readonly)

Returns the value of attribute autoload_entries.



236
237
238
# File 'lib/nitro/nitro.rb', line 236

def autoload_entries
  @autoload_entries
end

#module_paramsObject (readonly)

Returns the value of attribute module_params.



236
237
238
# File 'lib/nitro/nitro.rb', line 236

def module_params
  @module_params
end

Instance Method Details

#entry_point_addressObject Also known as: entry_addr, entry_point_addr



280
281
282
# File 'lib/nitro/nitro.rb', line 280

def entry_point_address
  armBin_getEntryPointAddress(@ptr)
end

#sane_address?(addr) ⇒ Boolean Also known as: sane_addr?

Returns:

  • (Boolean)


286
287
288
# File 'lib/nitro/nitro.rb', line 286

def sane_address?(addr)
  armBin_sanityCheckAddress(@ptr, addr)
end