Package ghidra.app.util.bin.format.pe

# Class BaseRelocation

java.lang.Object
ghidra.app.util.bin.format.pe.BaseRelocation

All Implemented Interfaces:
  `ByteArrayConverter`, `StructConverter`

public class BaseRelocation extends Object implements StructConverter, ByteArrayConverter
A class to represent the `IMAGE_BASE_RELOCATION` data structure defined in `winnt.h`.

     typedef struct _IMAGE_BASE_RELOCATION {
         DWORD   VirtualAddress;
         DWORD   SizeOfBlock;
     //  WORD    TypeOffset[1];
     } IMAGE_BASE_RELOCATION;
     typedef IMAGE_BASE_RELOCATION UNALIGNED * PIMAGE_BASE_RELOCATION;

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final int`
  `IMAGE_REL_BASED_ABSOLUTE`
  `static final int`
  `IMAGE_REL_BASED_DIR64`
  `static final int`
  `IMAGE_REL_BASED_HIGH`
  `static final int`
  `IMAGE_REL_BASED_HIGH3ADJ`
  `static final int`
  `IMAGE_REL_BASED_HIGHADJ`
  `static final int`
  `IMAGE_REL_BASED_HIGHLOW`
  `static final int`
  `IMAGE_REL_BASED_IA64_IMM64`
  `static final int`
  `IMAGE_REL_BASED_LOW`
  `static final int`
  `IMAGE_REL_BASED_MIPS_JMPADDR`
  `static final int`
  `IMAGE_REL_BASED_MIPS_JMPADDR16`
  `static final int`
  `IMAGE_REL_BASED_NOOP`
  `static final int`
  `IMAGE_REL_BASED_REL32`
  `static final int`
  `IMAGE_REL_BASED_SECTION`
  `static final int`
  `IMAGE_SIZEOF_BASE_RELOCATION`
  The size of the `IMAGE_BASE_RELOCATION` in bytes.
  `static final String`
  `NAME`
  The name to use when converting into a structure data type.
  `static final String[]`
  `TYPE_STRINGS`
  Names of the available base relocations.

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

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addRelocation(int type, int offset)`
  Adds a relocation to this base relocation block.
  `int`
  `getCount()`
  Returns the number of relocation in this block.
  `int`
  `getOffset(int index)`
  Returns the lower 12 bits of the offset.
  `int`
  `getSizeOfBlock()`
  Returns the size (in bytes) of this relocation block.
  `int`
  `getType(int index)`
  Returns the upper 4 bits of the offset.
  `int`
  `getVirtualAddress()`
  Returns the base address of the relocations in this block.
  `byte[]`
  `toBytes(DataConverter dc)`
  Returns a byte array representing this implementor of this interface.
  `DataType`
  `toDataType()`
  Returns a structure datatype representing the contents of the implementor of this interface.

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

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

- ## Field Details

  - ### NAME

    public static final String NAME
    The name to use when converting into a structure data type.
    See Also:
      - Constant Field Values

  - ### IMAGE_SIZEOF_BASE_RELOCATION

    public static final int IMAGE_SIZEOF_BASE_RELOCATION
    The size of the `IMAGE_BASE_RELOCATION` in bytes.
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_NOOP

    public static final int IMAGE_REL_BASED_NOOP
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_ABSOLUTE

    public static final int IMAGE_REL_BASED_ABSOLUTE
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_HIGH

    public static final int IMAGE_REL_BASED_HIGH
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_LOW

    public static final int IMAGE_REL_BASED_LOW
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_HIGHLOW

    public static final int IMAGE_REL_BASED_HIGHLOW
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_HIGHADJ

    public static final int IMAGE_REL_BASED_HIGHADJ
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_MIPS_JMPADDR

    public static final int IMAGE_REL_BASED_MIPS_JMPADDR
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_SECTION

    public static final int IMAGE_REL_BASED_SECTION
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_REL32

    public static final int IMAGE_REL_BASED_REL32
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_MIPS_JMPADDR16

    public static final int IMAGE_REL_BASED_MIPS_JMPADDR16
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_IA64_IMM64

    public static final int IMAGE_REL_BASED_IA64_IMM64
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_DIR64

    public static final int IMAGE_REL_BASED_DIR64
    See Also:
      - Constant Field Values

  - ### IMAGE_REL_BASED_HIGH3ADJ

    public static final int IMAGE_REL_BASED_HIGH3ADJ
    See Also:
      - Constant Field Values

  - ### TYPE_STRINGS

    public static final String[] TYPE_STRINGS
    Names of the available base relocations.

- ## Method Details

  - ### addRelocation

    public void addRelocation(int type, int offset)
    Adds a relocation to this base relocation block.
    Parameters:
      `type` - the relocation type
      `offset` - the relocation offset

  - ### getVirtualAddress

    public int getVirtualAddress()
    Returns the base address of the relocations in this block.
    Returns:
      the base address of the relocations in this block

  - ### getSizeOfBlock

    public int getSizeOfBlock()
    Returns the size (in bytes) of this relocation block.
    Returns:
      the size (in bytes) of this relocation block

  - ### getCount

    public int getCount()
    Returns the number of relocation in this block.
    Returns:
      the number of relocation in this block

  - ### getOffset

    public int getOffset(int index)
    Returns the lower 12 bits of the offset.
    Parameters:
      `index` - the ith relocation
    Returns:
      int the offset of the relocation

  - ### getType

    public int getType(int index)
    Returns the upper 4 bits of the offset.
    Parameters:
      `index` - the ith relocation
    Returns:
      int the type of the relocation ,

  - ### toDataType

    public DataType toDataType() throws DuplicateNameException
    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
    See Also:
      - `StructureDataType`

  - ### toBytes

    public byte[] toBytes(DataConverter dc)
    Description copied from interface: `ByteArrayConverter`
    Returns a byte array representing this implementor of this interface.
    Specified by:
      `toBytes` in interface `ByteArrayConverter`
    Parameters:
      `dc` - the data converter to use
    Returns:
      a byte array representing this object