lib/macho/macho_file.rb
# Attempt to decompress a Mach-O file from the data specified in a prelinked kernel header.
# @return [void]
# @raise [DecompressionError] if decompression is impossible or fails
# @api private
# @note This method rewrites the internal state of {MachOFile} to pretend as if it was never
#  compressed to begin with, allowing all other APIs to transparently act on compressed Mach-Os.
Attempt to decompress a Mach-O file from the data specified in a prelinked kernel header.
Attempt to decompress a Mach - O file from the data specified in a prelinked kernel header .
def decompress_macho_lzvn
      begin
        require "lzfse"
      rescue LoadError
        raise DecompressionError, "LZVN required but the optional 'lzfse' gem is not installed"
      end
      begin
        @raw_data = LZFSE.lzvn_decompress @raw_data.slice(Headers::PrelinkedKernelHeader.bytesize, @plh.compressed_size)
        raise DecompressionError if @raw_data.size != @plh.uncompressed_size
      rescue LZFSE::DecodeError
        raise DecompressionError, "LZVN decompression failed"
      end
    end
def decompress_macho_lzvn begin require "lzfse" rescue LoadError raise DecompressionError , "LZVN required but the optional 'lzfse' gem is not installed" end begin @raw_data = LZFSE . lzvn_decompress @raw_data . slice ( Headers :: PrelinkedKernelHeader . bytesize , @plh . compressed_size ) raise DecompressionError if @raw_data . size != @plh . uncompressed_size rescue LZFSE :: DecodeError raise DecompressionError , "LZVN decompression failed" end end
Attempt to decompress a Mach-O file from the data specified in a prelinked kernel header.
Attempt to decompress a Mach - O file from the data specified in a prelinked kernel header .
# From this point onwards, the internal buffer of this MachOFile refers to the decompressed # contents specified by the prelinked kernel header. # Sanity checks. # TODO: check the adler32 CRC in @plh
None
void
[DecompressionError] if decompression is impossible or fails
[ DecompressionError ] if decompression is impossible or fails
api
None
note
This method rewrites the internal state of {MachOFile} to pretend as if it was never compressed to begin with, allowing all other APIs to transparently act on compressed Mach-Os.
This method rewrites the internal state of { MachOFile } to pretend as if it was never compressed to begin with allowing all other APIs to transparently act on compressed Mach - Os .