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

# Class ThunkData

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

All Implemented Interfaces:
  `ByteArrayConverter`, `StructConverter`

public class ThunkData extends Object implements StructConverter, ByteArrayConverter
A class to represent the `IMAGE_THUNK_DATA32 struct` as defined in `winnt.h`.

     typedef struct _IMAGE_THUNK_DATA32 {
         union {
             DWORD ForwarderString;  // PBYTE
             DWORD Function;         // PDWORD
             DWORD Ordinal;
             DWORD AddressOfData;    // PIMAGE_IMPORT_BY_NAME
         } u1;
     } IMAGE_THUNK_DATA32;
     typedef IMAGE_THUNK_DATA32 * PIMAGE_THUNK_DATA32;

     typedef struct _IMAGE_THUNK_DATA64 {
         union {
             PBYTE  ForwarderString;
             PDWORD Function;
             ULONGLONG Ordinal;
             PIMAGE_IMPORT_BY_NAME  AddressOfData;
         } u1;
     } IMAGE_THUNK_DATA64;
     typedef IMAGE_THUNK_DATA64 * PIMAGE_THUNK_DATA64;

- ## 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
  `ThunkData(int value)`
  Constructs a new thunk data with the specified value

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `getAddressOfData()`
  Returns the address of the data.
  `long`
  `getForwarderString()`
  Returns the forward string pointer.
  `long`
  `getFunction()`
  Returns the function pointer.
  `ImportByName`
  `getImportByName()`
  Returns the underlying import by name structure.
  `long`
  `getOrdinal()`
  Returns the ordinal.
  `String`
  `getStructName()`
  Returns the struct name.
  `int`
  `getStructSize()`
  Returns the size of the thunk (in bytes) based on the size of the executable (32 vs 64 bit).
  `boolean`
  `isOrdinal()`
  `void`
  `setValue(int value)`
  Sets the value of the thunk.
  `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`

- ## Constructor Details

  - ### ThunkData

    public ThunkData(int value)
    Constructs a new thunk data with the specified value
    Parameters:
      `value` - the new thunk value

- ## Method Details

  - ### getStructSize

    public int getStructSize()
    Returns the size of the thunk (in bytes) based on the size of the executable (32 vs 64 bit).
    Returns:
      the size of the thunk (in bytes)

  - ### getStructName

    public String getStructName()
    Returns the struct name.
    Returns:
      the struct name

  - ### setValue

    public void setValue(int value)
    Sets the value of the thunk.
    Parameters:
      `value` - the new thunk value

  - ### getForwarderString

    public long getForwarderString()
    Returns the forward string pointer.
    Returns:
      the forward string pointer

  - ### getFunction

    public long getFunction()
    Returns the function pointer.
    Returns:
      the function pointer

  - ### getOrdinal

    public long getOrdinal()
    Returns the ordinal.
    Returns:
      the ordinal

  - ### isOrdinal

    public boolean isOrdinal()

  - ### getAddressOfData

    public long getAddressOfData()
    Returns the address of the data.
    Returns:
      the address of the data

  - ### getImportByName

    public ImportByName getImportByName()
    Returns the underlying import by name structure.
    Returns:
      the underlying import by name structure

  - ### 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:
      - `StructConverter.toDataType()`

  - ### 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
    See Also:
      - `ByteArrayConverter.toBytes(ghidra.util.DataConverter)`