Wildcard Assembler Module

This feature is currently only available as an API for Ghidra scripts and plugins. For an example of how to use the API, see the FindInstructionWithWildcard and WildSleighAssemblerInfo scripts in the Script Manager.

The Wildcard Assembler extends Ghidra's assembler to enable assembling instructions with specific tokens replaced with wildcards.

This assembler will return metadata for each wildcard in an assembled instruction. This metadata includes details of which specific bits of an assembled instruction are used to derive the value of the wildcarded token and the expression used to derive the value.

Wildcard Syntax

Wildcards in instructions are specified by replacing the to-be-wildcarded token with a wildcard name surrounded by backticks (e.g. `Q1` where Q1 is an arbitrary wildcard name) and passing the entire instruction to the Wildcard Assembler.

By default, the Wildcard Assembler will return metadata about all possible values that a wildcarded token could take and all the encodings of all these values. This behavior can be limited by filtering the wildcard by appending specific syntax after the wildcard name:

Normally a wildcard will only match a single token. For example, in a x86:LE:32:default binary:

No wildcard:
MOVSD.REP ES:EDI,ESI
Single token:
MOVSD.REP `Q1`:EDI,ESI
Single token:
MOVSD.REP ES:`Q2`,ESI

To allow a single wildcard to match multiple related tokens: precede the wildcard name with a ! character:

Multi-token:
MOVSD.REP `!Q4`,ESI
Single token (Does NOT assemble):
MOVSD.REP `Q3`,ESI

Provided by: Wildcard Assembler Module