Sha256: c8d6dd94e2656dbc09025a126bbf30f23c09978716875dbf3624c04e18ce5c98

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

# frozen_string_literal: true

module MooTool
  class KernelCollection < ControllerBase
    command 'kc'
    description 'Kernel Collections'

    def extract(command, output_folder)
      file = MachO.open command.file
      input = File.open(command.file, 'rb')

      file.command(:LC_FILESET_ENTRY).each do |entry|
        output_path = File.join(output_folder, entry.entry_id.to_s)
        puts "Writing to #{output_path}"
        output_file = File.open(output_path, 'wb')
        matching = file.command(:LC_SEGMENT_64).find { |command| command.fileoff == entry.fileoff }

        input.seek(matching.fileoff)
        output_file.write input.read(matching.filesize)
        output_file.close
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mootool-0.1.2 lib/mootool/controllers/kernel_collection.rb
mootool-0.1.1 lib/mootool/controllers/kernel_collection.rb
mootool-0.1.0 lib/mootool/controllers/kernel_collection.rb