27 #ifndef FCML_DISASSEMBLER_HPP_ 28 #define FCML_DISASSEMBLER_HPP_ 66 _throwExceptionOnError(true),
68 _enableErrorMessages(true),
69 _carryFlagConditionalSuffix(false),
70 _conditionalGroup(false),
72 _extendDispToASA(false),
73 _failIfUnknownInstruction(false) {
78 return _carryFlagConditionalSuffix;
83 _carryFlagConditionalSuffix = carryFlagConditionalSuffix;
88 return _conditionalGroup;
93 _conditionalGroup = conditionalGroup;
98 return _enableErrorMessages;
103 _enableErrorMessages = enableErrorMessages;
108 return _extendDispToASA;
113 _extendDispToASA = extendDispToAsa;
118 return _failIfUnknownInstruction;
123 _failIfUnknownInstruction = failIfUnknownInstruction;
133 _incrementIP = incrementIp;
143 _shortForms = shortForms;
154 return _throwExceptionOnError;
165 _throwExceptionOnError = throwExceptionOnError;
169 bool _throwExceptionOnError;
171 bool _enableErrorMessages;
172 bool _carryFlagConditionalSuffix;
173 fcml_uint8_t _conditionalGroup;
175 bool _extendDispToASA;
176 bool _failIfUnknownInstruction;
191 _code(NULL), _codeLength(0) {
202 _code(code), _codeLength(codeLength) {
244 _codeLength = codeLength;
254 return _disassemblerConf;
264 return _disassemblerConf;
274 _disassemblerConf = disassemblerConf;
306 _entryPoint = entryPoint;
316 _entryPoint.setIP(ip);
327 _entryPoint.incrementIP(ip);
337 _entryPoint.setOpMode(operatingMode);
347 _entryPoint.setAddressSizeAttribute(addressSizeAttribute);
357 _entryPoint.setOperandSizeAttribute(operandSizeAttribute);
368 fcml_usize _codeLength;
381 PT_GROUP_UNKNOWN = FCML_PT_GROUP_UNKNOWN,
382 PT_GROUP_1 = FCML_PT_GROUP_1,
383 PT_GROUP_2 = FCML_PT_GROUP_2,
384 PT_GROUP_3 = FCML_PT_GROUP_3,
385 PT_GROUP_4 = FCML_PT_GROUP_4,
386 PT_REX = FCML_PT_REX,
387 PT_VEX = FCML_PT_VEX,
388 PT_XOP = FCML_PT_XOP,
389 PT_EVEX = FCML_PT_EVEX
399 return _mandatoryPrefix;
410 _mandatoryPrefix = mandatoryPrefix;
450 _prefixType = prefixType;
475 fcml_uint8_t _prefix;
479 bool _mandatoryPrefix;
483 fcml_uint8_t _AvxBytes[3];
498 _prefixesBytesCount(0),
511 _AvxPrefixFirstByte(false),
539 return _prefixes[index];
553 return _prefixes[index];
593 _isBranch = isBranch;
633 _isNobranch = isNobranch;
753 _isXacquire = isXacquire;
813 _isXrelease = isXrelease;
909 return _prefixes[index];
925 return _prefixes[index];
935 return _prefixesBytesCount;
945 _prefixesBytesCount = prefixesBytesCount;
955 return _prefixesCount;
965 _prefixesCount = prefixesCount;
1015 return _AvxPrefixFirstByte;
1025 _AvxPrefixFirstByte = avxFirstByte;
1172 fcml_int _prefixesCount;
1174 fcml_int _prefixesBytesCount;
1206 fcml_uint8_t _AvxPrefixFirstByte;
1212 fcml_uint8_t _RPrim;
1224 fcml_uint8_t _LPrim;
1232 fcml_uint8_t _VPrim;
1264 AM_READ_WRITE = AM_READ | AM_WRITE
1272 _accessMode(AM_ACCESS_MODE_UNDEFINED) {
1282 _accessMode(accessMode) {
1302 _accessMode = accessMode;
1441 return _displacement;
1451 return _displacement;
1461 _displacement = displacement;
1508 _addrMode = addrMode;
1518 return _instruction;
1528 _instruction = instruction;
1539 return _instructionCode;
1550 return _instructionCode;
1561 return _instructionGroup;
1572 _instructionGroup = instructionGroup;
1582 return _instructionSize;
1592 _instructionSize = instructionSize;
1612 _isShortcut = isShortcut;
1622 return _modRMDetails;
1632 return _modRMDetails;
1642 _modRMDetails = modRmDetails;
1652 return _opcodeFieldSBit;
1662 _opcodeFieldSBit = opcodeFieldSBit;
1672 return _opcodeFieldWBit;
1682 _opcodeFieldWBit = opcodeFieldWBit;
1698 return _operandDetails[index];
1714 return _operandDetails[index];
1724 return _prefixesDetails;
1734 return _prefixesDetails;
1744 _prefixesDetails = prefixesDetails;
1764 _pseudoOp = pseudoOp;
1784 _isPseudoOp = isPseudoOp;
1802 _tupleType = tupleType;
1827 fcml_usize _instructionSize;
1844 bool _opcodeFieldSBit;
1849 bool _opcodeFieldWBit;
1861 fcml_uint16_t _addrMode;
1865 fcml_uint64_t _instructionGroup;
1869 fcml_uint8_t _tupleType;
1889 return _errorContainer;
1900 return _instruction;
1910 return _instructionDetails;
1918 _errorContainer.clean();
1934 return _instructionDetails;
1943 _instructionDetails = instructionDetails;
1952 return _instruction;
1961 _instruction = instruction;
1970 _errorContainer = errorContainer;
2016 modRM.setNotNull(FCML_TO_CPP_BOOL(src.
is_modrm));
2017 modRM.setValue(src.
modrm);
2019 sib.setNotNull(FCML_TO_CPP_BOOL(src.
sib.is_not_null));
2020 sib.setValue(src.
sib.value);
2024 N.setNotNull(FCML_TO_CPP_BOOL(src.
displacement.
N.is_not_null));
2035 sib.is_not_null = src.
getSib().isNotNull();
2036 sib.value = src.
getSib().getValue();
2046 static_cast<OperandDetails::AccessMode>(src.
access_mode));
2060 static_cast<InstructionPrefixDetails::PrefixType>(src.
prefix_type));
2129 dest.
R = src.
getR();
2131 dest.
X = src.
getX();
2132 dest.
B = src.
getB();
2133 dest.
W = src.
getW();
2134 dest.
L = src.
getL();
2142 dest.
z = src.
getZ() ? 1 : 0;
2224 extractDialect(dialect), &_disassembler);
2227 FCML_TEXT(
"Cannot initialize the disassembler."), error);
2236 if (_disassembler) {
2238 _disassembler = NULL;
2259 DisassemblerTypeConverter::convert(ctx, context);
2269 disassemblerResult.
clean();
2274 ErrorTypeConverter::convert(disassembler_result.
errors,
2282 FCML_TEXT(
"Assembling failed."), errorContainer, error);
2288 DisassemblerTypeConverter::convert(disassembler_result,
2289 disassemblerResult);
2299 }
catch (std::exception &exc) {
2328 #endif //FCML_DISASSEMBLER_HPP_ DecodedModRMDetails & getModRmDetails()
Gets ModR/M instruction details.
Definition: fcml_disassembler.hpp:1631
void setIsPseudoOp(bool isPseudoOp)
Sets pseudo operation flag.
Definition: fcml_disassembler.hpp:1783
void setLPrim(fcml_uint8_t lPrim)
Sets L' flag.
Definition: fcml_disassembler.hpp:852
DisassemblerContext()
Creates empty disassembler context.
Definition: fcml_disassembler.hpp:190
fcml_uint8_t mmmm
m-mmmm field of XOP or VEX prefix.
Definition: fcml_disassembler.h:177
void setAccessMode(AccessMode accessMode)
Sets an access mode for the operand.
Definition: fcml_disassembler.hpp:1301
fcml_ip ip
Instruction pointer EIP/RIP.
Definition: fcml_common.h:833
void clean()
Cleans the disassembling result.
Definition: fcml_disassembler.hpp:1917
fcml_bool is_xacquire
FCML_TRUE if xacquire explicit prefix exists.
Definition: fcml_disassembler.h:147
bool isBranch() const
Gets true if branch prefix is available.
Definition: fcml_disassembler.hpp:582
fcml_en_access_mode access_mode
Instruction operand access mode READ, WRITE or both.
Definition: fcml_disassembler.h:193
fcml_en_pseudo_operations getPseudoOp() const
Gets pseudo operation code.
Definition: fcml_disassembler.hpp:1753
void setOperatingMode(EntryPoint::OperatingMode operatingMode)
Sets processor operating mode directly into the entry point.
Definition: fcml_disassembler.hpp:336
fcml_bool is_rep
FCML_TRUE if rep explicit prefix exists.
Definition: fcml_disassembler.h:141
Operand is set by instruction.
Definition: fcml_common.h:548
fcml_int getPrefixesBytesCount() const
Gets number of bytes interpreted to be prefixes.
Definition: fcml_disassembler.hpp:934
void setCodeLength(fcml_usize codeLength)
Sets length of the code buffer in bytes.
Definition: fcml_disassembler.hpp:243
fcml_bool opcode_field_s_bit
Opcode field 's'.
Definition: fcml_disassembler.h:247
fcml_st_instruction instruction
Decoded instruction in its generic form.
Definition: fcml_disassembler.h:274
fcml_uint8_t * getAvxBytes()
Gets the second and third bytes of the XOP/VEX prefix.
Definition: fcml_disassembler.hpp:469
void setAaa(fcml_uint8_t aaa)
Sets 'aaa' field of the EVEX prefix.
Definition: fcml_disassembler.hpp:1064
void setAvxFirstByte(fcml_uint8_t avxFirstByte)
Sets a first byte of the XOP/VEX prefix.
Definition: fcml_disassembler.hpp:1024
void setPseudoOp(fcml_en_pseudo_operations pseudoOp)
Sets pseudo operation for the instruction.
Definition: fcml_disassembler.hpp:1763
void setPrefix(fcml_uint8_t prefix)
Sets the prefix byte.
Definition: fcml_disassembler.hpp:429
Nullable< fcml_uint32_t > & getN()
Gets N (see compressed AVX-512 disp8).
Definition: fcml_disassembler.hpp:1420
bool isNobranch() const
Gets true if no-branch prefix is available.
Definition: fcml_disassembler.hpp:622
void setInstructionGroup(fcml_uint64_t instructionGroup)
Sets an instruction group.
Definition: fcml_disassembler.hpp:1571
C++ wrappers common classes.
Disassembler wrapper.
Definition: fcml_disassembler.hpp:2211
fcml_uint8_t vvvv
vvvv field of XOP or VEX prefix.
Definition: fcml_disassembler.h:179
bool isAvx() const
Gets true if any AVX prefix is available.
Definition: fcml_disassembler.hpp:782
bool isRepne() const
Gets true if Repne prefix is available.
Definition: fcml_disassembler.hpp:662
bool isRip() const
Gets true if RIP byte is available.
Definition: fcml_disassembler.hpp:1330
void setIP(fcml_ip ip)
Sets a new instruction pointer for the entry point.
Definition: fcml_common.hpp:651
void setCode(fcml_ptr code)
Sets a new buffer with machine code for the context.
Definition: fcml_disassembler.hpp:223
void incrementIP(fcml_ip ip)
Increments entry point by given number of bytes.
Definition: fcml_disassembler.hpp:326
fcml_uint8_t V_prim
V’ field of EVEX prefix.
Definition: fcml_disassembler.h:185
fcml_bool is_vex
FCML_TRUE if VEX prefix exists.
Definition: fcml_disassembler.h:149
void setCarryFlagConditionalSuffix(bool carryFlagConditionalSuffix)
Definition: fcml_disassembler.hpp:82
void setVPrim(fcml_uint8_t vPrim)
Sets V' flag.
Definition: fcml_disassembler.hpp:1084
fcml_bool is_rip
True if RIP encoding is used by decoded instruction.
Definition: fcml_disassembler.h:214
void setInstructionSize(fcml_usize instructionSize)
Sets the instruction size in bytes.
Definition: fcml_disassembler.hpp:1591
void setEntryPoint(const EntryPoint &entryPoint)
Copies given entry point to the instance associated with the context.
Definition: fcml_disassembler.hpp:305
fcml_en_instruction
Instruction codes.
Definition: fcml_instructions.h:184
fcml_bool is_repne
FCML_TRUE if repne explicit prefix exists.
Definition: fcml_disassembler.h:143
fcml_uint8_t getTupleType() const
Gets avx-512 tuple type.
Definition: fcml_disassembler.hpp:1791
void setRepne(bool isRepne)
Sets Repne prefix availability.
Definition: fcml_disassembler.hpp:672
void setL(fcml_uint8_t L)
Sets L flag.
Definition: fcml_disassembler.hpp:832
void setTupleType(fcml_uint8_t tupleType)
Sets avx-512 tuple type.
Definition: fcml_disassembler.hpp:1801
fcml_st_disassembler_conf configuration
Disassembler configuration.
Definition: fcml_disassembler.h:84
Nullable< fcml_uint8_t > & getModRM()
Gets ModR/M nullable byte.
Definition: fcml_disassembler.hpp:1360
fcml_uint8_t R_prim
EVEX R’ High-16 register specifier modifier.
Definition: fcml_disassembler.h:163
fcml_en_pseudo_operations
Pseudo operations.
Definition: fcml_instructions.h:1539
void setRip(bool isRip)
Sets RIP byte availability.
Definition: fcml_disassembler.hpp:1340
std::basic_string< fcml_char > fcml_cstring
By using this type definition here, it will be definitely much easier to support UNICODE in future re...
Definition: fcml_common.hpp:53
Contains some additional information about all decoded instruction prefixes.
Definition: fcml_disassembler.h:127
bool isXrelease() const
Gets true if xrelease prefix is available.
Definition: fcml_disassembler.hpp:802
fcml_en_pseudo_operations pseudo_op
Pseudo operation code.
Definition: fcml_disassembler.h:256
fcml_uint8_t getAaa() const
Gets 'aaa' field of the EVEX prefix.
Definition: fcml_disassembler.hpp:1054
fcml_st_instruction_details instruction_details
Additional disassembler specific information about decoded instruction.
Definition: fcml_disassembler.h:272
fcml_int prefixes_bytes_count
Number of bytes used by all decoded prefixes.
Definition: fcml_disassembler.h:133
bool isShortForms() const
Definition: fcml_disassembler.hpp:137
const Nullable< fcml_uint8_t > & getModRM() const
Gets ModR/M nullable byte.
Definition: fcml_disassembler.hpp:1350
Disassembler context.
Definition: fcml_disassembler.h:80
Converts objects to their structures counterparts.
Definition: fcml_disassembler.hpp:1989
fcml_ptr getCode() const
Gets pointer to the machine code buffer.
Definition: fcml_disassembler.hpp:213
Definition: fcml_types.h:217
void setFailIfUnknownInstruction(bool failIfUnknownInstruction)
Definition: fcml_disassembler.hpp:122
DecodedModRMDetails()
Creates an empty ModR/M details.
Definition: fcml_disassembler.hpp:1320
Disassembler configuration.
Definition: fcml_disassembler.hpp:58
void setShortForms(bool shortForms)
Definition: fcml_disassembler.hpp:142
bool isXacquire() const
Gets true if xacquire prefix is available.
Definition: fcml_disassembler.hpp:742
fcml_en_prefix_types
Available types of instruction prefixes.
Definition: fcml_disassembler.h:97
bool isVex() const
Gets true if Vex prefix is available.
Definition: fcml_disassembler.hpp:702
Additional details about an instruction.
Definition: fcml_disassembler.hpp:1485
fcml_uint64_t instruction_group
Instruction group.
Definition: fcml_disassembler.h:261
fcml_en_access_mode
Operand access mode.
Definition: fcml_common.h:542
fcml_uint8_t avx_bytes[3]
Place for additional bytes of VEX/EVEX/XOP prefix.
Definition: fcml_disassembler.h:120
fcml_uint8_t getR() const
Gets R flag.
Definition: fcml_disassembler.hpp:974
PrefixesDetails & getPrefixesDetails()
Gets instruction prefixes details.
Definition: fcml_disassembler.hpp:1733
#define FCML_TEXT(x)
Used to code literal strings.
Definition: fcml_types.h:61
Dialect & getDialect() const
Gets dialect associated with the disassembler.
Definition: fcml_disassembler.hpp:2313
void setPrefixType(PrefixType prefixType)
Sets a new prefix type.
Definition: fcml_disassembler.hpp:449
fcml_bool is_nobranch
FCML_TRUE if nobranch prefix exists.
Definition: fcml_disassembler.h:137
bool getZ() const
Gets EVEX.z bit.
Definition: fcml_disassembler.hpp:1154
void setB(fcml_uint8_t B)
Sets B flag.
Definition: fcml_disassembler.hpp:572
LIB_EXPORT void LIB_CALL fcml_fn_disassembler_free(fcml_st_disassembler *disassembler)
Frees disassembler instance.
void setR(fcml_uint8_t r)
Sets R flag.
Definition: fcml_disassembler.hpp:984
void setXacquire(bool isXacquire)
Sets xacquire prefix availability.
Definition: fcml_disassembler.hpp:752
void setPrefixesBytesCount(fcml_int prefixesBytesCount)
Sets number of prefixes bytes available for the instruction.
Definition: fcml_disassembler.hpp:944
fcml_bool is_avx
True if it is an AVX instruction (VEX/XOP/EVEX).
Definition: fcml_disassembler.h:155
fcml_usize getInstructionSize() const
Instruction size in bytes.
Definition: fcml_disassembler.hpp:1581
void setModRM(const Nullable< fcml_uint8_t > &modRM)
Sets ModR/M nullable byte.
Definition: fcml_disassembler.hpp:1370
fcml_en_instruction instruction
Instruction code/number.
Definition: fcml_disassembler.h:254
fcml_bool is_modrm
True if ModR/M exists.
Definition: fcml_disassembler.h:216
bool isLock() const
Gets true if lock prefix is available.
Definition: fcml_disassembler.hpp:602
Holds instruction pointer, processor operating mode and memory segment flags.
Definition: fcml_common.hpp:524
fcml_int prefixes_count
Number of decoded prefixes.
Definition: fcml_disassembler.h:131
PrefixType getPrefixType() const
Gets the prefix type.
Definition: fcml_disassembler.hpp:439
fcml_bool is_pseudo_op
True if given instruction is a short form of pseudo-ops instructions.
Definition: fcml_disassembler.h:232
Base class for all exceptions that are aware of ErrorContainer.
Definition: fcml_errors.hpp:347
fcml_bool is_xop
FCML_TRUE if XOP prefix exists.
Definition: fcml_disassembler.h:153
void setMmmm(fcml_uint8_t mmmm)
Sets MMMM field.
Definition: fcml_disassembler.hpp:872
Disassembler configuration.
Definition: fcml_disassembler.h:53
bool isEvex() const
Gets true if EVEX prefix is available.
Definition: fcml_disassembler.hpp:732
void setOpcodeFieldSBit(bool opcodeFieldSBit)
Sets 'S' field of the opcode byte.
Definition: fcml_disassembler.hpp:1661
fcml_bool is_evex
FCML TRUE if EVEX prefix exists.
Definition: fcml_disassembler.h:151
const OperandDetails & getOperandDetails(fcml_usize index) const
Gets the operand details for given index.
Definition: fcml_disassembler.hpp:1693
void setInstructionDetails(const InstructionDetails &instructionDetails)
Sets new instruction details for the disassembler.
Definition: fcml_disassembler.hpp:1942
Instruction prefix.
Definition: fcml_disassembler.hpp:374
fcml_ptr code
Pointer to the encoded instruction.
Definition: fcml_disassembler.h:88
fcml_bool increment_ip
Set to true in order to make disassembler to increment IP address by length of the disassembled instr...
Definition: fcml_disassembler.h:56
void setOperandSizeAttribute(fcml_usize operandSizeAttribute)
Sets a new operand size attribute for the entry point.
Definition: fcml_disassembler.hpp:356
Integer & getDisplacement()
Gets raw displacement.
Definition: fcml_disassembler.hpp:1450
bool isCarryFlagConditionalSuffix() const
Definition: fcml_disassembler.hpp:77
AccessMode getAccessMode() const
Gets access mode for the operand.
Definition: fcml_disassembler.hpp:1291
Some basic information about decoded ModR/M and SIB bytes.
Definition: fcml_disassembler.h:207
Definition: fcml_assembler.hpp:39
void setModRmDetails(const DecodedModRMDetails &modRmDetails)
Sets a new instruction details for the instruction.
Definition: fcml_disassembler.hpp:1641
void setIncrementIp(bool incrementIp)
Definition: fcml_disassembler.hpp:132
bool getBcast() const
Gets EVEX.b bit.
Definition: fcml_disassembler.hpp:1134
virtual ~Disassembler()
Destructor.
Definition: fcml_disassembler.hpp:2235
void setVvvv(fcml_uint8_t vvvv)
Sets VVVV field of the XOP/VEX prefix.
Definition: fcml_disassembler.hpp:1044
fcml_uint8_t getPp() const
Gets PP field.
Definition: fcml_disassembler.hpp:882
#define FCML_OPERANDS_COUNT
Maximal number of the instruction operands.
Definition: fcml_common.h:35
fcml_bool enable_error_messages
True if optional error and warning messages should be collected during processing.
Definition: fcml_disassembler.h:59
fcml_uint8_t instruction_code[FCML_INSTRUCTION_SIZE]
Code of the disassembled instruction.
Definition: fcml_disassembler.h:234
void setN(const Nullable< fcml_uint32_t > &N)
Sets N (see compressed AVX-512 disp8).
Definition: fcml_disassembler.hpp:1430
const Nullable< fcml_uint32_t > & getN() const
Gets constant N (see AVX-512 compressed disp8).
Definition: fcml_disassembler.hpp:1410
DisassemblerContext(fcml_ptr code, fcml_usize codeLength)
Creates disassembler context for given piece of machine code.
Definition: fcml_disassembler.hpp:201
fcml_uint8_t getConditionalGroup() const
Definition: fcml_disassembler.hpp:87
void setBranch(bool isBranch)
Sets branch prefix availability.
Definition: fcml_disassembler.hpp:592
Some additional disassembler specific information about decoded operands.
Definition: fcml_disassembler.h:191
Component can not be initialized correctly.
Definition: fcml_disassembler.hpp:44
Inherit from this class in order to get access to the native FCML dialect structure.
Definition: fcml_dialect.hpp:98
bool isRep() const
Gets true if Rep prefix is available.
Definition: fcml_disassembler.hpp:642
EntryPoint & getEntryPoint()
Gets reference to the entry point instance associated with the context.
Definition: fcml_disassembler.hpp:294
fcml_uint64_t getInstructionGroup() const
Gets instruction group.
Definition: fcml_disassembler.hpp:1560
Used mainly in case of integers and offsets.
Definition: fcml_errors.h:55
const InstructionPrefixDetails & getPrefixes(fcml_usize index) const
Gets a reference to the prefix of the given index.
Definition: fcml_disassembler.hpp:904
fcml_uint8_t getVPrim() const
Gets V' flag.
Definition: fcml_disassembler.hpp:1074
const DecodedModRMDetails & getModRmDetails() const
Gets ModR/M instruction details.
Definition: fcml_disassembler.hpp:1621
DisassemblerConf & getDisassemblerConf()
Gets a reference to the configuration object associated with the context.
Definition: fcml_disassembler.hpp:263
fcml_uint8_t L
L field of XOP or VEX prefix.
Definition: fcml_disassembler.h:173
Represents integer value.
Definition: fcml_common.hpp:700
void setEvex(bool isEvex)
Sets EVEX prefix availability.
Definition: fcml_disassembler.hpp:722
fcml_uint8_t tuple_type
avx-512 tuple type
Definition: fcml_disassembler.h:263
bool isShortcut() const
Gets true if it's a shortcut instruction.
Definition: fcml_disassembler.hpp:1601
Structures and functions declarations related to FCML disassembler.
void setXrelease(bool isXrelease)
Sets xrelease prefix availability.
Definition: fcml_disassembler.hpp:812
fcml_bool extend_disp_to_asa
True if displacement should be sign extended to effective address size; otherwise false...
Definition: fcml_disassembler.h:72
void setEnableErrorMessages(bool enableErrorMessages)
Definition: fcml_disassembler.hpp:102
fcml_uint8_t getLPrim() const
Gets L' flag.
Definition: fcml_disassembler.hpp:842
fcml_uint8_t B
B field of REX,XOP or VEX prefix.
Definition: fcml_disassembler.h:167
fcml_st_decoded_modrm_details modrm_details
Details about decoded ModR/M and SIB bytes.
Definition: fcml_disassembler.h:242
bool isMandatoryPrefix() const
Returns true if it's a mandatory prefix.
Definition: fcml_disassembler.hpp:398
const EntryPoint & getEntryPoint() const
Gets reference to the constant entry point instance associated with the context.
Definition: fcml_disassembler.hpp:284
void setLock(bool isLock)
Sets lock prefix availability.
Definition: fcml_disassembler.hpp:612
ModRM details.
Definition: fcml_disassembler.hpp:1313
Disassembler(Dialect &dialect)
Creates a disassembler instance for the given dialect.
Definition: fcml_disassembler.hpp:2221
Instruction & getInstructionInternal()
Gets mutable instruction.
Definition: fcml_disassembler.hpp:1951
fcml_uint8_t prefix
Prefix itself as raw byte.
Definition: fcml_disassembler.h:112
OperandDetails()
Creates default operand details with an undefined access mode.
Definition: fcml_disassembler.hpp:1271
const fcml_uint8_t * getAvxBytes() const
Gets the second and third bytes of the XOP/VEX prefix.
Definition: fcml_disassembler.hpp:459
fcml_bool fail_if_unknown_instruction
If set to true assembler will return FCML_CEH_GEC_UNKNOWN_INSTRUCTION error code if instruction is no...
Definition: fcml_disassembler.h:76
fcml_bool short_forms
Set to true in order to use short forms.
Definition: fcml_disassembler.h:69
fcml_int64_t fcml_ip
General instruction pointer holder.
Definition: fcml_common.h:96
void setAddrMode(fcml_uint16_t addrMode)
Sets instruction form.
Definition: fcml_disassembler.hpp:1507
bool isThrowExceptionOnError() const
Returns true if exception should be thrown when disassembling fails.
Definition: fcml_disassembler.hpp:153
fcml_uint8_t getVvvv() const
Gets VVVV field of the XOP/VEX prefix.
Definition: fcml_disassembler.hpp:1034
OperandDetails & getOperandDetails(fcml_usize index)
Gets the operand details for given index.
Definition: fcml_disassembler.hpp:1709
void setDisplacement(const Integer &displacement)
Sets displacement.
Definition: fcml_disassembler.hpp:1460
fcml_uint8_t W
W field of REX,XOP or VEX/EVEX prefix.
Definition: fcml_disassembler.h:171
fcml_en_prefix_types prefix_type
Type of the prefix.
Definition: fcml_disassembler.h:114
bool isEnableErrorMessages() const
Definition: fcml_disassembler.hpp:97
PrefixType
Type of the instruction prefix.
Definition: fcml_disassembler.hpp:380
Reusable disassembler result holder.
Definition: fcml_disassembler.h:267
C++ wrapper for the base dialect.
fcml_uint8_t X
X field of REX,XOP or VEX prefix.
Definition: fcml_disassembler.h:165
DisassemblerConf()
Default constructor.
Definition: fcml_disassembler.hpp:65
Operand is read by instruction.
Definition: fcml_common.h:546
void setDisassemblerConf(DisassemblerConf disassemblerConf)
Sets a new disassembler configuration for the context.
Definition: fcml_disassembler.hpp:273
fcml_st_entry_point entry_point
Instruction entry point configuration.
Definition: fcml_disassembler.h:86
void setAddressSizeAttribute(fcml_usize addressSizeAttribute)
Sets a new address size attribute for the entry point.
Definition: fcml_disassembler.hpp:346
fcml_st_integer displacement
Displacement as encoded in disp8/disp16/disp32/disp8*N.
Definition: fcml_disassembler.h:201
LIB_EXPORT void LIB_CALL fcml_fn_disassembler_result_free(fcml_st_disassembler_result *result)
Cleans result holder.
Describes one decoded prefix.
Definition: fcml_disassembler.h:110
const fcml_uint8_t * getInstructionCode() const
Gets a pointer to the instruction code.
Definition: fcml_disassembler.hpp:1538
fcml_ceh_error disassemble(DisassemblerContext &ctx, DisassemblerResult &disassemblerResult)
Disassembled the next instruction from the context.
Definition: fcml_disassembler.hpp:2253
OperatingMode
Supported operating modes.
Definition: fcml_common.hpp:531
void setNobranch(bool isNobranch)
Sets no-branch prefix availability.
Definition: fcml_disassembler.hpp:632
void setRPrim(fcml_uint8_t rPrim)
Sets R' flag.
Definition: fcml_disassembler.hpp:1004
bool isXop() const
Gets true if XOP prefix is available.
Definition: fcml_disassembler.hpp:762
bool isPseudoOp() const
Gets true is it's a pseudo operation.
Definition: fcml_disassembler.hpp:1773
fcml_bool mandatory_prefix
FCML_TRUE if prefix is treated as mandatory one.
Definition: fcml_disassembler.h:116
LIB_EXPORT void LIB_CALL fcml_fn_disassembler_result_prepare(fcml_st_disassembler_result *result)
Prepares reusable result holder for disassembler.
void setPrefixesDetails(const PrefixesDetails &prefixesDetails)
Sets a new instruction prefixes details.
Definition: fcml_disassembler.hpp:1743
fcml_uint8_t R
R field of REX,XOP or VEX prefix.
Definition: fcml_disassembler.h:161
fcml_bool is_branch
FCML_TRUE if branch prefix exists.
Definition: fcml_disassembler.h:135
const Instruction & getInstruction() const
Gets errors container with errors related to the failed disassembling process.
Definition: fcml_disassembler.hpp:1899
fcml_bool is_rex
FCML_TRUE if REX prefix exists.
Definition: fcml_disassembler.h:157
fcml_uint8_t L_prim
L’ field of EVEX prefix.
Definition: fcml_disassembler.h:175
Prefixes details.
Definition: fcml_disassembler.hpp:489
fcml_st_raw_displacement displacement
Raw displacement.
Definition: fcml_disassembler.h:218
Disassembler result.
Definition: fcml_disassembler.hpp:1877
fcml_uint8_t getB() const
Gets b flag.
Definition: fcml_disassembler.hpp:562
const PrefixesDetails & getPrefixesDetails() const
Gets instruction prefixes details.
Definition: fcml_disassembler.hpp:1723
fcml_uint16_t getAddrMode() const
Gets address mode/instruction form.
Definition: fcml_disassembler.hpp:1497
fcml_uint16_t addr_mode
Code of the instruction form/addressing mode of the instruction above.
Definition: fcml_disassembler.h:259
bool isOpcodeFieldSBit() const
Gets opcode field 'S'.
Definition: fcml_disassembler.hpp:1651
Undefined mode.
Definition: fcml_common.h:544
fcml_uint8_t getW() const
Gets W flag.
Definition: fcml_disassembler.hpp:1094
fcml_uint8_t conditional_group
There are two groups of suffixes for conditional instructions, you can choose which one should be use...
Definition: fcml_disassembler.h:64
fcml_st_prefixes_details prefixes_details
Some additional information about decoded instruction prefixes.
Definition: fcml_disassembler.h:238
Wraps multiple errors into one component.
Definition: fcml_errors.hpp:148
const InstructionDetails & getInstructionDetails() const
Gets instruction details associated with the instruction.
Definition: fcml_disassembler.hpp:1909
fcml_bool is_shortcut
True if this is a shortcut.
Definition: fcml_disassembler.h:229
fcml_st_disassembler * disassembler
Disassembler used to decode instructions.
Definition: fcml_disassembler.h:82
InstructionPrefixDetails & getPrefixes(fcml_usize index)
Gets a reference to the prefix of the given index.
Definition: fcml_disassembler.hpp:920
void setShortcut(bool isShortcut)
Marks the instruction as a shortcut.
Definition: fcml_disassembler.hpp:1611
void setRex(bool isRex)
Sets REX prefix availability.
Definition: fcml_disassembler.hpp:692
AccessMode
Definition: fcml_disassembler.hpp:1256
Describes an instruction.
Definition: fcml_common.hpp:7185
void setInstruction(const Instruction &instruction)
Sets a new instruction for the result.
Definition: fcml_disassembler.hpp:1960
InstructionDetails & getInstructionDetailsInternal()
Gets mutable instruction details.
Definition: fcml_disassembler.hpp:1933
#define FCML_INSTRUCTION_SIZE
Maximal number of bytes instruction can use.
Definition: fcml_common.h:37
fcml_usize code_length
Size of the code in the buffer above.
Definition: fcml_disassembler.h:90
void setExtendDispToAsa(bool extendDispToAsa)
Definition: fcml_disassembler.hpp:112
#define FCML_DASM_PREFIXES_COUNT
Maximal number of instruction prefixes.
Definition: fcml_disassembler.h:42
bool isRex() const
Gets true if Rex prefix is available.
Definition: fcml_disassembler.hpp:682
void setXop(bool isXop)
Sets XOP prefix availability.
Definition: fcml_disassembler.hpp:772
fcml_bool opcode_field_w_bit
Opcode field 'w'.
Definition: fcml_disassembler.h:252
Operation succeed.
Definition: fcml_errors.h:42
fcml_usize getCodeLength() const
Gets length of the buffer in bytes.
Definition: fcml_disassembler.hpp:233
void setErrorContainer(const ErrorContainer &errorContainer)
Sets error container.
Definition: fcml_disassembler.hpp:1969
bool isExtendDispToAsa() const
Definition: fcml_disassembler.hpp:107
const Nullable< fcml_uint8_t > & getSib() const
Gets SIB nullable byte.
Definition: fcml_disassembler.hpp:1380
void setPp(fcml_uint8_t pp)
Sets PP field.
Definition: fcml_disassembler.hpp:892
fcml_uint8_t modrm
ModR/M byte if exists.
Definition: fcml_disassembler.h:209
void setSib(const Nullable< fcml_uint8_t > &sib)
Sets SIB nullable byte.
Definition: fcml_disassembler.hpp:1400
fcml_st_ceh_error_container errors
All errors and warnings messages going here.
Definition: fcml_disassembler.h:269
Bad arguments.
Definition: fcml_common.hpp:242
Disassembler context.
Definition: fcml_disassembler.hpp:183
void setThrowExceptionOnError(bool throwExceptionOnError)
Sets the way how the error handling is done.
Definition: fcml_disassembler.hpp:164
fcml_nuint8_t sib
SIB byte if exists.
Definition: fcml_disassembler.h:211
void setBcast(bool b)
Sets EVEX.b bit.
Definition: fcml_disassembler.hpp:1144
OperandDetails(AccessMode accessMode)
Creates operand details for given access mode.
Definition: fcml_disassembler.hpp:1281
fcml_uint8_t getPrefix() const
Gets the prefix byte.
Definition: fcml_disassembler.hpp:419
fcml_bool carry_flag_conditional_suffix
True if suffixes for carry flag has to be used by disassembler.
Definition: fcml_disassembler.h:61
An abstract dialect.
Definition: fcml_dialect.hpp:41
void setOpcodeFieldWBit(bool opcodeFieldWBit)
Sets 'W' field of the opcode byte.
Definition: fcml_disassembler.hpp:1681
fcml_uint8_t * getInstructionCode()
Gets a pointer to the instruction code.
Definition: fcml_disassembler.hpp:1549
void setConditionalGroup(fcml_uint8_t conditionalGroup)
Definition: fcml_disassembler.hpp:92
fcml_en_instruction getInstruction() const
Gets instruction code.
Definition: fcml_disassembler.hpp:1517
fcml_uint8_t getX() const
Gets X flag.
Definition: fcml_disassembler.hpp:1114
Operand details.
Definition: fcml_disassembler.hpp:1252
void setVex(bool isVex)
Sets VEX prefix availability.
Definition: fcml_disassembler.hpp:712
fcml_bool is_xrelease
FCML_TRUE if xrelease explicit prefix exists.
Definition: fcml_disassembler.h:145
void setIP(fcml_ip ip)
Sets instruction pointer directly into the entry point.
Definition: fcml_disassembler.hpp:315
bool isIncrementIp() const
Definition: fcml_disassembler.hpp:127
fcml_usize instruction_size
Instruction size in bytes.
Definition: fcml_disassembler.h:236
fcml_uint8_t getAvxFirstByte() const
Gets the first byte of the AVX prefix.
Definition: fcml_disassembler.hpp:1014
fcml_uint8_t aaa
Embedded opmask register specifier.
Definition: fcml_disassembler.h:187
const DisassemblerConf & getDisassemblerConf() const
Gets a reference to the configuration object associated with the context.
Definition: fcml_disassembler.hpp:253
bool isFailIfUnknownInstruction() const
Definition: fcml_disassembler.hpp:117
fcml_int getPrefixesCount() const
Gets number of prefixes available for the instruction.
Definition: fcml_disassembler.hpp:954
fcml_uint8_t avx_first_byte
First byte of AVX prefix.
Definition: fcml_disassembler.h:159
fcml_bool is_lock
FCML_TRUE if lock explicit prefix exists.
Definition: fcml_disassembler.h:139
void setInstruction(fcml_en_instruction instruction)
Gets a new instruction code for the instruction.
Definition: fcml_disassembler.hpp:1527
bool isOpcodeFieldWBit() const
Gets opcode field 'W'.
Definition: fcml_disassembler.hpp:1671
InstructionPrefixDetails & operator[](fcml_usize index)
Gets reference to the instruction prefix at given index.
Definition: fcml_disassembler.hpp:549
void setRep(bool isRep)
Sets Rep prefix availability.
Definition: fcml_disassembler.hpp:652
ErrorContainerAwareException(const fcml_cstring &msg, const ErrorContainer &errorContainer, fcml_ceh_error error=FCML_CEH_GEC_NO_ERROR)
Creates an error container aware exception instance and sets basic information for it...
Definition: fcml_errors.hpp:357
fcml_uint8_t b
b field of EVEX prefix.
Definition: fcml_disassembler.h:169
Component can not be initialized correctly.
Definition: fcml_common.hpp:231
struct fcml_st_disassembler fcml_st_disassembler
This structure and type declaration represents an abstract disassembler.
Definition: fcml_disassembler.h:50
LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_disassembler_init(const fcml_st_dialect *dialect, fcml_st_disassembler **disassembler)
Initializes disassembler instance.
void setW(fcml_uint8_t W)
Sets W flag.
Definition: fcml_disassembler.hpp:1104
Additional instruction details provided by disassembler.
Definition: fcml_disassembler.h:222
Nullable< fcml_uint8_t > & getSib()
Gets SIB nullable byte.
Definition: fcml_disassembler.hpp:1390
fcml_uint16_t fcml_ceh_error
All error codes should be held in variables of this type.
Definition: fcml_errors.h:156
fcml_uint8_t getL() const
Gets L flag.
Definition: fcml_disassembler.hpp:822
void setMandatoryPrefix(bool mandatoryPrefix)
Sets mandatory prefix flag for the prefix.
Definition: fcml_disassembler.hpp:409
Object which shouldn't be copied can inherit from this class.
Definition: fcml_common.hpp:288
const Integer & getDisplacement() const
Gets constant raw displacement.
Definition: fcml_disassembler.hpp:1440
void setX(fcml_uint8_t X)
Sets X flag.
Definition: fcml_disassembler.hpp:1124
fcml_uint8_t getMmmm() const
Gets MMMM field.
Definition: fcml_disassembler.hpp:862
C++ wrapper for the FCML errors handling.
fcml_uint8_t z
z field of EVEX prefix
Definition: fcml_disassembler.h:183
Illegal argument exception.
Definition: fcml_common.hpp:264
void setPrefixesCount(fcml_int prefixesCount)
Sets number of prefixes available for the instruction.
Definition: fcml_disassembler.hpp:964
LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_disassemble(fcml_st_disassembler_context *context, fcml_st_disassembler_result *result)
Disassembles one instruction from provided code buffer.
void setAvx(bool isAvx)
Sets XOP prefix availability.
Definition: fcml_disassembler.hpp:792
PrefixesDetails()
Default constructor.
Definition: fcml_disassembler.hpp:496
void setZ(bool z)
Sets EVEX.z bit.
Definition: fcml_disassembler.hpp:1164
fcml_nuint32_t N
Scaling factor N in EVEX specific compressed disp8*N.
Definition: fcml_disassembler.h:203
fcml_uint8_t getRPrim() const
Gets R' flag.
Definition: fcml_disassembler.hpp:994
fcml_st_operand_details operand_details[FCML_OPERANDS_COUNT]
All disassembler specific information about operands going there.
Definition: fcml_disassembler.h:240
const ErrorContainer & getErrorContainer() const
Gets errors container with errors related to the failed disassembling process.
Definition: fcml_disassembler.hpp:1888
fcml_uint8_t pp
pp field of XOP or VEX/EVEX prefix.
Definition: fcml_disassembler.h:181
fcml_st_instruction_prefix prefixes[FCML_DASM_PREFIXES_COUNT]
Array with decoded prefixes.
Definition: fcml_disassembler.h:129
const InstructionPrefixDetails & operator[](fcml_usize index) const
Gets reference to the instruction prefix at given index.
Definition: fcml_disassembler.hpp:535