Capstone Documentation Beta

Class Instruction

public class Instruction: CustomStringConvertible

Base class for all disassembled instructions.

Provides access to basic information about an instruction, shared by all architectures. Disassembled instructions will always be of a platform-specific instruction class.

%3 Instruction Instruction CustomStringConvertible CustomStringConvertible Instruction->CustomStringConvertible PlatformInstructionBase PlatformInstructionBase PlatformInstructionBase->Instruction

Subclasses

PlatformInstructionBase

Base class for platform-specific instructions without registers.

Conforms To

CustomStringConvertible

Properties

register​Type

var registerType: Any.Type?

The type for registers used in this architecture (if any).

This is an enumeration with values corresponding to the registers.

instruction​Type

var instructionType: InstructionType.Type

The type for instructions used in this architecture.

This is an enumeration with values corresponding to instruction mnemonics.

address

var address: UInt64

Address (EIP) of this instruction.

This information is available even when detail option is disabled.

size

var size: UInt16

Size of this instruction in bytes.

This information is available even when detail option is disabled.

bytes

var bytes: Data

Machine bytes of this instruction.

This information is available even when detail option is disabled.

mnemonic

var mnemonic: String

Textual representation of the instruction's mnemonic.

This information is available even when detail option is disabled.

operands​String

var operandsString: String

Textual representation of the instruction's operands.

This information is available even when detail option is disabled.

description

var description: String

Textual representation of the instruction, including its mnemonic and operands.

This information is available even when detail option is disabled.

has​Detail

var hasDetail: Bool

True if details are available for this instruction.

Details are available on instructions (not on skipped data) when disassembling in detail mode, by setting the appropriate option:

capstone.set(option: .detail(value: true))

base​Groups

var baseGroups: [InstructionGroup]

List of architecture-agnostic groups this instruction belongs to.

The list will be empty in any of these cases:

  • detail mode is off

  • capstone is built in diet mode

  • instruction groups are not implemented for this architecture See groups for architecture-specific groups.

group​Names

var groupNames: [String]

List of group names this instruction belongs to.

This API is only valid when detail mode is on (it's off by default). When in 'diet' mode, this API is irrelevant because engine does not store groups.

register​Names​Accessed

var registerNamesAccessed: (read: [String], written: [String])

Register names implicitly and explicitly accessed by this instruction.

This API is only valid when detail mode is on (it's off by default). When in 'diet' mode, this API is irrelevant because engine does not store registers.

register​Names​Accessed​Implicitly

var registerNamesAccessedImplicitly: (read: [String], written: [String])

Register names implicitly accessed by this instruction.

This API is only valid when detail mode is on (it's off by default). When in 'diet' mode, this API is irrelevant because engine does not store registers.

Methods

is​In(group:​)

public func isIn(group: InstructionGroup) -> Bool

Check if an instruction belong to a particular group.

This API is only valid when detail mode is on (it's off by default). When in 'diet' mode, this API is irrelevant because engine does not store groups.

Parameters

group Instruction​Group

group to check.

Returns

true if the instruction belongs to this group, false otherwise.