Package ghidra.app.util.bin.format.macho.dyld

# Class DyldCacheHeader

java.lang.Object
ghidra.app.util.bin.format.macho.dyld.DyldCacheHeader

All Implemented Interfaces:
  `StructConverter`

public class DyldCacheHeader extends Object implements StructConverter
Represents a dyld_cache_header structure.

See Also:
  - dyld_cache_format.h

- ## Field Summary

  ### Fields inherited from interface ghidra.app.util.bin.StructConverter

  `ASCII, BYTE, DWORD, IBO32, IBO64, POINTER, QWORD, SLEB128, STRING, ULEB128, UTF16, UTF8, VOID, WORD`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DyldCacheHeader(BinaryReader reader)`
  Create a new `DyldCacheHeader`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `DyldArchitecture`
  `getArchitecture()`
  Gets architecture information.
  `long`
  `getBaseAddress()`
  Gets the base address of the DYLD cache.
  `List<Long>`
  `getBranchPoolAddresses()`
  Gets the `List` of branch pool address.
  `List<DyldCacheMappingAndSlideInfo>`
  `getCacheMappingAndSlideInfos()`
  Gets the `List` of `DyldCacheMappingAndSlideInfo`s.
  `Long`
  `getEntryPoint()`
  Gets the DYLD entry point address (if known)
  `int`
  `getImagesCount()`
  Gets the number of `DyldCacheImageInfo`s.
  `int`
  `getImagesOffset()`
  Gets the file offset to first `DyldCacheImageInfo`.
  `DyldCacheLocalSymbolsInfo`
  `getLocalSymbolsInfo()`
  Gets the `DyldCacheLocalSymbolsInfo`.
  `byte[]`
  `getMagic()`
  Gets the magic bytes, which contain version information.
  `List<DyldCacheImage>`
  `getMappedImages()`
  Generates a `List` of `DyldCacheImage`s that are mapped in by this `DyldCacheHeader`.
  `List<DyldCacheMappingInfo>`
  `getMappingInfos()`
  Gets the `List` of `DyldCacheMappingInfo`s.
  `List<DyldCacheSlideInfoCommon>`
  `getSlideInfos()`
  Gets the `List` of `DyldCacheSlideInfoCommon`s.
  `List<DyldSubcacheEntry>`
  `getSubcacheEntries()`
  Gets the `List` of `DyldSubcacheEntry`s.
  `String`
  `getSymbolFileUUID()`
  Gets the symbol file UUID in `String` form
  `String`
  `getUUID()`
  Gets the UUID in `String` form
  `boolean`
  `hasAccelerateInfo()`
  Checks to see whether or not the old accelerate info fields are being used
  `boolean`
  `hasSlideInfo()`
  Checks to see if any slide info exists
  `boolean`
  `isSubcache()`
  Checks to see whether or not this is a subcache
  `void`
  `markup(Program program, boolean markupLocalSymbols, AddressSpace space, TaskMonitor monitor, MessageLog log)`
  Marks up this `DyldCacheHeader` with data structures and comments.
  `void`
  `parseFromFile(boolean parseLocalSymbols, MessageLog log, TaskMonitor monitor)`
  Parses the structures referenced by this `DyldCacheHeader` from a file.
  `void`
  `parseFromMemory(Program program, AddressSpace space, MessageLog log, TaskMonitor monitor)`
  Parses the structures referenced by this `DyldCacheHeader` from memory.
  `void`
  `parseLocalSymbolsInfo(boolean shouldParse, MessageLog log, TaskMonitor monitor)`
  `void`
  `setFileBlock(MemoryBlock block)`
  Sets the `MemoryBlock` associated with this header's FILE block.
  `DataType`
  `toDataType()`
  Returns a structure datatype representing the contents of the implementor of this interface.
  `long`
  `unslidLoadAddress()`
  Get the original unslid load address.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### DyldCacheHeader

    public DyldCacheHeader(BinaryReader reader) throws IOException
    Create a new `DyldCacheHeader`.
    Parameters:
      `reader` - A `BinaryReader` positioned at the start of a DYLD cache header
    Throws:
      `IOException` - if there was an IO-related problem creating the DYLD cache header

- ## Method Details

  - ### parseFromFile

    public void parseFromFile(boolean parseLocalSymbols, MessageLog log, TaskMonitor monitor) throws CancelledException
    Parses the structures referenced by this `DyldCacheHeader` from a file.
    Parameters:
      `parseLocalSymbols` - True if local symbols should be parsed; otherwise, false
      `log` - The log
      `monitor` - A cancellable task monitor
    Throws:
      `CancelledException` - if the user cancelled the operation

  - ### parseFromMemory

    public void parseFromMemory(Program program, AddressSpace space, MessageLog log, TaskMonitor monitor) throws CancelledException
    Parses the structures referenced by this `DyldCacheHeader` from memory.
    Parameters:
      `program` - The `Program` whose memory to parse
      `space` - The `Program`'s `AddressSpace`
      `log` - The log
      `monitor` - A cancellable task monitor
    Throws:
      `CancelledException` - if the user cancelled the operation

  - ### markup

    public void markup(Program program, boolean markupLocalSymbols, AddressSpace space, TaskMonitor monitor, MessageLog log) throws CancelledException
    Marks up this `DyldCacheHeader` with data structures and comments.
    Parameters:
      `program` - The `Program` to mark up
      `markupLocalSymbols` - True if the local symbols should be marked up; otherwise, false
      `space` - The `Program`'s `AddressSpace`
      `monitor` - A cancellable task monitor
      `log` - The log
    Throws:
      `CancelledException` - if the user cancelled the operation

  - ### getBaseAddress

    public long getBaseAddress()
    Gets the base address of the DYLD cache. This is where the cache should be loaded in memory.
    Returns:
      The base address of the DYLD cache

  - ### getMagic

    public byte[] getMagic()
    Gets the magic bytes, which contain version information.
    Returns:
      The magic bytes

  - ### getUUID

    public String getUUID()
    Gets the UUID in `String` form
    Returns:
      The UUID in `String` form, or null if a UUID is not defined

  - ### getEntryPoint

    public Long getEntryPoint()
    Gets the DYLD entry point address (if known)
    Returns:
      The DYLD entry point address, or null if it is not known

  - ### getMappingInfos

    public List<DyldCacheMappingInfo> getMappingInfos()
    Gets the `List` of `DyldCacheMappingInfo`s. Requires header to have been parsed.
    Returns:
      The `List` of `DyldCacheMappingInfo`s

  - ### getImagesOffset

    public int getImagesOffset()
    Gets the file offset to first `DyldCacheImageInfo`.
    Returns:
      The file offset to first `DyldCacheImageInfo`

  - ### getImagesCount

    public int getImagesCount()
    Gets the number of `DyldCacheImageInfo`s.
    Returns:
      The number of `DyldCacheImageInfo`s

  - ### getMappedImages

    public List<DyldCacheImage> getMappedImages()
    Generates a `List` of `DyldCacheImage`s that are mapped in by this `DyldCacheHeader`. Requires header to have been parsed.

    NOTE: A DYLD subcache header may declare an image, but that image may get loaded at an address defined by the memory map of a different subcache header. This method will only return the images that are mapped by "this" header's memory map.

    Returns:
      A `List` of `DyldCacheImage`s mapped by this `DyldCacheHeader`

  - ### getSubcacheEntries

    public List<DyldSubcacheEntry> getSubcacheEntries()
    Gets the `List` of `DyldSubcacheEntry`s. Requires header to have been parsed.
    Returns:
      The `List` of `DyldSubcacheEntry`s

  - ### getSymbolFileUUID

    public String getSymbolFileUUID()
    Gets the symbol file UUID in `String` form
    Returns:
      The symbol file UUID in `String` form, or null if a symbol file UUID is not defined or is all zeros

  - ### getCacheMappingAndSlideInfos

    public List<DyldCacheMappingAndSlideInfo> getCacheMappingAndSlideInfos()
    Gets the `List` of `DyldCacheMappingAndSlideInfo`s. Requires header to have been parsed.
    Returns:
      The `List` of `DyldCacheMappingAndSlideInfo`s

  - ### getLocalSymbolsInfo

    public DyldCacheLocalSymbolsInfo getLocalSymbolsInfo()
    Gets the `DyldCacheLocalSymbolsInfo`.
    Returns:
      The `DyldCacheLocalSymbolsInfo`. Could be be null if it didn't parse.

  - ### getSlideInfos

    public List<DyldCacheSlideInfoCommon> getSlideInfos()
    Gets the `List` of `DyldCacheSlideInfoCommon`s.
    Returns:
      the `List` of `DyldCacheSlideInfoCommon`s.

  - ### getBranchPoolAddresses

    public List<Long> getBranchPoolAddresses()
    Gets the `List` of branch pool address. Requires header to have been parsed.
    Returns:
      The `List` of branch pool address

  - ### getArchitecture

    public DyldArchitecture getArchitecture()
    Gets architecture information.
    Returns:
      architecture information

  - ### toDataType

    public DataType toDataType() throws DuplicateNameException, IOException
    Description copied from interface: `StructConverter`
    Returns a structure datatype representing the contents of the implementor of this interface.

    For example, given:

         class A {
             int foo;
             double bar;
         }

    The return value should be a structure data type with two data type components; an INT and a DOUBLE. The structure should contain field names and, if possible, field comments.

    Specified by:
      `toDataType` in interface `StructConverter`
    Returns:
      returns a structure datatype representing the implementor of this interface
    Throws:
      `DuplicateNameException` - when a datatype of the same name already exists
      `IOException`
    See Also:
      - `StructureDataType`

  - ### parseLocalSymbolsInfo

    public void parseLocalSymbolsInfo(boolean shouldParse, MessageLog log, TaskMonitor monitor) throws CancelledException
    Throws:
      `CancelledException`

  - ### setFileBlock

    public void setFileBlock(MemoryBlock block)
    Sets the `MemoryBlock` associated with this header's FILE block.
    Parameters:
      `block` - The `MemoryBlock` associated with this header's FILE block

  - ### hasSlideInfo

    public boolean hasSlideInfo()
    Checks to see if any slide info exists
    Returns:
      True if any slide info exists; otherwise, false

  - ### unslidLoadAddress

    public long unslidLoadAddress()
    Get the original unslid load address. This is found in the first mapping infos.
    Returns:
      the original unslid load address

  - ### isSubcache

    public boolean isSubcache()
    Checks to see whether or not this is a subcache
    Returns:
      True if this is a subcache; otherwise, false if it's a base cache

  - ### hasAccelerateInfo

    public boolean hasAccelerateInfo()
    Checks to see whether or not the old accelerate info fields are being used
    Returns:
      True if the old accelerate info fields are being used; otherwise, false if the new dyldInCache fields are being used