Class: MachO::Headers::PrelinkedKernelHeader

Inherits:
MachOStructure show all
Defined in:
lib/macho/headers.rb

Overview

Prelinked kernel/"kernelcache" header structure

Constant Summary collapse

FORMAT =

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

"L>6a40a64a256"
SIZEOF =

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

384

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from MachOStructure

bytesize, new_from_bin

Constructor Details

#initialize(signature, compress_type, adler32, uncompressed_size, compressed_size, prelink_version, reserved, platform_name, root_path) ⇒ PrelinkedKernelHeader

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 PrelinkedKernelHeader.



853
854
855
856
857
858
859
860
861
862
863
864
865
# File 'lib/macho/headers.rb', line 853

def initialize(signature, compress_type, adler32, uncompressed_size, compressed_size, prelink_version, reserved, platform_name, root_path)
  super()

  @signature = signature
  @compress_type = compress_type
  @adler32 = adler32
  @uncompressed_size = uncompressed_size
  @compressed_size = compressed_size
  @prelink_version = prelink_version
  @reserved = reserved.unpack("L>10")
  @platform_name = platform_name
  @root_path = root_path
end

Instance Attribute Details

#adler32Integer (readonly)

Returns a checksum for the uncompressed data.

Returns:

  • (Integer)

    a checksum for the uncompressed data



824
825
826
# File 'lib/macho/headers.rb', line 824

def adler32
  @adler32
end

#compress_typeInteger (readonly)

Returns the type of compression used.

Returns:

  • (Integer)

    the type of compression used



821
822
823
# File 'lib/macho/headers.rb', line 821

def compress_type
  @compress_type
end

#compressed_sizeInteger (readonly)

Returns the size of the compressed data, in bytes.

Returns:

  • (Integer)

    the size of the compressed data, in bytes



830
831
832
# File 'lib/macho/headers.rb', line 830

def compressed_size
  @compressed_size
end

#platform_namevoid (readonly)

This method returns an undefined value.



839
840
841
# File 'lib/macho/headers.rb', line 839

def platform_name
  @platform_name
end

Returns the version of the prelink format.

Returns:

  • (Integer)

    the version of the prelink format



833
834
835
# File 'lib/macho/headers.rb', line 833

def prelink_version
  @prelink_version
end

#reservedvoid (readonly)

This method returns an undefined value.



836
837
838
# File 'lib/macho/headers.rb', line 836

def reserved
  @reserved
end

#root_pathvoid (readonly)

This method returns an undefined value.



842
843
844
# File 'lib/macho/headers.rb', line 842

def root_path
  @root_path
end

#signatureInteger (readonly)

Returns the magic number for a compressed header (COMPRESSED_MAGIC).

Returns:



818
819
820
# File 'lib/macho/headers.rb', line 818

def signature
  @signature
end

#uncompressed_sizeInteger (readonly)

Returns the size of the uncompressed data, in bytes.

Returns:

  • (Integer)

    the size of the uncompressed data, in bytes



827
828
829
# File 'lib/macho/headers.rb', line 827

def uncompressed_size
  @uncompressed_size
end

Instance Method Details

#kaslr?Boolean

Returns whether this prelinked kernel supports KASLR.

Returns:

  • (Boolean)

    whether this prelinked kernel supports KASLR



868
869
870
# File 'lib/macho/headers.rb', line 868

def kaslr?
  prelink_version >= 1
end

#lzss?Boolean

Returns whether this prelinked kernel is compressed with LZSS.

Returns:

  • (Boolean)

    whether this prelinked kernel is compressed with LZSS



873
874
875
# File 'lib/macho/headers.rb', line 873

def lzss?
  compress_type == COMP_TYPE_LZSS
end

#lzvn?Boolean

Returns whether this prelinked kernel is compressed with LZVN.

Returns:

  • (Boolean)

    whether this prelinked kernel is compressed with LZVN



878
879
880
# File 'lib/macho/headers.rb', line 878

def lzvn?
  compress_type == COMP_TYPE_FASTLIB
end

#to_hHash

Returns a hash representation of this MachO::Headers::PrelinkedKernelHeader.

Returns:



883
884
885
886
887
888
889
890
891
892
893
894
895
# File 'lib/macho/headers.rb', line 883

def to_h
  {
    "signature" => signature,
    "compress_type" => compress_type,
    "adler32" => adler32,
    "uncompressed_size" => uncompressed_size,
    "compressed_size" => compressed_size,
    "prelink_version" => prelink_version,
    "reserved" => reserved,
    "platform_name" => platform_name,
    "root_path" => root_path,
  }.merge super
end