dynarmic/include/Zydis/DecoderTypes.h
Alexandre Bouvier 6fa8d51479 Squashed 'externals/zydis/' changes from 25193db0..1ba75aee
1ba75aee Disassembler: fix argument type `usize` -> `u64`
de4cbcdb MSVC project updates (#400)
e32757cd CMake: Enable `CMAKE_MSVC_RUNTIME_LIBRARY` (MSVC)
325e5e00 CI: fix Doxyfile being used
3ad3d7fc CI: inject Doxygen CSS theme
a1dd0652 Doc: remove CSS theme from Zydis repository
cc4f22cb Makefile: fix doc target name
83d2afa9 Update zycore to v1.4.0
53dd0880 Match parameter name for documentation
64028db9 Allow doxygen generation to be disabled
4bb3c83f Fixed ISA sets (Fixes #389)
2a9f9c66 Decoder: change error code for `NULL` `buffer` arguments
807af687 Examples: adjust to `ZydisDecoderDecodeFull` changes
71fe85a7 Tools: adjust to `ZydisDecoderDecodeFull` changes
59135031 Decoder: simplify `ZydisDecoderDecodeFull` API
e5e52676 Makefile: fix `test` recipe
bcb0a361 CMake: rename target `doc` -> `ZydisDoc`
3208f041 Add support for ppc(64) and riscv64 (#383)
0002161e Deps: update zycore to v1.3.0
e0fc2a92 CMake: simplify example build rules
2221bce3 README: switch decoder example to simplified version
392aa410 Examples: add `@file` comment to `Disassemble` example
cff56e42 Examples: add `DisassembleSimple`
246d471b Disassemble: add function for decoding and formatting in one step
109d08ba build(make): use new doc target
ebf95079 build: add doc target
df277052 Fixed kernel build (WDK detection)
daf7c62d Decoder: unnest all structs in `ZydisDecodedInstruction`
89cba0c2 Formatter: provide more meaningful documentation for types
f8344423 Doc: remove misspelled `@brief`
6cbdb04a Doc: update `Doxyfile` config to latest version
67e15cf0 Doc: fix group references
f6dfdbd2 Added `ZydisEncoderNopFill`
404e50b5 Doc: group important macros and refer to them
c6141110 CI: clone doxygen theme prior to building doc
9d6c82a3 CI: add automated documentation builds
f8866275 Formatter: add missing newline at end of file
2a06d5e5 Decoder: add missing `ZYAN_FALLTHROUGH`
b83a3923 CI: enable development mode for all CI builds
eca25034 CI: switch to an include-only way of defining the build matrix
dd271e90 README: update CI badge URL
90d54ee8 Fix sign compare warnings on clang-cl
e66c7010 CI: shorten name prefix
91f9d4ea CI: improved build name generation
14800b6f CI: add ClangCL build on Windows
55b23387 CI: consistently use default-init for empty vars
6c39010e CI: generalize `dev_mode` variable to `cmake_flags`
3160753d Formatter: make `operand_count` check less strict
9b9b72c9 README: include examples via permalinks
adb1a85b Examples: add README encoder example to build
0897c271 Doc: switch Doxygen theme
9cb54996 Examples: add README examples to build
a762cd6a README: fix example code
503e064c Fixed compiler warnings
091016bd Update workflow
f29de7d8 Added tests for encoding in absolute address mode
355ce7e3 Added function to calculate and encode relative operands
73a44921 Updating ZyCore
9413c809 Doc: clarify that `user_data` can be `NULL`
f0f44096 Simplify porting guide `Formatter` section
9ba7e55a Combine `ZydisFormatterTokenizeOperand` with `Ex` variant
35ea249d Combine `ZydisFormatterTokenizeInstruction` with `Ex` variant
01dddb93 Combine `ZydisFormatterFormatOperand` and `Ex` variant
abcacbcb Combine `ZydisFormatterFormatInstruction` and `Ex` variant
871c40c5 Clean up `.gitignore` file
a941e961 Doc: update porting guide
e973b3ec MSVC: add `Segment.{h,c}` to projects
dbaec910 Build: make segment API an optional feature
cd508f3b Utils: split segment API into separate files
2677d5a2 Add Makefile for quick access to various operations
83eddf40 Decoder: fix name confusion (context vs state)
e46660c7 Decoder: make placement of parentheses consistent
cc9ff174 Fix build without `ZYDIS_FEATURE_ENCODER`
9b882913 Revert default operand-size to 32-bit for `MOVMSKPS/D`
73d7dbb3 Improved signedness data accuracy and consistency (Fixes #327)
f46e3e9d Update zasm URL
2ed04d0c Decoder: add `raw.rex` to union
dd6235c5 Duplicate encoding to aid Rust bindings
c8b5b75d Always initialize `instruction->cpu_flags/fpu_flags`
9392f010 Extend porting guide (#338)
14453b30 Encoder: consistent constant naming (#339)
95329939 Avoid passing variable size to memcpy to prevent external call (#337)
f0f0664a Encoder: improve `ZydisArePrefixesCompatible` perf (#334)
7f83c416 Improve LTO support (#333)
70085c71 Encoder: make all internal functions `static`
1581029c Change `st0` operand visibility as specified by SDM
81fae568 Update regression tests for `st0` visibility changes
6d83a277 Declare structs as anonymous within anonymous unions (#329)
f146fd18 Apply consistent encodings to existing files
cdbf379a Enforce consistent encoding and line endings
0cf3c960 Disable C11 feature warnings in Windows kernel example
6afe1d80 Update Zycore submodule
580cbfe6 Add unions in decoded instruction and operands
e14a0789 Fix `vcpkg` install instructions
3f5a3ad8 Cleanup zydis include
c0e80e79 Fixed error codes inside `ZydisDecoderDecodeFull`
770c3203 Fix incorrect register definition
0a45c474 Change default operand size for `MOVMSKPS/D` to 64-bit
91742f41 Fixed hidden operand scaling regression (Fixes #309)
b44ec347 Remove LuaJIT bindings link
4f232ebf Fixed edge case for hidden operand scaling (Fixes #296)
562a7c1e Fixed newlines on Windows (amalgamation)
79c759ed Fixed signedness compilation warning (MSVC x86)
3092818a Fixed defines in MSVC projects
124571c5 Improve CMake file
69636284 Add amalgamated CI build
d866d2e4 Rename STR_REGISTER -> STR_REGISTERS
bd392018 Add script for creating amalgamated distributions
311fb0b4 Prevent duplicate CI builds
9770c41d Get rid of ZydisExportConfig.h
cbc23017 Update zycore submodule
e34e6b97 Remove register lookup special cases
a5fb0d09 Fix `MASM` style disassembly (#298)
9fc98de2 Point to zasm for an assembler front-end
4756724a Ignore `.b` for `modrm.rm` encoded mask registers
198fee5d Improved prefix handling
a8e43f84 Fixed `MVEX.EH` special cases
ecb7e060 Reworked encoding of branching instructions (Fixes #268, Fixes #266)
38aba0fc Improve `ZydisInfo`
0d650daf Fixed decoder example
49005dd8 Add lookup tables for `ZydisRegister` and `ZydisRegisterClass` (#283)
c804b8f6 Refactored operand count checks
979f0bea Update porting guide
875c8a75 Decouple operand decoding
5df1b68e Minor refactoring
66e81ebe Add WebAssembly support (#277)
33c5bccf Refactor operand constraints handling
b5a92f4e Fixed constraint enforcement for AMX instructions
db2c1633 Add regression tests for recent bugs (#275)
17896d72 Add a minimal mode build to CI (#274)
84dfb487 Fix register constraints of certain `AMX` instructions
4581fe30 Fixed build in minimal mode (#273)
70d6bda3 Make test scripts executable
93b503da Add encoder tests to CI (#272)
4f38dd50 Auto-generated `zydis_encoder_types.py`
69884f0e Fix constraints of certain `AMX` instructions
92dffbf2 Correctly set `is_gather` for MVEX instructions
23b499a7 Enforce MVEX constraints
7b981a6f Enforce constraints for gather instructions (Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=41044)
4f4dade2 Move fuzzing corpus out of the repository
d835ac30 docs: add man pages (#267)
f2429819 Update version-bump-checklist.txt
7d6ee06e Remove legacy code and general cleanup (#262)
162ef4ef Fix various warnings ocurring in pedantic mode
4189d830 Move static asserts to global scope
9fab1a82 `ZydisEncodablePrefix`/`ZydisEncoderInstructionAttribute` -> `ZYDIS_ATTRIB_*`
9f569b7c Size-optimal outputs, bug fixes, FuzzEncoder improvements, misc tooling improvements
1e8e1702 Added regression test suite for encoder
4634cc22 Update `examples/README.md`
043b2cc3 Added separate projects for fuzz targets
0faa2346 Add porting guide
248bc1fc Move instruction attributes into `SharedTypes.h`
4e0cb756 Fix attribute definitions
ecb1286f Add example for rewriting instructions
606e361c Fix unaligned pointer write
3707e70f Rebase attribute flags and add `ZYDIS_ATTRIB_HAS_EVEX_B`
8a452a32 Prefer stdlib functions in example
46cd3e02 Documentation improvements
fbcfc5d9 Improve encoder example and cleanup README
edcac7b3 Extend example to execute the generated code
2a8eb8e2 Add simple encoding example
d3b5e241 Fixed compiler warning
76fdffac Added operand masks for enhanced performance
cd6a49e9 Implemented instruction encoder (Closes #129)
29bb0163 Don't pack ZydisShortString on Darwin (#259)
55dd08c2 Fix struct initialization in formatter
554efeb7 Update example code in README.md
869dfb42 Remove ZydisPE
6ae9f61b Create SECURITY.md
077b1851 Fix merge conflict
99a22d85 Fix general address-width handling
ab535b1a build(cmake): add option to use system installed Zycore
746faa45 Bump version to v3.2
c3720691 Merged some definitions (TBM instructions)
12b4c46f chore: update zycore submodule
6423f083 build(cmake): add version and soversion to the library
2666f80c Update zycore submodule
4a3f25be build(cmake): fix PUBLIC include dir of installed lib
c5f5bcf3 Set `ZYDIS_ATTRIB_ACCEPTS_SEGMENT` for non legacy instructions
795f555b Fix `ECX` scaling for `pcmpestri`/`vpcmpestri`/`pcmpistri`/`vpcmpistri`
3737fcbd Fixed segment override handling (Fixes #231)
db796058 Fixed FP16 HV broadcasts (Fixes #243)
e5764446 Fixed no_source_dest_match check (Fixes #241)
683bf85c Change branch-type from `short` -> `near` for `jkzd`/`jknzd`
c462f63a Scale base register of implicit `SP`/`BP` memory operands by stack- instead of address-size
e4931747 Do not sign ZydisWinKernel sample
5c193ca3 Ignore segment override for `BNDC{L|N|U}`
f30efaf0 Add mission exception class strings to `ZydisInfo`
82a42657 Rebase tests
e38110a4 Add missing `notrack` strings to `ZydisInfo`
c95307b3 Do not drop `const` modifier
8ac69395 Fixed {sae}/{rc} formatting (Fixes #232)
80d8d523 Fixed issues with enum signedness
5503f8b0 Fuzzing: validate enum ranges
49a087f9 Fixed MVEX rounding mode decoding (Fixes #226) (#227)
60bc090a Rebase tests
4c7ec7fb Replace wrong eviction hint formatter-string
45ad14c6 Add missing register string
2613f262 Fixed Load-op SwizzUpConv(F32) (Fixes #224)
412a3c8e Add support for `no_compat_mode` flag
255513a6 Fix `T1F` handling for 16-bit elements
e57da244 Fix element-size for new `QUARTER` tuple-type
d36c77f2 Improve malformed `EVEX` conditions
5ec77520 Update MSVC project files
80a99de0 Fix `EVEX` map for certain `AVX-512 FP16` instructions
ac3d45b4 Add `MSBuild` build to CI
1588ad23 Update and clean up CI config
b622e814 Update zycore submodule
7fc3a946 Fix decoding/formatting of certain `AVX-512 FP16` instructions
e6a72bbf Update copyright year
841bd7ca Update zycore submodule
61731ae2 Fix formatting of offset for `PTR` operands (should be unsigned)
ad7ddc2c Add `AVX-512 FP16` isa-set (#214)
861187e2 Use lowercase `windows.h` in examples
e5758caa Add multiple new ISA extensions
984e0c1d `XOP`/`VEX`/`EVEX` is invalid in 16-bit real mode
58662bf5 Fixed CET/VMX decoding in real mode (Fixes #211)
4c846ec9 Add formatter option to control printing of scale `*1`
e994083e Print asterisk in front of absolute `jmp`/`call` address (AT&T) (#207)
2ab6a5cc Improve multiple instruction definitions
179441f3 Add support for `CET` `no-track` prefix (#204)
e3fc6790 Ignore segment override for certain operands (#203)
68ad2460 Document xbegin special case
805a88f8 Improved handling of 16-bit relative operands (Fixes #198)
cbf808a7 Removed impossible jcxz/jrcxz encodings (Fixes #196)
8080ae55 Fix cmake config files (#191)
fe8f1bfd Enhanced formatting for MIB operands
efd9c446 Fixes #192 (#193)
6a17c485 Update `Zycore` submodule

git-subtree-dir: externals/zydis
git-subtree-split: 1ba75aeefae37094c7be8eba07ff81d4fe0f1f20
2022-11-20 21:52:09 +01:00

1447 lines
38 KiB
C

/***************************************************************************************************
Zyan Disassembler Library (Zydis)
Original Author : Florian Bernd
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
***************************************************************************************************/
/**
* @file
* Defines the basic `ZydisDecodedInstruction` and `ZydisDecodedOperand` structs.
*/
#ifndef ZYDIS_INSTRUCTIONINFO_H
#define ZYDIS_INSTRUCTIONINFO_H
#include <Zycore/Types.h>
#include <Zydis/MetaInfo.h>
#include <Zydis/Mnemonic.h>
#include <Zydis/Register.h>
#include <Zydis/SharedTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================================== */
/* Decoded operand */
/* ============================================================================================== */
/* ---------------------------------------------------------------------------------------------- */
/* Operand attributes */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisOperandAttributes` data-type.
*/
typedef ZyanU8 ZydisOperandAttributes;
/**
* The operand is a `MULTISOURCE4` register operand.
*
* This is a special register operand-type used by `4FMAPS` instructions where the given register
* points to the first register of a register range (4 registers in total).
*
* Example: ZMM3 -> [ZMM3..ZMM6]
*/
#define ZYDIS_OATTRIB_IS_MULTISOURCE4 0x01 // (1 << 0)
/* ---------------------------------------------------------------------------------------------- */
/* Memory type */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMemoryOperandType` enum.
*/
typedef enum ZydisMemoryOperandType_
{
ZYDIS_MEMOP_TYPE_INVALID,
/**
* Normal memory operand.
*/
ZYDIS_MEMOP_TYPE_MEM,
/**
* The memory operand is only used for address-generation. No real memory-access is
* caused.
*/
ZYDIS_MEMOP_TYPE_AGEN,
/**
* A memory operand using `SIB` addressing form, where the index register is not used
* in address calculation and scale is ignored. No real memory-access is caused.
*/
ZYDIS_MEMOP_TYPE_MIB,
/**
* A vector `SIB` memory addressing operand (`VSIB`).
*/
ZYDIS_MEMOP_TYPE_VSIB,
/**
* Maximum value of this enum.
*/
ZYDIS_MEMOP_TYPE_MAX_VALUE = ZYDIS_MEMOP_TYPE_VSIB,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MEMOP_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MEMOP_TYPE_MAX_VALUE)
} ZydisMemoryOperandType;
/* ---------------------------------------------------------------------------------------------- */
/* Decoded operand */
/* ---------------------------------------------------------------------------------------------- */
/**
* Extended info for register-operands.
*/
typedef struct ZydisDecodedOperandReg_
{
/**
* The register value.
*/
ZydisRegister value;
} ZydisDecodedOperandReg;
/**
* Extended info for memory-operands.
*/
typedef struct ZydisDecodedOperandMem_
{
/**
* The type of the memory operand.
*/
ZydisMemoryOperandType type;
/**
* The segment register.
*/
ZydisRegister segment;
/**
* The base register.
*/
ZydisRegister base;
/**
* The index register.
*/
ZydisRegister index;
/**
* The scale factor.
*/
ZyanU8 scale;
/**
* Extended info for memory-operands with displacement.
*/
struct ZydisDecodedOperandMemDisp_
{
/**
* Signals, if the displacement value is used.
*/
ZyanBool has_displacement;
/**
* The displacement value
*/
ZyanI64 value;
} disp;
} ZydisDecodedOperandMem;
/**
* Extended info for pointer-operands.
*/
typedef struct ZydisDecodedOperandPtr_
{
ZyanU16 segment;
ZyanU32 offset;
} ZydisDecodedOperandPtr;
/**
* Extended info for immediate-operands.
*/
typedef struct ZydisDecodedOperandImm_
{
/**
* Signals, if the immediate value is signed.
*/
ZyanBool is_signed;
/**
* Signals, if the immediate value contains a relative offset. You can use
* `ZydisCalcAbsoluteAddress` to determine the absolute address value.
*/
ZyanBool is_relative;
/**
* The immediate value.
*/
union ZydisDecodedOperandImmValue_
{
ZyanU64 u;
ZyanI64 s;
} value;
} ZydisDecodedOperandImm;
/**
* Defines the `ZydisDecodedOperand` struct.
*/
typedef struct ZydisDecodedOperand_
{
/**
* The operand-id.
*/
ZyanU8 id;
/**
* The visibility of the operand.
*/
ZydisOperandVisibility visibility;
/**
* The operand-actions.
*/
ZydisOperandActions actions;
/**
* The operand-encoding.
*/
ZydisOperandEncoding encoding;
/**
* The logical size of the operand (in bits).
*/
ZyanU16 size;
/**
* The element-type.
*/
ZydisElementType element_type;
/**
* The size of a single element.
*/
ZydisElementSize element_size;
/**
* The number of elements.
*/
ZyanU16 element_count;
/*
* Additional operand attributes.
*/
ZydisOperandAttributes attributes;
/**
* The type of the operand.
*/
ZydisOperandType type;
/*
* Operand type specific information.
*
* The enabled union variant is determined by the `type` field.
*/
union
{
ZydisDecodedOperandReg reg;
ZydisDecodedOperandMem mem;
ZydisDecodedOperandPtr ptr;
ZydisDecodedOperandImm imm;
};
} ZydisDecodedOperand;
/* ---------------------------------------------------------------------------------------------- */
/* ============================================================================================== */
/* Decoded instruction */
/* ============================================================================================== */
/* ---------------------------------------------------------------------------------------------- */
/* CPU/FPU flags */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisAccessedFlagsMask` data-type.
*/
typedef ZyanU32 ZydisAccessedFlagsMask;
/**
* @defgroup decoder_cpu_flags CPU flags
* @ingroup decoder
*
* Constants used for testing CPU flags accessed by an instruction.
*
* @{
*/
/**
* Carry flag.
*/
#define ZYDIS_CPUFLAG_CF (1ul << 0)
/**
* Parity flag.
*/
#define ZYDIS_CPUFLAG_PF (1ul << 2)
/**
* Adjust flag.
*/
#define ZYDIS_CPUFLAG_AF (1ul << 4)
/**
* Zero flag.
*/
#define ZYDIS_CPUFLAG_ZF (1ul << 6)
/**
* Sign flag.
*/
#define ZYDIS_CPUFLAG_SF (1ul << 7)
/**
* Trap flag.
*/
#define ZYDIS_CPUFLAG_TF (1ul << 8)
/**
* Interrupt enable flag.
*/
#define ZYDIS_CPUFLAG_IF (1ul << 9)
/**
* Direction flag.
*/
#define ZYDIS_CPUFLAG_DF (1ul << 10)
/**
* Overflow flag.
*/
#define ZYDIS_CPUFLAG_OF (1ul << 11)
/**
* I/O privilege level flag.
*/
#define ZYDIS_CPUFLAG_IOPL (1ul << 12)
/**
* Nested task flag.
*/
#define ZYDIS_CPUFLAG_NT (1ul << 14)
/**
* Resume flag.
*/
#define ZYDIS_CPUFLAG_RF (1ul << 16)
/**
* Virtual 8086 mode flag.
*/
#define ZYDIS_CPUFLAG_VM (1ul << 17)
/**
* Alignment check.
*/
#define ZYDIS_CPUFLAG_AC (1ul << 18)
/**
* Virtual interrupt flag.
*/
#define ZYDIS_CPUFLAG_VIF (1ul << 19)
/**
* Virtual interrupt pending.
*/
#define ZYDIS_CPUFLAG_VIP (1ul << 20)
/**
* Able to use CPUID instruction.
*/
#define ZYDIS_CPUFLAG_ID (1ul << 21)
/**
* @}
*/
/**
* @defgroup decoder_fpu_flags FPU flags
* @ingroup decoder
*
* Constants used for testing FPU flags accessed by an instruction.
*
* @{
*/
/**
* FPU condition-code flag 0.
*/
#define ZYDIS_FPUFLAG_C0 (1ul << 0)
/**
* FPU condition-code flag 1.
*/
#define ZYDIS_FPUFLAG_C1 (1ul << 1)
/**
* FPU condition-code flag 2.
*/
#define ZYDIS_FPUFLAG_C2 (1ul << 2)
/**
* FPU condition-code flag 3.
*/
#define ZYDIS_FPUFLAG_C3 (1ul << 3)
/**
* @}
*/
/*
* Information about CPU/FPU flags accessed by the instruction.
*/
typedef struct ZydisAccessedFlags_
{
/*
* As mask containing the flags `TESTED` by the instruction.
*/
ZydisAccessedFlagsMask tested;
/*
* As mask containing the flags `MODIFIED` by the instruction.
*/
ZydisAccessedFlagsMask modified;
/*
* As mask containing the flags `SET_0` by the instruction.
*/
ZydisAccessedFlagsMask set_0;
/*
* As mask containing the flags `SET_1` by the instruction.
*/
ZydisAccessedFlagsMask set_1;
/*
* As mask containing the flags `UNDEFINED` by the instruction.
*/
ZydisAccessedFlagsMask undefined;
} ZydisAccessedFlags;
/* ---------------------------------------------------------------------------------------------- */
/* Branch types */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisBranchType` enum.
*/
typedef enum ZydisBranchType_
{
/**
* The instruction is not a branch instruction.
*/
ZYDIS_BRANCH_TYPE_NONE,
/**
* The instruction is a short (8-bit) branch instruction.
*/
ZYDIS_BRANCH_TYPE_SHORT,
/**
* The instruction is a near (16-bit or 32-bit) branch instruction.
*/
ZYDIS_BRANCH_TYPE_NEAR,
/**
* The instruction is a far (inter-segment) branch instruction.
*/
ZYDIS_BRANCH_TYPE_FAR,
/**
* Maximum value of this enum.
*/
ZYDIS_BRANCH_TYPE_MAX_VALUE = ZYDIS_BRANCH_TYPE_FAR,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_BRANCH_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_BRANCH_TYPE_MAX_VALUE)
} ZydisBranchType;
/* ---------------------------------------------------------------------------------------------- */
/* SSE/AVX exception-class */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisExceptionClass` enum.
*/
typedef enum ZydisExceptionClass_
{
ZYDIS_EXCEPTION_CLASS_NONE,
// TODO: FP Exceptions
ZYDIS_EXCEPTION_CLASS_SSE1,
ZYDIS_EXCEPTION_CLASS_SSE2,
ZYDIS_EXCEPTION_CLASS_SSE3,
ZYDIS_EXCEPTION_CLASS_SSE4,
ZYDIS_EXCEPTION_CLASS_SSE5,
ZYDIS_EXCEPTION_CLASS_SSE7,
ZYDIS_EXCEPTION_CLASS_AVX1,
ZYDIS_EXCEPTION_CLASS_AVX2,
ZYDIS_EXCEPTION_CLASS_AVX3,
ZYDIS_EXCEPTION_CLASS_AVX4,
ZYDIS_EXCEPTION_CLASS_AVX5,
ZYDIS_EXCEPTION_CLASS_AVX6,
ZYDIS_EXCEPTION_CLASS_AVX7,
ZYDIS_EXCEPTION_CLASS_AVX8,
ZYDIS_EXCEPTION_CLASS_AVX11,
ZYDIS_EXCEPTION_CLASS_AVX12,
ZYDIS_EXCEPTION_CLASS_E1,
ZYDIS_EXCEPTION_CLASS_E1NF,
ZYDIS_EXCEPTION_CLASS_E2,
ZYDIS_EXCEPTION_CLASS_E2NF,
ZYDIS_EXCEPTION_CLASS_E3,
ZYDIS_EXCEPTION_CLASS_E3NF,
ZYDIS_EXCEPTION_CLASS_E4,
ZYDIS_EXCEPTION_CLASS_E4NF,
ZYDIS_EXCEPTION_CLASS_E5,
ZYDIS_EXCEPTION_CLASS_E5NF,
ZYDIS_EXCEPTION_CLASS_E6,
ZYDIS_EXCEPTION_CLASS_E6NF,
ZYDIS_EXCEPTION_CLASS_E7NM,
ZYDIS_EXCEPTION_CLASS_E7NM128,
ZYDIS_EXCEPTION_CLASS_E9NF,
ZYDIS_EXCEPTION_CLASS_E10,
ZYDIS_EXCEPTION_CLASS_E10NF,
ZYDIS_EXCEPTION_CLASS_E11,
ZYDIS_EXCEPTION_CLASS_E11NF,
ZYDIS_EXCEPTION_CLASS_E12,
ZYDIS_EXCEPTION_CLASS_E12NP,
ZYDIS_EXCEPTION_CLASS_K20,
ZYDIS_EXCEPTION_CLASS_K21,
ZYDIS_EXCEPTION_CLASS_AMXE1,
ZYDIS_EXCEPTION_CLASS_AMXE2,
ZYDIS_EXCEPTION_CLASS_AMXE3,
ZYDIS_EXCEPTION_CLASS_AMXE4,
ZYDIS_EXCEPTION_CLASS_AMXE5,
ZYDIS_EXCEPTION_CLASS_AMXE6,
/**
* Maximum value of this enum.
*/
ZYDIS_EXCEPTION_CLASS_MAX_VALUE = ZYDIS_EXCEPTION_CLASS_AMXE6,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_EXCEPTION_CLASS_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_EXCEPTION_CLASS_MAX_VALUE)
} ZydisExceptionClass;
/* ---------------------------------------------------------------------------------------------- */
/* AVX mask mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMaskMode` enum.
*/
typedef enum ZydisMaskMode_
{
ZYDIS_MASK_MODE_INVALID,
/**
* Masking is disabled for the current instruction (`K0` register is used).
*/
ZYDIS_MASK_MODE_DISABLED,
/**
* The embedded mask register is used as a merge-mask.
*/
ZYDIS_MASK_MODE_MERGING,
/**
* The embedded mask register is used as a zero-mask.
*/
ZYDIS_MASK_MODE_ZEROING,
/**
* The embedded mask register is used as a control-mask (element selector).
*/
ZYDIS_MASK_MODE_CONTROL,
/**
* The embedded mask register is used as a zeroing control-mask (element selector).
*/
ZYDIS_MASK_MODE_CONTROL_ZEROING,
/**
* Maximum value of this enum.
*/
ZYDIS_MASK_MODE_MAX_VALUE = ZYDIS_MASK_MODE_CONTROL_ZEROING,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MASK_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MASK_MODE_MAX_VALUE)
} ZydisMaskMode;
/* ---------------------------------------------------------------------------------------------- */
/* AVX broadcast-mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisBroadcastMode` enum.
*/
typedef enum ZydisBroadcastMode_
{
ZYDIS_BROADCAST_MODE_INVALID,
ZYDIS_BROADCAST_MODE_1_TO_2,
ZYDIS_BROADCAST_MODE_1_TO_4,
ZYDIS_BROADCAST_MODE_1_TO_8,
ZYDIS_BROADCAST_MODE_1_TO_16,
ZYDIS_BROADCAST_MODE_1_TO_32,
ZYDIS_BROADCAST_MODE_1_TO_64,
ZYDIS_BROADCAST_MODE_2_TO_4,
ZYDIS_BROADCAST_MODE_2_TO_8,
ZYDIS_BROADCAST_MODE_2_TO_16,
ZYDIS_BROADCAST_MODE_4_TO_8,
ZYDIS_BROADCAST_MODE_4_TO_16,
ZYDIS_BROADCAST_MODE_8_TO_16,
/**
* Maximum value of this enum.
*/
ZYDIS_BROADCAST_MODE_MAX_VALUE = ZYDIS_BROADCAST_MODE_8_TO_16,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_BROADCAST_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_BROADCAST_MODE_MAX_VALUE)
} ZydisBroadcastMode;
/* ---------------------------------------------------------------------------------------------- */
/* AVX rounding-mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisRoundingMode` enum.
*/
typedef enum ZydisRoundingMode_
{
ZYDIS_ROUNDING_MODE_INVALID,
/**
* Round to nearest.
*/
ZYDIS_ROUNDING_MODE_RN,
/**
* Round down.
*/
ZYDIS_ROUNDING_MODE_RD,
/**
* Round up.
*/
ZYDIS_ROUNDING_MODE_RU,
/**
* Round towards zero.
*/
ZYDIS_ROUNDING_MODE_RZ,
/**
* Maximum value of this enum.
*/
ZYDIS_ROUNDING_MODE_MAX_VALUE = ZYDIS_ROUNDING_MODE_RZ,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_ROUNDING_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_ROUNDING_MODE_MAX_VALUE)
} ZydisRoundingMode;
/* ---------------------------------------------------------------------------------------------- */
/* KNC swizzle-mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisSwizzleMode` enum.
*/
typedef enum ZydisSwizzleMode_
{
ZYDIS_SWIZZLE_MODE_INVALID,
ZYDIS_SWIZZLE_MODE_DCBA,
ZYDIS_SWIZZLE_MODE_CDAB,
ZYDIS_SWIZZLE_MODE_BADC,
ZYDIS_SWIZZLE_MODE_DACB,
ZYDIS_SWIZZLE_MODE_AAAA,
ZYDIS_SWIZZLE_MODE_BBBB,
ZYDIS_SWIZZLE_MODE_CCCC,
ZYDIS_SWIZZLE_MODE_DDDD,
/**
* Maximum value of this enum.
*/
ZYDIS_SWIZZLE_MODE_MAX_VALUE = ZYDIS_SWIZZLE_MODE_DDDD,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_SWIZZLE_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_SWIZZLE_MODE_MAX_VALUE)
} ZydisSwizzleMode;
/* ---------------------------------------------------------------------------------------------- */
/* KNC conversion-mode */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisConversionMode` enum.
*/
typedef enum ZydisConversionMode_
{
ZYDIS_CONVERSION_MODE_INVALID,
ZYDIS_CONVERSION_MODE_FLOAT16,
ZYDIS_CONVERSION_MODE_SINT8,
ZYDIS_CONVERSION_MODE_UINT8,
ZYDIS_CONVERSION_MODE_SINT16,
ZYDIS_CONVERSION_MODE_UINT16,
/**
* Maximum value of this enum.
*/
ZYDIS_CONVERSION_MODE_MAX_VALUE = ZYDIS_CONVERSION_MODE_UINT16,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_CONVERSION_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_CONVERSION_MODE_MAX_VALUE)
} ZydisConversionMode;
/* ---------------------------------------------------------------------------------------------- */
/* Legacy prefix type */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisPrefixType` enum.
*/
typedef enum ZydisPrefixType_
{
/**
* The prefix is ignored by the instruction.
*
* This applies to all prefixes that are not accepted by the instruction in general or the
* ones that are overwritten by a prefix of the same group closer to the instruction opcode.
*/
ZYDIS_PREFIX_TYPE_IGNORED,
/**
* The prefix is effectively used by the instruction.
*/
ZYDIS_PREFIX_TYPE_EFFECTIVE,
/**
* The prefix is used as a mandatory prefix.
*
* A mandatory prefix is interpreted as an opcode extension and has no further effect on the
* instruction.
*/
ZYDIS_PREFIX_TYPE_MANDATORY,
/**
* Maximum value of this enum.
*/
ZYDIS_PREFIX_TYPE_MAX_VALUE = ZYDIS_PREFIX_TYPE_MANDATORY,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_PREFIX_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_PREFIX_TYPE_MAX_VALUE)
} ZydisPrefixType;
// TODO: Check effective for 66/67 prefixes (currently defaults to EFFECTIVE)
/* ---------------------------------------------------------------------------------------------- */
/* Decoded instruction */
/* ---------------------------------------------------------------------------------------------- */
/**
* Detailed info about the `REX` prefix.
*/
typedef struct ZydisDecodedInstructionRawRex_
{
/**
* 64-bit operand-size promotion.
*/
ZyanU8 W;
/**
* Extension of the `ModRM.reg` field.
*/
ZyanU8 R;
/**
* Extension of the `SIB.index` field.
*/
ZyanU8 X;
/**
* Extension of the `ModRM.rm`, `SIB.base`, or `opcode.reg` field.
*/
ZyanU8 B;
/**
* The offset of the effective `REX` byte, relative to the beginning of the
* instruction, in bytes.
*
* This offset always points to the "effective" `REX` prefix (the one closest to the
* instruction opcode), if multiple `REX` prefixes are present.
*
* Note that the `REX` byte can be the first byte of the instruction, which would lead
* to an offset of `0`. Please refer to the instruction attributes to check for the
* presence of the `REX` prefix.
*/
ZyanU8 offset;
} ZydisDecodedInstructionRawRex;
/**
* Detailed info about the `XOP` prefix.
*/
typedef struct ZydisDecodedInstructionRawXop_
{
/**
* Extension of the `ModRM.reg` field (inverted).
*/
ZyanU8 R;
/**
* Extension of the `SIB.index` field (inverted).
*/
ZyanU8 X;
/**
* Extension of the `ModRM.rm`, `SIB.base`, or `opcode.reg` field (inverted).
*/
ZyanU8 B;
/**
* Opcode-map specifier.
*/
ZyanU8 m_mmmm;
/**
* 64-bit operand-size promotion or opcode-extension.
*/
ZyanU8 W;
/**
* `NDS`/`NDD` (non-destructive-source/destination) register
* specifier (inverted).
*/
ZyanU8 vvvv;
/**
* Vector-length specifier.
*/
ZyanU8 L;
/**
* Compressed legacy prefix.
*/
ZyanU8 pp;
/**
* The offset of the first xop byte, relative to the beginning of
* the instruction, in bytes.
*/
ZyanU8 offset;
} ZydisDecodedInstructionRawXop;
/**
* Detailed info about the `VEX` prefix.
*/
typedef struct ZydisDecodedInstructionRawVex_
{
/**
* Extension of the `ModRM.reg` field (inverted).
*/
ZyanU8 R;
/**
* Extension of the `SIB.index` field (inverted).
*/
ZyanU8 X;
/**
* Extension of the `ModRM.rm`, `SIB.base`, or `opcode.reg` field (inverted).
*/
ZyanU8 B;
/**
* Opcode-map specifier.
*/
ZyanU8 m_mmmm;
/**
* 64-bit operand-size promotion or opcode-extension.
*/
ZyanU8 W;
/**
* `NDS`/`NDD` (non-destructive-source/destination) register specifier
* (inverted).
*/
ZyanU8 vvvv;
/**
* Vector-length specifier.
*/
ZyanU8 L;
/**
* Compressed legacy prefix.
*/
ZyanU8 pp;
/**
* The offset of the first `VEX` byte, relative to the beginning of the instruction, in
* bytes.
*/
ZyanU8 offset;
/**
* The size of the `VEX` prefix, in bytes.
*/
ZyanU8 size;
} ZydisDecodedInstructionRawVex;
/**
* Detailed info about the `EVEX` prefix.
*/
typedef struct ZydisDecodedInstructionRawEvex
{
/**
* Extension of the `ModRM.reg` field (inverted).
*/
ZyanU8 R;
/**
* Extension of the `SIB.index/vidx` field (inverted).
*/
ZyanU8 X;
/**
* Extension of the `ModRM.rm` or `SIB.base` field (inverted).
*/
ZyanU8 B;
/**
* High-16 register specifier modifier (inverted).
*/
ZyanU8 R2;
/**
* Opcode-map specifier.
*/
ZyanU8 mmm;
/**
* 64-bit operand-size promotion or opcode-extension.
*/
ZyanU8 W;
/**
* `NDS`/`NDD` (non-destructive-source/destination) register specifier
* (inverted).
*/
ZyanU8 vvvv;
/**
* Compressed legacy prefix.
*/
ZyanU8 pp;
/**
* Zeroing/Merging.
*/
ZyanU8 z;
/**
* Vector-length specifier or rounding-control (most significant bit).
*/
ZyanU8 L2;
/**
* Vector-length specifier or rounding-control (least significant bit).
*/
ZyanU8 L;
/**
* Broadcast/RC/SAE context.
*/
ZyanU8 b;
/**
* High-16 `NDS`/`VIDX` register specifier.
*/
ZyanU8 V2;
/**
* Embedded opmask register specifier.
*/
ZyanU8 aaa;
/**
* The offset of the first evex byte, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} ZydisDecodedInstructionRawEvex;
/**
* Detailed info about the `MVEX` prefix.
*/
typedef struct ZydisDecodedInstructionRawMvex_
{
/**
* Extension of the `ModRM.reg` field (inverted).
*/
ZyanU8 R;
/**
* Extension of the `SIB.index/vidx` field (inverted).
*/
ZyanU8 X;
/**
* Extension of the `ModRM.rm` or `SIB.base` field (inverted).
*/
ZyanU8 B;
/**
* High-16 register specifier modifier (inverted).
*/
ZyanU8 R2;
/**
* Opcode-map specifier.
*/
ZyanU8 mmmm;
/**
* 64-bit operand-size promotion or opcode-extension.
*/
ZyanU8 W;
/**
* `NDS`/`NDD` (non-destructive-source/destination) register specifier
* (inverted).
*/
ZyanU8 vvvv;
/**
* Compressed legacy prefix.
*/
ZyanU8 pp;
/**
* Non-temporal/eviction hint.
*/
ZyanU8 E;
/**
* Swizzle/broadcast/up-convert/down-convert/static-rounding controls.
*/
ZyanU8 SSS;
/**
* High-16 `NDS`/`VIDX` register specifier.
*/
ZyanU8 V2;
/**
* Embedded opmask register specifier.
*/
ZyanU8 kkk;
/**
* The offset of the first mvex byte, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} ZydisDecodedInstructionRawMvex;
/**
* Extended info for `AVX` instructions.
*/
typedef struct ZydisDecodedInstructionAvx_
{
/**
* The `AVX` vector-length.
*/
ZyanU16 vector_length;
/**
* Info about the embedded writemask-register (`AVX-512` and `KNC` only).
*/
struct ZydisDecodedInstructionAvxMask_
{
/**
* The masking mode.
*/
ZydisMaskMode mode;
/**
* The mask register.
*/
ZydisRegister reg;
} mask;
/**
* Contains info about the `AVX` broadcast.
*/
struct ZydisDecodedInstructionAvxBroadcast_
{
/**
* Signals, if the broadcast is a static broadcast.
*
* This is the case for instructions with inbuilt broadcast functionality, which is
* always active and not controlled by the `EVEX/MVEX.RC` bits.
*/
ZyanBool is_static;
/**
* The `AVX` broadcast-mode.
*/
ZydisBroadcastMode mode;
} broadcast;
/**
* Contains info about the `AVX` rounding.
*/
struct ZydisDecodedInstructionAvxRounding_
{
/**
* The `AVX` rounding-mode.
*/
ZydisRoundingMode mode;
} rounding;
/**
* Contains info about the `AVX` register-swizzle (`KNC` only).
*/
struct ZydisDecodedInstructionAvxSwizzle_
{
/**
* The `AVX` register-swizzle mode.
*/
ZydisSwizzleMode mode;
} swizzle;
/**
* Contains info about the `AVX` data-conversion (`KNC` only).
*/
struct ZydisDecodedInstructionAvxConversion_
{
/**
* The `AVX` data-conversion mode.
*/
ZydisConversionMode mode;
} conversion;
/**
* Signals, if the `SAE` (suppress-all-exceptions) functionality is
* enabled for the instruction.
*/
ZyanBool has_sae;
/**
* Signals, if the instruction has a memory-eviction-hint (`KNC` only).
*/
ZyanBool has_eviction_hint;
// TODO: publish EVEX tuple-type and MVEX functionality
} ZydisDecodedInstructionAvx;
/**
* Instruction meta info.
*/
typedef struct ZydisDecodedInstructionMeta_
{
/**
* The instruction category.
*/
ZydisInstructionCategory category;
/**
* The ISA-set.
*/
ZydisISASet isa_set;
/**
* The ISA-set extension.
*/
ZydisISAExt isa_ext;
/**
* The branch type.
*/
ZydisBranchType branch_type;
/**
* The exception class.
*/
ZydisExceptionClass exception_class;
} ZydisDecodedInstructionMeta;
/**
* Detailed info about different instruction-parts like `ModRM`, `SIB` or
* encoding-prefixes.
*/
typedef struct ZydisDecodedInstructionRaw_
{
/**
* The number of legacy prefixes.
*/
ZyanU8 prefix_count;
/**
* Detailed info about the legacy prefixes (including `REX`).
*/
struct ZydisDecodedInstructionRawPrefixes_
{
/**
* The prefix type.
*/
ZydisPrefixType type;
/**
* The prefix byte.
*/
ZyanU8 value;
} prefixes[ZYDIS_MAX_INSTRUCTION_LENGTH];
/*
* Copy of the `encoding` field.
*
* This is here to allow the Rust bindings to treat the following union as an `enum`,
* sparing us a lot of unsafe code. Prefer using the regular `encoding` field in C/C++ code.
*/
ZydisInstructionEncoding encoding2;
/*
* Union for things from various mutually exclusive encodings.
*/
union
{
ZydisDecodedInstructionRawRex rex;
ZydisDecodedInstructionRawXop xop;
ZydisDecodedInstructionRawVex vex;
ZydisDecodedInstructionRawEvex evex;
ZydisDecodedInstructionRawMvex mvex;
};
/**
* Detailed info about the `ModRM` byte.
*/
struct ZydisDecodedInstructionModRm_
{
/**
* The addressing mode.
*/
ZyanU8 mod;
/**
* Register specifier or opcode-extension.
*/
ZyanU8 reg;
/**
* Register specifier or opcode-extension.
*/
ZyanU8 rm;
/**
* The offset of the `ModRM` byte, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} modrm;
/**
* Detailed info about the `SIB` byte.
*/
struct ZydisDecodedInstructionRawSib_
{
/**
* The scale factor.
*/
ZyanU8 scale;
/**
* The index-register specifier.
*/
ZyanU8 index;
/**
* The base-register specifier.
*/
ZyanU8 base;
/**
* The offset of the `SIB` byte, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} sib;
/**
* Detailed info about displacement-bytes.
*/
struct ZydisDecodedInstructionRawDisp_
{
/**
* The displacement value
*/
ZyanI64 value;
/**
* The physical displacement size, in bits.
*/
ZyanU8 size;
// TODO: publish cd8 scale
/**
* The offset of the displacement data, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} disp;
/**
* Detailed info about immediate-bytes.
*/
struct ZydisDecodedInstructionRawImm_
{
/**
* Signals, if the immediate value is signed.
*/
ZyanBool is_signed;
/**
* Signals, if the immediate value contains a relative offset. You can use
* `ZydisCalcAbsoluteAddress` to determine the absolute address value.
*/
ZyanBool is_relative;
/**
* The immediate value.
*/
union ZydisDecodedInstructionRawImmValue_
{
ZyanU64 u;
ZyanI64 s;
} value;
/**
* The physical immediate size, in bits.
*/
ZyanU8 size;
/**
* The offset of the immediate data, relative to the beginning of the
* instruction, in bytes.
*/
ZyanU8 offset;
} imm[2];
} ZydisDecodedInstructionRaw;
/**
* Information about a decoded instruction.
*/
typedef struct ZydisDecodedInstruction_
{
/**
* The machine mode used to decode this instruction.
*/
ZydisMachineMode machine_mode;
/**
* The instruction-mnemonic.
*/
ZydisMnemonic mnemonic;
/**
* The length of the decoded instruction.
*/
ZyanU8 length;
/**
* The instruction-encoding (`LEGACY`, `3DNOW`, `VEX`, `EVEX`, `XOP`).
*/
ZydisInstructionEncoding encoding;
/**
* The opcode-map.
*/
ZydisOpcodeMap opcode_map;
/**
* The instruction-opcode.
*/
ZyanU8 opcode;
/**
* The stack width.
*/
ZyanU8 stack_width;
/**
* The effective operand width.
*/
ZyanU8 operand_width;
/**
* The effective address width.
*/
ZyanU8 address_width;
/**
* The number of instruction-operands.
*
* Explicit and implicit operands are guaranteed to be in the front and ordered as they are
* printed by the formatter in `Intel` mode. No assumptions can be made about the order of
* hidden operands, except that they always located behind the explicit and implicit operands.
*/
ZyanU8 operand_count;
/**
* The number of explicit (visible) instruction-operands.
*
* Explicit and implicit operands are guaranteed to be in the front and ordered as they are
* printed by the formatter in `Intel` mode.
*/
ZyanU8 operand_count_visible;
/**
* See @ref instruction_attributes.
*/
ZydisInstructionAttributes attributes;
/**
* Information about CPU flags accessed by the instruction.
*
* The bits in the masks correspond to the actual bits in the `FLAGS/EFLAGS/RFLAGS`
* register. See @ref decoder_cpu_flags.
*/
const ZydisAccessedFlags* cpu_flags;
/**
* Information about FPU flags accessed by the instruction.
*
* See @ref decoder_fpu_flags.
*/
const ZydisAccessedFlags* fpu_flags;
/**
* Extended info for `AVX` instructions.
*/
ZydisDecodedInstructionAvx avx;
/**
* Meta info.
*/
ZydisDecodedInstructionMeta meta;
/**
* Detailed info about different instruction-parts like `ModRM`, `SIB` or
* encoding-prefixes.
*/
ZydisDecodedInstructionRaw raw;
} ZydisDecodedInstruction;
/* ---------------------------------------------------------------------------------------------- */
/* Decoder context */
/* ---------------------------------------------------------------------------------------------- */
/**
* The decoder context is used to preserve some internal state between subsequent decode
* operations for THE SAME instruction.
*
* The context is initialized by @c ZydisDecoderDecodeInstruction and required by e.g.
* @c ZydisDecoderDecodeOperands.
*
* All fields in this struct should be considered as "private". Any changes may lead to unexpected
* behavior.
*
* This struct is neither ABI nor API stable!
*/
typedef struct ZydisDecoderContext_
{
/**
* A pointer to the internal instruction definition.
*/
const void* definition;
/**
* Contains the effective operand-size index.
*
* 0 = 16 bit, 1 = 32 bit, 2 = 64 bit
*/
ZyanU8 eosz_index;
/**
* Contains the effective address-size index.
*
* 0 = 16 bit, 1 = 32 bit, 2 = 64 bit
*/
ZyanU8 easz_index;
/**
* Contains some cached REX/XOP/VEX/EVEX/MVEX values to provide uniform access.
*/
struct
{
ZyanU8 W;
ZyanU8 R;
ZyanU8 X;
ZyanU8 B;
ZyanU8 L;
ZyanU8 LL;
ZyanU8 R2;
ZyanU8 V2;
ZyanU8 vvvv;
ZyanU8 mask;
} vector_unified;
/**
* Information about encoded operand registers.
*/
struct
{
/**
* Signals if the `modrm.mod == 3` or `reg` form is forced for the instruction.
*/
ZyanBool is_mod_reg;
/**
* The final register id for the `reg` encoded register.
*/
ZyanU8 id_reg;
/**
* The final register id for the `rm` encoded register.
*
* This value is only set, if a register is encoded in `modrm.rm`.
*/
ZyanU8 id_rm;
/**
* The final register id for the `ndsndd` (`.vvvv`) encoded register.
*/
ZyanU8 id_ndsndd;
/**
* The final register id for the base register.
*
* This value is only set, if a memory operand is encoded in `modrm.rm`.
*/
ZyanU8 id_base;
/**
* The final register id for the index register.
*
* This value is only set, if a memory operand is encoded in `modrm.rm` and the `SIB` byte
* is present.
*/
ZyanU8 id_index;
} reg_info;
/**
* Internal EVEX-specific information.
*/
struct
{
/**
* The EVEX tuple-type.
*/
ZyanU8 tuple_type;
/**
* The EVEX element-size.
*/
ZyanU8 element_size;
} evex;
/**
* Internal MVEX-specific information.
*/
struct
{
/**
* The MVEX functionality.
*/
ZyanU8 functionality;
} mvex;
/**
* The scale factor for EVEX/MVEX compressed 8-bit displacement values.
*/
ZyanU8 cd8_scale; // TODO: Could make sense to expose this in the ZydisDecodedInstruction
} ZydisDecoderContext;
/* ---------------------------------------------------------------------------------------------- */
/* ============================================================================================== */
#ifdef __cplusplus
}
#endif
#endif /* ZYDIS_INSTRUCTIONINFO_H */