operand_to_field_path

summary: turn an instruction operand into a structure-field reference by name

description:

Demonstrates how to use ida_typeinf.resolve_field_path() to convert a user-friendly dotted field path (e.g. “_IO_STACK_LOCATION.Parameters.DeviceIoControl.IoControlCode”) into the path[] inputs that ida_bytes.op_stroff() expects.

resolve_field_path() is needed when the chain crosses anonymous types – unnamed types are stored with synthetic “::$HASH” names, so the friendly dotted form the user writes does not match the canonical names directly. resolve_field_path() walks the chain segment by segment and produces a ready-to-use op_stroff() path.

Companion to operand_to_struct_member.py, which does the same thing interactively (the user picks the top struct and any union members through a chooser dialog). This one is for scripts that already know exactly where in the type tree the operand should point.

level: intermediate

Attributes

FIELD_PATH

OPNUM

result

Functions

retype_as_field_path(ea, opnum, field_path)

Annotate operand opnum of the instruction at ea as field_path.

Module Contents

operand_to_field_path.FIELD_PATH = '_IO_STACK_LOCATION.Parameters.DeviceIoControl.IoControlCode'
operand_to_field_path.OPNUM = 1
operand_to_field_path.retype_as_field_path(ea, opnum, field_path)

Annotate operand opnum of the instruction at ea as field_path.

field_path: a dotted name like “MyStruct.field1.field2.leaf”.

Returns the ida_typeinf.field_path_t produced by resolve_field_path() on success or None on failure.

operand_to_field_path.result = None