Skip to main content

Overview

Program Diff extends the CodeBrowser to display two programs side-by-side, computing and visualizing differences between them. Unlike Version Tracking which focuses on transferring analysis, Program Diff emphasizes interactive comparison and selective markup application.
Program Diff allows you to compare any two compatible programs and selectively apply differences from one program to another.

Core Capabilities

Side-by-Side View

Synchronized dual-panel display of programs

Difference Highlighting

Visual marking of all differences between programs

Selective Application

Apply specific differences to the target program

Detail View

Examine detailed differences at cursor location

Getting Started

Opening a Second Program

1

Open First Program

Open your primary program in the CodeBrowser.
2

Select Second Program

Click Tools → Program Diff → Open/Close Second Program.
3

Choose Program

Select from:
  • Currently open programs in the tool
  • Programs from project repository
  • Versioned programs from Ghidra Server
4

View Opens

Second program displays in right panel with synchronized scrolling.
The two programs must have similar architectures and compatible memory layouts. Programs with completely different architectures cannot be compared.

Program Compatibility

Programs are compatible when:
  • Same processor architecture (language)
  • Similar memory organization
  • Overlapping address spaces
// Source: ProgramDiffPlugin.java:1591-1599
// Programs are checked for similarity using:
// ProgramMemoryComparator.similarPrograms(prog1, prog2)
// which compares language IDs and basic structure

Computing Differences

Execute Diff Dialog

1

Open Execute Diff

Click Tools → Program Diff → Execute Diff or press the diff icon.
2

Configure Filters

Select which difference types to compute:
  • Bytes
  • Instructions
  • Comments
  • Labels
  • Functions
  • References
  • And more…
3

Set Scope

Choose comparison scope:
  • Entire program
  • Current selection
  • Specific address ranges
4

Execute

Click OK to compute differences.

Difference Types

Program Diff can detect differences in:
  • Bytes: Raw byte differences
  • Instructions: Disassembly differences
  • Mnemonics: Instruction mnemonics only
  • Operands: Instruction operands

Diff Filters

Customize which differences to display:
// Source: ProgramDiffPlugin.java:628
// ProgramDiffFilter controls which difference types
// are computed and highlighted

// Common filter configurations:
// - ALL_DIFFS: Show everything
// - CODE_DIFFS: Only code differences  
// - USER_DEFINED: Only user markup
filterType
enum
Options: All Diffs, Code Diffs Only, User-Defined Only, Custom

Viewing Differences

Difference Highlighting

Differences are highlighted in both program views:
  • Background color: Marks addresses with differences
  • Margin markers: Overview of diff locations
  • Navigation: Jump between difference locations
The highlight color can be customized via Edit → Tool Options → Browser Fields → Difference Color.

Next Difference

Navigate to the next highlighted difference

Previous Difference

Navigate to the previous highlighted difference

Go to Address

Jump to specific address in both programs

Select All Diffs

Select all difference addresses in view

Synchronized Views

Both program panels remain synchronized:
  • Cursor location: Both views track the same address
  • Scrolling: Synchronized scroll positions
  • Selection: Selections span both programs
  • Field focus: Same field types visible
// Source: ProgramDiffPlugin.java:175-236
// programLocationChanged() handler keeps cursors
// synchronized between primary and secondary programs

Difference Details

Details Window

View detailed information about differences at current location:
1

Show Details

Window → Diff Details to open the details panel.
2

Navigate to Location

Position cursor on address with differences.
3

Review Details

Panel shows:
  • Specific differences at location
  • Original vs. new values
  • Difference categories
Details include:
  • Byte values: Hexadecimal comparison
  • Disassembly: Instruction differences
  • Markup: Comment and label differences
  • Type information: Data type differences
Difference details update automatically as you navigate through the program.

Applying Differences

Apply Settings

Configure which differences to apply:
1

Open Settings

Window → Diff Apply Settings to open configuration panel.
2

Select Categories

Choose which difference types to apply:
  • Replace: Overwrite with second program’s value
  • Merge: Combine both values (where applicable)
  • Ignore: Don’t apply this type
3

Configure Options

Set options like:
  • Primary symbol handling
  • Reference behavior
  • Comment merging

Applying Changes

Apply differences at current cursor location:
  1. Position cursor on difference
  2. Click Apply in Diff Apply Settings
  3. Changes applied to primary program
Applying differences modifies the primary program. Use undo or save carefully.

Apply Filters

Control which categories are applied:
CategoryReplaceMergeIgnore
BytesOverwrite bytesN/ASkip
InstructionsReplace instructionN/ASkip
CommentsReplace commentAppend bothSkip
LabelsReplace labelAdd alternateSkip
FunctionsReplace signatureCombine paramsSkip
ReferencesReplace refsAdd refsSkip
// Source: DiffApplySettingsProvider.java
// ProgramMergeFilter configured via Apply Settings dialog
// controls which markup types are applied and how

Selection Management

Making Selections

Selections work across both programs:
  • Click and drag: Select range in either panel
  • Shift+Click: Extend selection
  • Ctrl+Click: Add to selection
  • Select All Diffs: Select all highlighted differences

Selection Actions

