Class AddressFormatter

java.lang.Object
com.pnfsoftware.jeb.core.units.code.asm.render.AddressFormatter

@Ser public class AddressFormatter extends Object
A native memory address formatter.

The formatter can generate different types of addresses:

  • As an absolute address (always in hexadecimal form)
  • As a label (using a INativeCodeUnit)
  • As a relative address in hexadecimal/decimal

As an example: loc_400248 -> 400248h -> PC+10h/ PC+16.

  • Constructor Details

    • AddressFormatter

      public AddressFormatter()
      Create an address formatter.
    • AddressFormatter

      public AddressFormatter(AddressFormatter.AddressBase base, String pcName, NumberFormatter.HexaNotationType hexNotation)
      Create an address formatter.
      Parameters:
      base - address rendering base
      pcName - relative address prefix
      hexNotation - hexadecimal notation
  • Method Details

    • setBase

      public void setBase(AddressFormatter.AddressBase base)
      Set the address rendering base.
      Parameters:
      base - address rendering base
    • getBase

      public AddressFormatter.AddressBase getBase()
      Retrieve the address rendering base.
      Returns:
      address rendering base
    • setRelativePrefix

      public void setRelativePrefix(String relativePrefix)
      Set the relative address prefix.
      Parameters:
      relativePrefix - relative address prefix
    • getRelativePrefix

      public String getRelativePrefix()
      Retrieve the relative address prefix.
      Returns:
      relative address prefix
    • setHexaNotationType

      public void setHexaNotationType(NumberFormatter.HexaNotationType hexaNotationType)
      Set the hexadecimal notation style.
      Parameters:
      hexaNotationType - hexadecimal notation style
    • getHexaNotationType

      public NumberFormatter.HexaNotationType getHexaNotationType()
      Retrieve the hexadecimal notation style.
      Returns:
      hexadecimal notation style
    • format

      public String format(INativeCodeUnit<?> unit, int bitsize, long address, IInstructionOperandGeneric opnd)
      Format a number using the formatter's current settings.
      Parameters:
      unit - native code unit used for label resolution
      bitsize - address size in bits
      address - address to format
      opnd - operand containing the raw relative value, or null
      Returns:
      formatted address
    • format

      public String format(int bitsize, long address, IInstructionOperandGeneric opnd)
      Format an address without a code unit.
      Parameters:
      bitsize - address size in bits
      address - address to format
      opnd - operand containing the raw relative value, or null
      Returns:
      formatted address
    • format

      public String format(INativeCodeUnit<?> unit, int bitsize, long address, IInstructionOperandGeneric opnd, AddressFormatter.AddressBase base)
      Format an address.
      Parameters:
      unit - native code unit used for label resolution
      bitsize - address size in bits
      address - address to format
      opnd - operand containing the raw relative value, or null
      base - rendering base
      Returns:
      formatted address