Class ProgramMemoryComparator

java.lang.Object
ghidra.program.util.ProgramMemoryComparator

public class ProgramMemoryComparator extends Object
ProgramMemoryComparator is a class for comparing two programs and determining the address differences between them.
  • Constructor Details

    • ProgramMemoryComparator

      public ProgramMemoryComparator(Program program1, Program program2) throws ProgramConflictException
      ProgramMemoryComparator is used to determine the memory address differences between two programs.
      Parameters:
      program1 - the first program
      program2 - the second program
      Throws:
      ProgramConflictException - if the two programs can't be compared.
  • Method Details

    • compareAddressTypes

      public static void compareAddressTypes(Program program1, Program program2) throws ProgramConflictException
      Check each program to see if the memory blocks have the same address types.
      Parameters:
      program1 - the first program
      program2 - the second program
      Throws:
      ProgramConflictException - if the address types for the two programs do not match.
    • similarPrograms

      public static boolean similarPrograms(Program p1, Program p2)
      Return whether or not the two specified programs are alike (their language name or address spaces are the same).
      Parameters:
      p1 - the first program
      p2 - the second program
      Returns:
      true if the programs are alike (their language name or address spaces are the same).
    • getProgramOne

      public Program getProgramOne()
      Gets the first program being compared by the ProgramMemoryComparator.
      Returns:
      program1.
    • getProgramTwo

      public Program getProgramTwo()
      Gets the second program being compared by the ProgramMemoryComparator.
      Returns:
      program2.
    • getCombinedAddresses

      public static AddressSet getCombinedAddresses(Program program1, Program program2)
      Returns the addresses from combining the address sets in program1 and program2. Addresses in the returned address set are derived from program1.
      Returns:
      the addresses for both program1 and program2.
    • getAddressRanges

      public AddressRangeIterator getAddressRanges()
      Returns an iterator for the address ranges in the set containing the combined addresses in program1 and program2. Address ranges from this iterator are derived using program1.
      Returns:
      the addresses for both program1 and program2.
    • getAddressesInCommon

      public AddressSet getAddressesInCommon()
      Returns the addresses in common between program1 and program2. The returned address set is derived using program1.
      Returns:
      the addresses in common between program1 and program2.
    • getInitializedAddressesInCommon

      public AddressSet getInitializedAddressesInCommon()
      Returns the addresses of initialized memory in common between program1 and program2. This includes bit memory and live memory. The returned address set is derived using program1.
      Returns:
      the addresses in common between program1 and program2.
    • getSameMemTypeAddressesInCommon

      public AddressSet getSameMemTypeAddressesInCommon()
      Returns the addresses with the same memory types in common between program1 and program2. The returned address set is derived using program1.
      Returns:
      the addresses in common between program1 and program2.
    • getAddressesOnlyInOne

      public AddressSet getAddressesOnlyInOne()
      Returns the addresses that are in program1, but not in program2 The returned address set is derived using program1.
      Returns:
      the addresses that are in program1, but not in program2.
    • getAddressesOnlyInTwo

      public AddressSet getAddressesOnlyInTwo()
      Returns the addresses that are in program2, but not in program1 The returned address set is derived using program2.
      Returns:
      the addresses that are in program2, but not in program1.
    • getCompatibleAddressesOnlyInTwo

      public AddressSet getCompatibleAddressesOnlyInTwo()
      Returns the set of addresses that are in program2, but not in program1 and that are compatible with program1. The returned address set is derived using program1.
      Returns:
      the addresses that are in program2, but not in program1.
    • hasMemoryDifferences

      public boolean hasMemoryDifferences()
      Return whether or not the memory addresses for the two Programs are different.
    • sameProgramContextRegisterNames

      public static boolean sameProgramContextRegisterNames(Program program1, Program program2)
      Returns true if the register names are the same in both programs.
      Parameters:
      program1 - the first program
      program2 - the second program
      Returns:
      true if the register names are the same