Transfer primary program’s selection to secondary program view.Use: Focus on same code in both programs
Mark selected differences to be ignored (not highlighted).Use: Hide unimportant differences
Apply all differences within selection to primary program.Use: Bulk apply related changes

Ignore Functionality

Temporarily hide specific differences:
1

Select Differences

Select address range containing differences to ignore.
2

Ignore

Click Ignore Selection and Goto Next Difference.
3

Result

Selected addresses no longer highlighted as differences.
Ignored differences are not permanently removed—re-run Execute Diff to restore them.

Advanced Features

Program Context

Diff can operate in different program contexts:
  • Same context: Compare identical address ranges
  • Different context: Handle memory layout differences
  • Overlay support: Compare overlay address spaces
// Source: ProgramDiffPlugin.java:196-206  
// Overlay space handling converts addresses between
// programs when address spaces don't match exactly

Address Mapping

Program Diff handles address translation:
  • Compatible addresses: Direct mapping between programs
  • Overlay conversion: Map overlay spaces appropriately
  • Only in P1: Addresses existing only in first program
  • Only in P2: Addresses existing only in second program
Addresses that exist in only one program are specially marked and handled during diff operations.

Diff History

Program Diff maintains history:
  • Previous location: Track last cursor position
  • Navigation stack: Return to previous locations
  • Undo/Redo: Revert applied changes

Tool Configuration

Options

Configure Diff behavior via Edit → Tool Options:
Difference Color
color
Background color for highlighting differences
Cursor Sync
boolean
default:true
Keep cursors synchronized between programs
Auto Apply
boolean
default:false
Automatically apply when navigating to next diff

Window Layout

Customize panel arrangement:
  • Resize second program panel
  • Dock/undock details window
  • Show/hide apply settings
  • Configure field visibility

Comparison with Version Tracking

FeatureProgram DiffVersion Tracking
PurposeInteractive comparisonAnalysis transfer
WorkflowImmediate visual diffMulti-step correlation
ScopeAddress-by-addressFunction/data matching
ApplicationSelective manual applyBulk automated apply
Best ForQuick comparisonsVersion migration
Use Program Diff when:
  • Comparing similar programs quickly
  • Applying specific targeted changes
  • Reviewing byte-level differences
Use Version Tracking when:
  • Migrating to new software version
  • Transferring comprehensive analysis
  • Handling major code refactoring

Use Cases

Patch Analysis

Compare original and patched executables to find fixes

Malware Variants

Identify differences between malware samples

Build Comparison

Compare debug vs. release builds

Binary Auditing

Verify compiled binary matches expected source

Obfuscation Analysis

Compare obfuscated and clean versions

Optimization Review

Analyze compiler optimization effects

Limitations and Considerations

Important Limitations:
  • Only one diff session per program at a time
  • Second program must be compatible architecture
  • Large programs may have slow diff computation
  • Memory-intensive for large address ranges
  • No automatic conflict resolution

Performance Tips

For Better Performance:
  • Limit diff scope to specific selections
  • Use targeted diff filters
  • Close unused tool windows
  • Apply differences incrementally
  • Consider Version Tracking for large-scale changes

Troubleshooting

Checks:
  • Verify programs have similar languages
  • Check if another diff is already open
  • Ensure program is in accessible project
  • Confirm memory compatibility
Causes:
  • Diff filter too restrictive
  • Programs are identical in selected categories
  • Comparison scope excludes differences
Solution: Adjust filters and scope, re-execute diff
Checks:
  • Verify apply settings configured (not all “Ignore”)
  • Ensure selection includes differences
  • Check for transaction conflicts
  • Confirm program is not read-only
Solutions:
  • Reduce diff scope to selection
  • Disable some diff filters
  • Use faster system or more memory
  • Consider splitting into multiple sessions

Keyboard Shortcuts

ActionShortcutDescription
Next DiffCtrl+NNavigate to next difference
Previous DiffCtrl+PNavigate to previous difference
Apply and NextCtrl+Shift+NApply current and go to next
Select All DiffsCtrl+ASelect all differences in view
Show DetailsCtrl+DToggle Diff Details window
Shortcuts can be customized via Edit → Tool Options → Key Bindings.

Source Code References

# Main plugin implementation
~/workspace/source/Ghidra/Features/ProgramDiff/src/main/java/ghidra/app/plugin/core/diff/

# Key files:
- ProgramDiffPlugin.java         # Main diff plugin
- DiffController.java            # Difference navigation
- ApplyDiffCommand.java          # Apply logic
- DiffApplySettingsProvider.java # Settings UI
- DiffDetailsProvider.java       # Details panel

Tools → Program Diff Menu

  • Open/Close Second Program: Select program to compare
  • Execute Diff: Compute differences with filters
  • Next Difference: Navigate forward
  • Previous Difference: Navigate backward
  • Apply Differences: Apply at cursor or selection
  • Ignore Selection and Goto Next: Skip differences
  • Select All Differences: Select all diffs in view

Window Menu

  • Diff Details: Show/hide detailed differences
  • Diff Apply Settings: Configure apply behavior

Next Steps

Version Tracking

Advanced version comparison and analysis transfer

Graph Visualization

Visualize program structure and relationships

Build docs developers (and LLMs) love