dynarmic/include/Zydis/Internal/SharedData.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

979 lines
33 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.
***************************************************************************************************/
#ifndef ZYDIS_INTERNAL_SHAREDDATA_H
#define ZYDIS_INTERNAL_SHAREDDATA_H
#include <Zycore/Defines.h>
#include <Zydis/Mnemonic.h>
#include <Zydis/Register.h>
#include <Zydis/SharedTypes.h>
#include <Zydis/DecoderTypes.h>
#ifdef __cplusplus
extern "C" {
#endif
/* ============================================================================================== */
/* Enums and types */
/* ============================================================================================== */
// MSVC does not like types other than (un-)signed int for bit-fields
#ifdef ZYAN_MSVC
# pragma warning(push)
# pragma warning(disable:4214)
#endif
#pragma pack(push, 1)
/* ---------------------------------------------------------------------------------------------- */
/* Operand definition */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisSemanticOperandType` enum.
*/
typedef enum ZydisSemanticOperandType_
{
ZYDIS_SEMANTIC_OPTYPE_UNUSED,
ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_REG,
ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_MEM,
ZYDIS_SEMANTIC_OPTYPE_IMPLICIT_IMM1,
ZYDIS_SEMANTIC_OPTYPE_GPR8,
ZYDIS_SEMANTIC_OPTYPE_GPR16,
ZYDIS_SEMANTIC_OPTYPE_GPR32,
ZYDIS_SEMANTIC_OPTYPE_GPR64,
ZYDIS_SEMANTIC_OPTYPE_GPR16_32_64,
ZYDIS_SEMANTIC_OPTYPE_GPR32_32_64,
ZYDIS_SEMANTIC_OPTYPE_GPR16_32_32,
ZYDIS_SEMANTIC_OPTYPE_GPR_ASZ,
ZYDIS_SEMANTIC_OPTYPE_FPR,
ZYDIS_SEMANTIC_OPTYPE_MMX,
ZYDIS_SEMANTIC_OPTYPE_XMM,
ZYDIS_SEMANTIC_OPTYPE_YMM,
ZYDIS_SEMANTIC_OPTYPE_ZMM,
ZYDIS_SEMANTIC_OPTYPE_TMM,
ZYDIS_SEMANTIC_OPTYPE_BND,
ZYDIS_SEMANTIC_OPTYPE_SREG,
ZYDIS_SEMANTIC_OPTYPE_CR,
ZYDIS_SEMANTIC_OPTYPE_DR,
ZYDIS_SEMANTIC_OPTYPE_MASK,
ZYDIS_SEMANTIC_OPTYPE_MEM,
ZYDIS_SEMANTIC_OPTYPE_MEM_VSIBX,
ZYDIS_SEMANTIC_OPTYPE_MEM_VSIBY,
ZYDIS_SEMANTIC_OPTYPE_MEM_VSIBZ,
ZYDIS_SEMANTIC_OPTYPE_IMM,
ZYDIS_SEMANTIC_OPTYPE_REL,
ZYDIS_SEMANTIC_OPTYPE_PTR,
ZYDIS_SEMANTIC_OPTYPE_AGEN,
ZYDIS_SEMANTIC_OPTYPE_MOFFS,
ZYDIS_SEMANTIC_OPTYPE_MIB,
/**
* Maximum value of this enum.
*/
ZYDIS_SEMANTIC_OPTYPE_MAX_VALUE = ZYDIS_SEMANTIC_OPTYPE_MIB,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_SEMANTIC_OPTYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_SEMANTIC_OPTYPE_MAX_VALUE)
} ZydisSemanticOperandType;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisInternalElementType` enum.
*/
typedef enum ZydisInternalElementType_
{
ZYDIS_IELEMENT_TYPE_INVALID,
ZYDIS_IELEMENT_TYPE_VARIABLE,
ZYDIS_IELEMENT_TYPE_STRUCT,
ZYDIS_IELEMENT_TYPE_INT,
ZYDIS_IELEMENT_TYPE_UINT,
ZYDIS_IELEMENT_TYPE_INT1,
ZYDIS_IELEMENT_TYPE_INT8,
ZYDIS_IELEMENT_TYPE_INT16,
ZYDIS_IELEMENT_TYPE_INT32,
ZYDIS_IELEMENT_TYPE_INT64,
ZYDIS_IELEMENT_TYPE_UINT8,
ZYDIS_IELEMENT_TYPE_UINT16,
ZYDIS_IELEMENT_TYPE_UINT32,
ZYDIS_IELEMENT_TYPE_UINT64,
ZYDIS_IELEMENT_TYPE_UINT128,
ZYDIS_IELEMENT_TYPE_UINT256,
ZYDIS_IELEMENT_TYPE_FLOAT16,
ZYDIS_IELEMENT_TYPE_FLOAT16X2,
ZYDIS_IELEMENT_TYPE_FLOAT32,
ZYDIS_IELEMENT_TYPE_FLOAT64,
ZYDIS_IELEMENT_TYPE_FLOAT80,
ZYDIS_IELEMENT_TYPE_BCD80,
ZYDIS_IELEMENT_TYPE_CC3,
ZYDIS_IELEMENT_TYPE_CC5,
/**
* Maximum value of this enum.
*/
ZYDIS_IELEMENT_TYPE_MAX_VALUE = ZYDIS_IELEMENT_TYPE_CC5,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_IELEMENT_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_IELEMENT_TYPE_MAX_VALUE)
} ZydisInternalElementType;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisImplicitRegisterType` enum.
*/
typedef enum ZydisImplicitRegisterType_
{
// TODO: Rename OSZ|ASZ|SSZ_
ZYDIS_IMPLREG_TYPE_STATIC,
ZYDIS_IMPLREG_TYPE_GPR_OSZ,
ZYDIS_IMPLREG_TYPE_GPR_ASZ,
ZYDIS_IMPLREG_TYPE_IP_ASZ,
ZYDIS_IMPLREG_TYPE_IP_SSZ,
ZYDIS_IMPLREG_TYPE_GPR_SSZ,
ZYDIS_IMPLREG_TYPE_FLAGS_SSZ,
/**
* Maximum value of this enum.
*/
ZYDIS_IMPLREG_TYPE_MAX_VALUE = ZYDIS_IMPLREG_TYPE_FLAGS_SSZ,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_IMPLREG_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_IMPLREG_TYPE_MAX_VALUE)
} ZydisImplicitRegisterType;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisImplicitMemBase` enum.
*/
typedef enum ZydisImplicitMemBase_
{
// TODO: Rename OSZ|ASZ|SSZ_
ZYDIS_IMPLMEM_BASE_AGPR_REG,
ZYDIS_IMPLMEM_BASE_AGPR_RM,
ZYDIS_IMPLMEM_BASE_AAX,
ZYDIS_IMPLMEM_BASE_ADX,
ZYDIS_IMPLMEM_BASE_ABX,
ZYDIS_IMPLMEM_BASE_ASI,
ZYDIS_IMPLMEM_BASE_ADI,
ZYDIS_IMPLMEM_BASE_SSP,
ZYDIS_IMPLMEM_BASE_SBP,
/**
* Maximum value of this enum.
*/
ZYDIS_IMPLMEM_BASE_MAX_VALUE = ZYDIS_IMPLMEM_BASE_SBP,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_IMPLMEM_BASE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_IMPLMEM_BASE_MAX_VALUE)
} ZydisImplicitMemBase;
/* ---------------------------------------------------------------------------------------------- */
// MSVC does not correctly execute the `pragma pack(1)` compiler-directive, if we use the correct
// enum types
ZYAN_STATIC_ASSERT(ZYDIS_SEMANTIC_OPTYPE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_OPERAND_VISIBILITY_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_OPERAND_ACTION_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_IELEMENT_TYPE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_OPERAND_ENCODING_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_IMPLREG_TYPE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_REGISTER_REQUIRED_BITS <= 16);
ZYAN_STATIC_ASSERT(ZYDIS_IMPLMEM_BASE_REQUIRED_BITS <= 8);
/**
* Defines the `ZydisOperandDefinition` struct.
*/
typedef struct ZydisOperandDefinition_
{
ZyanU8 type ZYAN_BITFIELD(ZYDIS_SEMANTIC_OPTYPE_REQUIRED_BITS);
ZyanU8 visibility ZYAN_BITFIELD(ZYDIS_OPERAND_VISIBILITY_REQUIRED_BITS);
ZyanU8 actions ZYAN_BITFIELD(ZYDIS_OPERAND_ACTION_REQUIRED_BITS);
ZyanU16 size[3];
ZyanU8 element_type ZYAN_BITFIELD(ZYDIS_IELEMENT_TYPE_REQUIRED_BITS);
union
{
ZyanU8 encoding ZYAN_BITFIELD(ZYDIS_OPERAND_ENCODING_REQUIRED_BITS);
struct
{
ZyanU8 type ZYAN_BITFIELD(ZYDIS_IMPLREG_TYPE_REQUIRED_BITS);
union
{
ZyanU16 reg ZYAN_BITFIELD(ZYDIS_REGISTER_REQUIRED_BITS);
ZyanU8 id ZYAN_BITFIELD(6);
} reg;
} reg;
struct
{
ZyanU8 seg ZYAN_BITFIELD(3);
ZyanU8 base ZYAN_BITFIELD(ZYDIS_IMPLMEM_BASE_REQUIRED_BITS);
} mem;
} op;
ZyanBool is_multisource4 ZYAN_BITFIELD(1);
ZyanBool ignore_seg_override ZYAN_BITFIELD(1);
} ZydisOperandDefinition;
/* ---------------------------------------------------------------------------------------------- */
/* Instruction definition */
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisReadWriteAction` enum.
*/
typedef enum ZydisReadWriteAction_
{
ZYDIS_RW_ACTION_NONE,
ZYDIS_RW_ACTION_READ,
ZYDIS_RW_ACTION_WRITE,
ZYDIS_RW_ACTION_READWRITE,
/**
* Maximum value of this enum.
*/
ZYDIS_RW_ACTION_MAX_VALUE = ZYDIS_RW_ACTION_READWRITE,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_RW_ACTION_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_RW_ACTION_MAX_VALUE)
} ZydisReadWriteAction;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisInternalVectorLength` enum.
*/
typedef enum ZydisInternalVectorLength_
{
ZYDIS_IVECTOR_LENGTH_DEFAULT,
ZYDIS_IVECTOR_LENGTH_FIXED_128,
ZYDIS_IVECTOR_LENGTH_FIXED_256,
ZYDIS_IVECTOR_LENGTH_FIXED_512,
/**
* Maximum value of this enum.
*/
ZYDIS_IVECTOR_LENGTH_MAX_VALUE = ZYDIS_IVECTOR_LENGTH_FIXED_512,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_IVECTOR_LENGTH_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_IVECTOR_LENGTH_MAX_VALUE)
} ZydisInternalVectorLength;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisInternalElementSize` enum.
*/
typedef enum ZydisInternalElementSize_
{
ZYDIS_IELEMENT_SIZE_INVALID,
ZYDIS_IELEMENT_SIZE_8,
ZYDIS_IELEMENT_SIZE_16,
ZYDIS_IELEMENT_SIZE_32,
ZYDIS_IELEMENT_SIZE_64,
ZYDIS_IELEMENT_SIZE_128,
/**
* Maximum value of this enum.
*/
ZYDIS_IELEMENT_SIZE_MAX_VALUE = ZYDIS_IELEMENT_SIZE_128,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_IELEMENT_SIZE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_IELEMENT_SIZE_MAX_VALUE)
} ZydisInternalElementSize;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisEVEXFunctionality` enum.
*/
typedef enum ZydisEVEXFunctionality_
{
ZYDIS_EVEX_FUNC_INVALID,
/**
* `EVEX.b` enables broadcast functionality.
*/
ZYDIS_EVEX_FUNC_BC,
/**
* `EVEX.b` enables embedded-rounding functionality.
*/
ZYDIS_EVEX_FUNC_RC,
/**
* `EVEX.b` enables sae functionality.
*/
ZYDIS_EVEX_FUNC_SAE,
/**
* Maximum value of this enum.
*/
ZYDIS_EVEX_FUNC_MAX_VALUE = ZYDIS_EVEX_FUNC_SAE,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_EVEX_FUNC_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_EVEX_FUNC_MAX_VALUE)
} ZydisEVEXFunctionality;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisEVEXTupleType` enum.
*/
typedef enum ZydisEVEXTupleType_
{
ZYDIS_TUPLETYPE_INVALID,
/**
* Full Vector
*/
ZYDIS_TUPLETYPE_FV,
/**
* Half Vector
*/
ZYDIS_TUPLETYPE_HV,
/**
* Full Vector Mem
*/
ZYDIS_TUPLETYPE_FVM,
/**
* Tuple1 Scalar
*/
ZYDIS_TUPLETYPE_T1S,
/**
* Tuple1 Fixed
*/
ZYDIS_TUPLETYPE_T1F,
/**
* Tuple1 4x32
*/
ZYDIS_TUPLETYPE_T1_4X,
/**
* Gather / Scatter
*/
ZYDIS_TUPLETYPE_GSCAT,
/**
* Tuple2
*/
ZYDIS_TUPLETYPE_T2,
/**
* Tuple4
*/
ZYDIS_TUPLETYPE_T4,
/**
* Tuple8
*/
ZYDIS_TUPLETYPE_T8,
/**
* Half Mem
*/
ZYDIS_TUPLETYPE_HVM,
/**
* QuarterMem
*/
ZYDIS_TUPLETYPE_QVM,
/**
* OctMem
*/
ZYDIS_TUPLETYPE_OVM,
/**
* Mem128
*/
ZYDIS_TUPLETYPE_M128,
/**
* MOVDDUP
*/
ZYDIS_TUPLETYPE_DUP,
/**
* Quarter of the vector-length.
*/
ZYDIS_TUPLETYPE_QUARTER,
/**
* Maximum value of this enum.
*/
ZYDIS_TUPLETYPE_MAX_VALUE = ZYDIS_TUPLETYPE_QUARTER,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_TUPLETYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_TUPLETYPE_MAX_VALUE)
} ZydisEVEXTupleType;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMVEXFunctionality` enum.
*/
typedef enum ZydisMVEXFunctionality_
{
/**
* The `MVEX.SSS` value is ignored.
*/
ZYDIS_MVEX_FUNC_IGNORED,
/**
* `MVEX.SSS` must be `000b`.
*/
ZYDIS_MVEX_FUNC_INVALID,
/**
* `MVEX.SSS` controls embedded-rounding functionality.
*/
ZYDIS_MVEX_FUNC_RC,
/**
* `MVEX.SSS` controls sae functionality.
*/
ZYDIS_MVEX_FUNC_SAE,
/**
* No special operation (32bit float elements).
*/
ZYDIS_MVEX_FUNC_F_32,
/**
* No special operation (32bit uint elements).
*/
ZYDIS_MVEX_FUNC_I_32,
/**
* No special operation (64bit float elements).
*/
ZYDIS_MVEX_FUNC_F_64,
/**
* No special operation (64bit uint elements).
*/
ZYDIS_MVEX_FUNC_I_64,
/**
* Sf32(reg) or Si32(reg).
*/
ZYDIS_MVEX_FUNC_SWIZZLE_32,
/**
* Sf64(reg) or Si64(reg).
*/
ZYDIS_MVEX_FUNC_SWIZZLE_64,
/**
* Sf32(mem).
*/
ZYDIS_MVEX_FUNC_SF_32,
/**
* Sf32(mem) broadcast only.
*/
ZYDIS_MVEX_FUNC_SF_32_BCST,
/**
* Sf32(mem) broadcast 4to16 only.
*/
ZYDIS_MVEX_FUNC_SF_32_BCST_4TO16,
/**
* Sf64(mem).
*/
ZYDIS_MVEX_FUNC_SF_64,
/**
* Si32(mem).
*/
ZYDIS_MVEX_FUNC_SI_32,
/**
* Si32(mem) broadcast only.
*/
ZYDIS_MVEX_FUNC_SI_32_BCST,
/**
* Si32(mem) broadcast 4to16 only.
*/
ZYDIS_MVEX_FUNC_SI_32_BCST_4TO16,
/**
* Si64(mem).
*/
ZYDIS_MVEX_FUNC_SI_64,
/**
* Uf32.
*/
ZYDIS_MVEX_FUNC_UF_32,
/**
* Uf64.
*/
ZYDIS_MVEX_FUNC_UF_64,
/**
* Ui32.
*/
ZYDIS_MVEX_FUNC_UI_32,
/**
* Ui64.
*/
ZYDIS_MVEX_FUNC_UI_64,
/**
* Df32.
*/
ZYDIS_MVEX_FUNC_DF_32,
/**
* Df64.
*/
ZYDIS_MVEX_FUNC_DF_64,
/**
* Di32.
*/
ZYDIS_MVEX_FUNC_DI_32,
/**
* Di64.
*/
ZYDIS_MVEX_FUNC_DI_64,
/**
* Maximum value of this enum.
*/
ZYDIS_MVEX_FUNC_MAX_VALUE = ZYDIS_MVEX_FUNC_DI_64,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MVEX_FUNC_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MVEX_FUNC_MAX_VALUE)
} ZydisMVEXFunctionality;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisVEXStaticBroadcast` enum.
*/
typedef enum ZydisVEXStaticBroadcast
{
ZYDIS_VEX_STATIC_BROADCAST_NONE,
ZYDIS_VEX_STATIC_BROADCAST_1_TO_2,
ZYDIS_VEX_STATIC_BROADCAST_1_TO_4,
ZYDIS_VEX_STATIC_BROADCAST_1_TO_8,
ZYDIS_VEX_STATIC_BROADCAST_1_TO_16,
ZYDIS_VEX_STATIC_BROADCAST_1_TO_32,
ZYDIS_VEX_STATIC_BROADCAST_2_TO_4,
/**
* Maximum value of this enum.
*/
ZYDIS_VEX_STATIC_BROADCAST_MAX_VALUE = ZYDIS_VEX_STATIC_BROADCAST_2_TO_4,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_VEX_STATIC_BROADCAST_REQUIRED_BITS =
ZYAN_BITS_TO_REPRESENT(ZYDIS_VEX_STATIC_BROADCAST_MAX_VALUE)
} ZydisVEXStaticBroadcast;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisEVEXStaticBroadcast` enum.
*/
typedef enum ZydisEVEXStaticBroadcast_
{
ZYDIS_EVEX_STATIC_BROADCAST_NONE,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_2,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_4,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_8,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_16,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_32,
ZYDIS_EVEX_STATIC_BROADCAST_1_TO_64,
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_4,
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_8,
ZYDIS_EVEX_STATIC_BROADCAST_2_TO_16,
ZYDIS_EVEX_STATIC_BROADCAST_4_TO_8,
ZYDIS_EVEX_STATIC_BROADCAST_4_TO_16,
ZYDIS_EVEX_STATIC_BROADCAST_8_TO_16,
/**
* Maximum value of this enum.
*/
ZYDIS_EVEX_STATIC_BROADCAST_MAX_VALUE = ZYDIS_EVEX_STATIC_BROADCAST_8_TO_16,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_EVEX_STATIC_BROADCAST_REQUIRED_BITS =
ZYAN_BITS_TO_REPRESENT(ZYDIS_EVEX_STATIC_BROADCAST_MAX_VALUE)
} ZydisEVEXStaticBroadcast;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMVEXStaticBroadcast` enum.
*/
typedef enum ZydisMVEXStaticBroadcast_
{
ZYDIS_MVEX_STATIC_BROADCAST_NONE,
ZYDIS_MVEX_STATIC_BROADCAST_1_TO_8,
ZYDIS_MVEX_STATIC_BROADCAST_1_TO_16,
ZYDIS_MVEX_STATIC_BROADCAST_4_TO_8,
ZYDIS_MVEX_STATIC_BROADCAST_4_TO_16,
/**
* Maximum value of this enum.
*/
ZYDIS_MVEX_STATIC_BROADCAST_MAX_VALUE = ZYDIS_MVEX_STATIC_BROADCAST_4_TO_16,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MVEX_STATIC_BROADCAST_REQUIRED_BITS =
ZYAN_BITS_TO_REPRESENT(ZYDIS_MVEX_STATIC_BROADCAST_MAX_VALUE)
} ZydisMVEXStaticBroadcast;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMaskPolicy` enum.
*/
typedef enum ZydisMaskPolicy_
{
ZYDIS_MASK_POLICY_INVALID,
/**
* The instruction accepts mask-registers other than the default-mask (K0), but
* does not require them.
*/
ZYDIS_MASK_POLICY_ALLOWED,
/**
* The instruction requires a mask-register other than the default-mask (K0).
*/
ZYDIS_MASK_POLICY_REQUIRED,
/**
* The instruction does not allow a mask-register other than the default-mask (K0).
*/
ZYDIS_MASK_POLICY_FORBIDDEN,
/**
* Maximum value of this enum.
*/
ZYDIS_MASK_POLICY_MAX_VALUE = ZYDIS_MASK_POLICY_FORBIDDEN,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MASK_POLICY_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MASK_POLICY_MAX_VALUE)
} ZydisMaskPolicy;
/* ---------------------------------------------------------------------------------------------- */
/**
* Defines the `ZydisMaskOverride` enum.
*/
typedef enum ZydisMaskOverride_
{
ZYDIS_MASK_OVERRIDE_DEFAULT,
ZYDIS_MASK_OVERRIDE_ZEROING,
ZYDIS_MASK_OVERRIDE_CONTROL,
/**
* Maximum value of this enum.
*/
ZYDIS_MASK_OVERRIDE_MAX_VALUE = ZYDIS_MASK_OVERRIDE_CONTROL,
/**
* The minimum number of bits required to represent all values of this enum.
*/
ZYDIS_MASK_OVERRIDE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MASK_OVERRIDE_MAX_VALUE)
} ZydisMaskOverride;
/* ---------------------------------------------------------------------------------------------- */
#define ZYDIS_OPDEF_REQUIRED_BITS \
ZYAN_MAX(ZYDIS_REGKIND_REQUIRED_BITS, ZYDIS_MEMOP_TYPE_REQUIRED_BITS + 1) + 1
#define ZYDIS_OPDEF_GET_REG(operand_definition) \
((operand_definition) & ((1 << ZYDIS_REGKIND_REQUIRED_BITS ) - 1))
#define ZYDIS_OPDEF_GET_MEM(operand_definition) \
((operand_definition) & ((1 << ZYDIS_MEMOP_TYPE_REQUIRED_BITS) - 1))
#define ZYDIS_OPDEF_GET_REG_HIGH_BIT(operand_definition) \
(((operand_definition) >> ZYDIS_REGKIND_REQUIRED_BITS ) & 0x01)
#define ZYDIS_OPDEF_GET_MEM_HIGH_BIT(operand_definition) \
(((operand_definition) >> ZYDIS_MEMOP_TYPE_REQUIRED_BITS) & 0x01)
// MSVC does not correctly execute the `pragma pack(1)` compiler-directive, if we use the correct
// enum types
ZYAN_STATIC_ASSERT(ZYDIS_MNEMONIC_REQUIRED_BITS <= 16);
ZYAN_STATIC_ASSERT(ZYDIS_CATEGORY_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_ISA_SET_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_ISA_EXT_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_BRANCH_TYPE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_EXCEPTION_CLASS_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_OPDEF_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_RW_ACTION_REQUIRED_BITS <= 8);
#ifndef ZYDIS_MINIMAL_MODE
# define ZYDIS_INSTRUCTION_DEFINITION_BASE \
ZyanU16 mnemonic ZYAN_BITFIELD(ZYDIS_MNEMONIC_REQUIRED_BITS); \
ZyanU8 operand_count ZYAN_BITFIELD( 4); \
ZyanU8 operand_count_visible ZYAN_BITFIELD( 3); \
ZyanU16 operand_reference ZYAN_BITFIELD(15); \
ZyanU8 operand_size_map ZYAN_BITFIELD( 3); \
ZyanU8 address_size_map ZYAN_BITFIELD( 2); \
ZyanU8 flags_reference ZYAN_BITFIELD( 7); \
ZyanBool requires_protected_mode ZYAN_BITFIELD( 1); \
ZyanBool no_compat_mode ZYAN_BITFIELD( 1); \
ZyanU8 category ZYAN_BITFIELD(ZYDIS_CATEGORY_REQUIRED_BITS); \
ZyanU8 isa_set ZYAN_BITFIELD(ZYDIS_ISA_SET_REQUIRED_BITS); \
ZyanU8 isa_ext ZYAN_BITFIELD(ZYDIS_ISA_EXT_REQUIRED_BITS); \
ZyanU8 branch_type ZYAN_BITFIELD(ZYDIS_BRANCH_TYPE_REQUIRED_BITS); \
ZyanU8 exception_class ZYAN_BITFIELD(ZYDIS_EXCEPTION_CLASS_REQUIRED_BITS); \
ZyanU8 op_reg ZYAN_BITFIELD(ZYDIS_OPDEF_REQUIRED_BITS); \
ZyanU8 op_rm ZYAN_BITFIELD(ZYDIS_OPDEF_REQUIRED_BITS); \
ZyanU8 cpu_state ZYAN_BITFIELD(ZYDIS_RW_ACTION_REQUIRED_BITS); \
ZyanU8 fpu_state ZYAN_BITFIELD(ZYDIS_RW_ACTION_REQUIRED_BITS); \
ZyanU8 xmm_state ZYAN_BITFIELD(ZYDIS_RW_ACTION_REQUIRED_BITS); \
ZyanBool accepts_segment ZYAN_BITFIELD( 1)
#else
# define ZYDIS_INSTRUCTION_DEFINITION_BASE \
ZyanU16 mnemonic ZYAN_BITFIELD(ZYDIS_MNEMONIC_REQUIRED_BITS); \
ZyanU8 operand_size_map ZYAN_BITFIELD( 3); \
ZyanU8 address_size_map ZYAN_BITFIELD( 2); \
ZyanBool requires_protected_mode ZYAN_BITFIELD( 1); \
ZyanBool no_compat_mode ZYAN_BITFIELD( 1); \
ZyanU8 op_reg ZYAN_BITFIELD(ZYDIS_OPDEF_REQUIRED_BITS); \
ZyanU8 op_rm ZYAN_BITFIELD(ZYDIS_OPDEF_REQUIRED_BITS)
#endif
#define ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR \
ZYDIS_INSTRUCTION_DEFINITION_BASE; \
ZyanU8 op_ndsndd ZYAN_BITFIELD(ZYDIS_OPDEF_REQUIRED_BITS)
#define ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR_INTEL \
ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR; \
ZyanBool is_gather ZYAN_BITFIELD( 1); \
ZyanBool no_source_dest_match ZYAN_BITFIELD( 1); \
ZyanBool no_source_source_match ZYAN_BITFIELD( 1) // TODO: Could be moved to VEX
/**
* Defines the `ZydisInstructionDefinition` struct.
*/
typedef struct ZydisInstructionDefinition_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE;
} ZydisInstructionDefinition;
/**
* Defines the `ZydisInstructionDefinitionLEGACY` struct.
*/
typedef struct ZydisInstructionDefinitionLEGACY_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE;
#ifndef ZYDIS_MINIMAL_MODE
ZyanBool is_privileged ZYAN_BITFIELD( 1);
#endif
ZyanBool accepts_LOCK ZYAN_BITFIELD( 1);
#ifndef ZYDIS_MINIMAL_MODE
ZyanBool accepts_REP ZYAN_BITFIELD( 1);
ZyanBool accepts_REPEREPZ ZYAN_BITFIELD( 1);
ZyanBool accepts_REPNEREPNZ ZYAN_BITFIELD( 1);
ZyanBool accepts_BOUND ZYAN_BITFIELD( 1);
ZyanBool accepts_XACQUIRE ZYAN_BITFIELD( 1);
ZyanBool accepts_XRELEASE ZYAN_BITFIELD( 1);
ZyanBool accepts_NOTRACK ZYAN_BITFIELD( 1);
ZyanBool accepts_hle_without_lock ZYAN_BITFIELD( 1);
ZyanBool accepts_branch_hints ZYAN_BITFIELD( 1);
#endif
} ZydisInstructionDefinitionLEGACY;
/**
* Defines the `ZydisInstructionDefinition3DNOW` struct.
*/
typedef struct ZydisInstructionDefinition3DNOW_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE;
} ZydisInstructionDefinition3DNOW;
/**
* Defines the `ZydisInstructionDefinitionXOP` struct.
*/
typedef struct ZydisInstructionDefinitionXOP_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR;
} ZydisInstructionDefinitionXOP;
// MSVC does not correctly execute the `pragma pack(1)` compiler-directive, if we use the correct
// enum types
ZYAN_STATIC_ASSERT(ZYDIS_VEX_STATIC_BROADCAST_REQUIRED_BITS <= 8);
/**
* Defines the `ZydisInstructionDefinitionVEX` struct.
*/
typedef struct ZydisInstructionDefinitionVEX_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR_INTEL;
#ifndef ZYDIS_MINIMAL_MODE
ZyanU8 broadcast ZYAN_BITFIELD(ZYDIS_VEX_STATIC_BROADCAST_REQUIRED_BITS);
#endif
} ZydisInstructionDefinitionVEX;
#ifndef ZYDIS_DISABLE_AVX512
// MSVC does not correctly execute the `pragma pack(1)` compiler-directive, if we use the correct
// enum types
ZYAN_STATIC_ASSERT(ZYDIS_IVECTOR_LENGTH_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_TUPLETYPE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_IELEMENT_SIZE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_EVEX_FUNC_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_MASK_POLICY_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_MASK_OVERRIDE_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_EVEX_STATIC_BROADCAST_REQUIRED_BITS <= 8);
/**
* Defines the `ZydisInstructionDefinitionEVEX` struct.
*/
typedef struct ZydisInstructionDefinitionEVEX_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR_INTEL;
#ifndef ZYDIS_MINIMAL_MODE
ZyanU8 vector_length ZYAN_BITFIELD(ZYDIS_IVECTOR_LENGTH_REQUIRED_BITS);
ZyanU8 tuple_type ZYAN_BITFIELD(ZYDIS_TUPLETYPE_REQUIRED_BITS);
ZyanU8 element_size ZYAN_BITFIELD(ZYDIS_IELEMENT_SIZE_REQUIRED_BITS);
ZyanU8 functionality ZYAN_BITFIELD(ZYDIS_EVEX_FUNC_REQUIRED_BITS);
#endif
ZyanU8 mask_policy ZYAN_BITFIELD(ZYDIS_MASK_POLICY_REQUIRED_BITS);
ZyanBool accepts_zero_mask ZYAN_BITFIELD( 1);
#ifndef ZYDIS_MINIMAL_MODE
ZyanU8 mask_override ZYAN_BITFIELD(ZYDIS_MASK_OVERRIDE_REQUIRED_BITS);
ZyanU8 broadcast ZYAN_BITFIELD(ZYDIS_EVEX_STATIC_BROADCAST_REQUIRED_BITS);
#endif
} ZydisInstructionDefinitionEVEX;
#endif
#ifndef ZYDIS_DISABLE_KNC
// MSVC does not correctly execute the `pragma pack(1)` compiler-directive, if we use the correct
// enum types
ZYAN_STATIC_ASSERT(ZYDIS_MVEX_FUNC_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_MASK_POLICY_REQUIRED_BITS <= 8);
ZYAN_STATIC_ASSERT(ZYDIS_MVEX_STATIC_BROADCAST_REQUIRED_BITS <= 8);
/**
* Defines the `ZydisInstructionDefinitionMVEX` struct.
*/
typedef struct ZydisInstructionDefinitionMVEX_
{
ZYDIS_INSTRUCTION_DEFINITION_BASE_VECTOR_INTEL;
ZyanU8 functionality ZYAN_BITFIELD(ZYDIS_MVEX_FUNC_REQUIRED_BITS);
ZyanU8 mask_policy ZYAN_BITFIELD(ZYDIS_MASK_POLICY_REQUIRED_BITS);
#ifndef ZYDIS_MINIMAL_MODE
ZyanBool has_element_granularity ZYAN_BITFIELD( 1);
ZyanU8 broadcast ZYAN_BITFIELD(ZYDIS_MVEX_STATIC_BROADCAST_REQUIRED_BITS);
#endif
} ZydisInstructionDefinitionMVEX;
#endif
/* ---------------------------------------------------------------------------------------------- */
#pragma pack(pop)
#ifdef ZYAN_MSVC
# pragma warning(pop)
#endif
/* ---------------------------------------------------------------------------------------------- */
/* Accessed CPU/FPU flags */
/* ---------------------------------------------------------------------------------------------- */
/*
* Contains information about the CPU/FPU flags accessed by an instruction.
*
* We don't want this struct to be packed! A pointer to the individual members will be used by the
* `ZydisDecodedInstruction` struct.
*/
typedef struct ZydisDefinitionAccessedFlags_
{
ZydisAccessedFlags cpu_flags;
ZydisAccessedFlags fpu_flags;
} ZydisDefinitionAccessedFlags;
/* ---------------------------------------------------------------------------------------------- */
/* ============================================================================================== */
/* Functions */
/* ============================================================================================== */
/* ---------------------------------------------------------------------------------------------- */
/* Instruction definition */
/* ---------------------------------------------------------------------------------------------- */
/**
* Returns the instruction-definition with the given `encoding` and `id`.
*
* @param encoding The instruction-encoding.
* @param id The definition-id.
* @param definition A pointer to the variable that receives a pointer to the instruction-
* definition.
*/
ZYDIS_NO_EXPORT void ZydisGetInstructionDefinition(ZydisInstructionEncoding encoding,
ZyanU16 id, const ZydisInstructionDefinition** definition);
/* ---------------------------------------------------------------------------------------------- */
/* Operand definition */
/* ---------------------------------------------------------------------------------------------- */
#ifndef ZYDIS_MINIMAL_MODE
/**
* Returns the the operand-definitions for the given instruction-`definition`.
*
* @param definition A pointer to the instruction-definition.
*
* @return A pointer to the first operand definition of the instruction, or `ZYAN_NULL`.
*/
ZYDIS_NO_EXPORT const ZydisOperandDefinition* ZydisGetOperandDefinitions(
const ZydisInstructionDefinition* definition);
#endif
/* ---------------------------------------------------------------------------------------------- */
/* Element info */
/* ---------------------------------------------------------------------------------------------- */
#ifndef ZYDIS_MINIMAL_MODE
/**
* Returns the actual type and size of an internal element-type.
*
* @param element The internal element type.
* @param type The actual element type.
* @param size The element size.
*/
ZYDIS_NO_EXPORT void ZydisGetElementInfo(ZydisInternalElementType element, ZydisElementType* type,
ZydisElementSize* size);
#endif
/* ---------------------------------------------------------------------------------------------- */
/* Accessed CPU flags */
/* ---------------------------------------------------------------------------------------------- */
#ifndef ZYDIS_MINIMAL_MODE
/**
* Returns the the operand-definitions for the given instruction-`definition`.
*
* @param definition A pointer to the instruction-definition.
* @param flags A pointer to the variable that receives the `ZydisDefinitionAccessedFlags`
* struct.
*
* @return `ZYAN_TRUE`, if the instruction accesses any flags, or `ZYAN_FALSE`, if not.
*/
ZYDIS_NO_EXPORT ZyanBool ZydisGetAccessedFlags(const ZydisInstructionDefinition* definition,
const ZydisDefinitionAccessedFlags** flags);
#endif
/* ---------------------------------------------------------------------------------------------- */
/* ============================================================================================== */
#ifdef __cplusplus
}
#endif
#endif /* ZYDIS_INTERNAL_SHAREDDATA_H */