1 /*************************************************************************************************** 2 3 Zyan Disassembler Library (Zydis) 4 5 Original Author : Florian Bernd 6 7 * Permission is hereby granted, free of charge, to any person obtaining a copy 8 * of this software and associated documentation files (the "Software"), to deal 9 * in the Software without restriction, including without limitation the rights 10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 * copies of the Software, and to permit persons to whom the Software is 12 * furnished to do so, subject to the following conditions: 13 * 14 * The above copyright notice and this permission notice shall be included in all 15 * copies or substantial portions of the Software. 16 * 17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 * SOFTWARE. 24 25 ***************************************************************************************************/ 26 27 /** 28 * @file 29 * Defines decoder/encoder-shared macros and types. 30 */ 31 32 #ifndef ZYDIS_SHAREDTYPES_H 33 #define ZYDIS_SHAREDTYPES_H 34 35 #include <Zycore/Types.h> 36 37 #ifdef __cplusplus 38 extern "C" { 39 #endif 40 41 /* ============================================================================================== */ 42 /* Macros */ 43 /* ============================================================================================== */ 44 45 /* ---------------------------------------------------------------------------------------------- */ 46 /* Constants */ 47 /* ---------------------------------------------------------------------------------------------- */ 48 49 #define ZYDIS_MAX_INSTRUCTION_LENGTH 15 50 #define ZYDIS_MAX_OPERAND_COUNT 10 // TODO: Auto generate 51 #define ZYDIS_MAX_OPERAND_COUNT_VISIBLE 5 // TODO: Auto generate 52 53 /* ---------------------------------------------------------------------------------------------- */ 54 55 /* ============================================================================================== */ 56 /* Enums and types */ 57 /* ============================================================================================== */ 58 59 /* ---------------------------------------------------------------------------------------------- */ 60 /* Machine mode */ 61 /* ---------------------------------------------------------------------------------------------- */ 62 63 /** 64 * Defines the `ZydisMachineMode` enum. 65 */ 66 typedef enum ZydisMachineMode_ 67 { 68 /** 69 * 64 bit mode. 70 */ 71 ZYDIS_MACHINE_MODE_LONG_64, 72 /** 73 * 32 bit protected mode. 74 */ 75 ZYDIS_MACHINE_MODE_LONG_COMPAT_32, 76 /** 77 * 16 bit protected mode. 78 */ 79 ZYDIS_MACHINE_MODE_LONG_COMPAT_16, 80 /** 81 * 32 bit protected mode. 82 */ 83 ZYDIS_MACHINE_MODE_LEGACY_32, 84 /** 85 * 16 bit protected mode. 86 */ 87 ZYDIS_MACHINE_MODE_LEGACY_16, 88 /** 89 * 16 bit real mode. 90 */ 91 ZYDIS_MACHINE_MODE_REAL_16, 92 93 /** 94 * Maximum value of this enum. 95 */ 96 ZYDIS_MACHINE_MODE_MAX_VALUE = ZYDIS_MACHINE_MODE_REAL_16, 97 /** 98 * The minimum number of bits required to represent all values of this enum. 99 */ 100 ZYDIS_MACHINE_MODE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_MACHINE_MODE_MAX_VALUE) 101 } ZydisMachineMode; 102 103 /* ---------------------------------------------------------------------------------------------- */ 104 /* Stack width */ 105 /* ---------------------------------------------------------------------------------------------- */ 106 107 /** 108 * Defines the `ZydisStackWidth` enum. 109 */ 110 typedef enum ZydisStackWidth_ 111 { 112 ZYDIS_STACK_WIDTH_16, 113 ZYDIS_STACK_WIDTH_32, 114 ZYDIS_STACK_WIDTH_64, 115 116 /** 117 * Maximum value of this enum. 118 */ 119 ZYDIS_STACK_WIDTH_MAX_VALUE = ZYDIS_STACK_WIDTH_64, 120 /** 121 * The minimum number of bits required to represent all values of this enum. 122 */ 123 ZYDIS_STACK_WIDTH_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_STACK_WIDTH_MAX_VALUE) 124 } ZydisStackWidth; 125 126 /* ---------------------------------------------------------------------------------------------- */ 127 /* Element type */ 128 /* ---------------------------------------------------------------------------------------------- */ 129 130 /** 131 * Defines the `ZydisElementType` enum. 132 */ 133 typedef enum ZydisElementType_ 134 { 135 ZYDIS_ELEMENT_TYPE_INVALID, 136 /** 137 * A struct type. 138 */ 139 ZYDIS_ELEMENT_TYPE_STRUCT, 140 /** 141 * Unsigned integer value. 142 */ 143 ZYDIS_ELEMENT_TYPE_UINT, 144 /** 145 * Signed integer value. 146 */ 147 ZYDIS_ELEMENT_TYPE_INT, 148 /** 149 * 16-bit floating point value (`half`). 150 */ 151 ZYDIS_ELEMENT_TYPE_FLOAT16, 152 /** 153 * 32-bit floating point value (`single`). 154 */ 155 ZYDIS_ELEMENT_TYPE_FLOAT32, 156 /** 157 * 64-bit floating point value (`double`). 158 */ 159 ZYDIS_ELEMENT_TYPE_FLOAT64, 160 /** 161 * 80-bit floating point value (`extended`). 162 */ 163 ZYDIS_ELEMENT_TYPE_FLOAT80, 164 /** 165 * 16-bit brain floating point value. 166 */ 167 ZYDIS_ELEMENT_TYPE_BFLOAT16, 168 /** 169 * Binary coded decimal value. 170 */ 171 ZYDIS_ELEMENT_TYPE_LONGBCD, 172 /** 173 * A condition code (e.g. used by `CMPPD`, `VCMPPD`, ...). 174 */ 175 ZYDIS_ELEMENT_TYPE_CC, 176 177 /** 178 * Maximum value of this enum. 179 */ 180 ZYDIS_ELEMENT_TYPE_MAX_VALUE = ZYDIS_ELEMENT_TYPE_CC, 181 /** 182 * The minimum number of bits required to represent all values of this enum. 183 */ 184 ZYDIS_ELEMENT_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_ELEMENT_TYPE_MAX_VALUE) 185 } ZydisElementType; 186 187 /* ---------------------------------------------------------------------------------------------- */ 188 /* Element size */ 189 /* ---------------------------------------------------------------------------------------------- */ 190 191 /** 192 * Defines the `ZydisElementSize` datatype. 193 */ 194 typedef ZyanU16 ZydisElementSize; 195 196 /* ---------------------------------------------------------------------------------------------- */ 197 /* Operand type */ 198 /* ---------------------------------------------------------------------------------------------- */ 199 200 /** 201 * Defines the `ZydisOperandType` enum. 202 */ 203 typedef enum ZydisOperandType_ 204 { 205 /** 206 * The operand is not used. 207 */ 208 ZYDIS_OPERAND_TYPE_UNUSED, 209 /** 210 * The operand is a register operand. 211 */ 212 ZYDIS_OPERAND_TYPE_REGISTER, 213 /** 214 * The operand is a memory operand. 215 */ 216 ZYDIS_OPERAND_TYPE_MEMORY, 217 /** 218 * The operand is a pointer operand with a segment:offset lvalue. 219 */ 220 ZYDIS_OPERAND_TYPE_POINTER, 221 /** 222 * The operand is an immediate operand. 223 */ 224 ZYDIS_OPERAND_TYPE_IMMEDIATE, 225 226 /** 227 * Maximum value of this enum. 228 */ 229 ZYDIS_OPERAND_TYPE_MAX_VALUE = ZYDIS_OPERAND_TYPE_IMMEDIATE, 230 /** 231 * The minimum number of bits required to represent all values of this enum. 232 */ 233 ZYDIS_OPERAND_TYPE_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_OPERAND_TYPE_MAX_VALUE) 234 } ZydisOperandType; 235 236 // If asserts are failing here remember to update encoder table generator before fixing asserts 237 ZYAN_STATIC_ASSERT(ZYAN_BITS_TO_REPRESENT( 238 ZYDIS_OPERAND_TYPE_MAX_VALUE - ZYDIS_OPERAND_TYPE_REGISTER) == 2); 239 240 /* ---------------------------------------------------------------------------------------------- */ 241 /* Operand encoding */ 242 /* ---------------------------------------------------------------------------------------------- */ 243 244 /** 245 * Defines the `ZydisOperandEncoding` enum. 246 */ 247 typedef enum ZydisOperandEncoding_ 248 { 249 ZYDIS_OPERAND_ENCODING_NONE, 250 ZYDIS_OPERAND_ENCODING_MODRM_REG, 251 ZYDIS_OPERAND_ENCODING_MODRM_RM, 252 ZYDIS_OPERAND_ENCODING_OPCODE, 253 ZYDIS_OPERAND_ENCODING_NDSNDD, 254 ZYDIS_OPERAND_ENCODING_IS4, 255 ZYDIS_OPERAND_ENCODING_MASK, 256 ZYDIS_OPERAND_ENCODING_DISP8, 257 ZYDIS_OPERAND_ENCODING_DISP16, 258 ZYDIS_OPERAND_ENCODING_DISP32, 259 ZYDIS_OPERAND_ENCODING_DISP64, 260 ZYDIS_OPERAND_ENCODING_DISP16_32_64, 261 ZYDIS_OPERAND_ENCODING_DISP32_32_64, 262 ZYDIS_OPERAND_ENCODING_DISP16_32_32, 263 ZYDIS_OPERAND_ENCODING_UIMM8, 264 ZYDIS_OPERAND_ENCODING_UIMM16, 265 ZYDIS_OPERAND_ENCODING_UIMM32, 266 ZYDIS_OPERAND_ENCODING_UIMM64, 267 ZYDIS_OPERAND_ENCODING_UIMM16_32_64, 268 ZYDIS_OPERAND_ENCODING_UIMM32_32_64, 269 ZYDIS_OPERAND_ENCODING_UIMM16_32_32, 270 ZYDIS_OPERAND_ENCODING_SIMM8, 271 ZYDIS_OPERAND_ENCODING_SIMM16, 272 ZYDIS_OPERAND_ENCODING_SIMM32, 273 ZYDIS_OPERAND_ENCODING_SIMM64, 274 ZYDIS_OPERAND_ENCODING_SIMM16_32_64, 275 ZYDIS_OPERAND_ENCODING_SIMM32_32_64, 276 ZYDIS_OPERAND_ENCODING_SIMM16_32_32, 277 ZYDIS_OPERAND_ENCODING_JIMM8, 278 ZYDIS_OPERAND_ENCODING_JIMM16, 279 ZYDIS_OPERAND_ENCODING_JIMM32, 280 ZYDIS_OPERAND_ENCODING_JIMM64, 281 ZYDIS_OPERAND_ENCODING_JIMM16_32_64, 282 ZYDIS_OPERAND_ENCODING_JIMM32_32_64, 283 ZYDIS_OPERAND_ENCODING_JIMM16_32_32, 284 285 /** 286 * Maximum value of this enum. 287 */ 288 ZYDIS_OPERAND_ENCODING_MAX_VALUE = ZYDIS_OPERAND_ENCODING_JIMM16_32_32, 289 /** 290 * The minimum number of bits required to represent all values of this enum. 291 */ 292 ZYDIS_OPERAND_ENCODING_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_OPERAND_ENCODING_MAX_VALUE) 293 } ZydisOperandEncoding; 294 295 /* ---------------------------------------------------------------------------------------------- */ 296 /* Operand visibility */ 297 /* ---------------------------------------------------------------------------------------------- */ 298 299 /** 300 * Defines the `ZydisOperandVisibility` enum. 301 */ 302 typedef enum ZydisOperandVisibility_ 303 { 304 ZYDIS_OPERAND_VISIBILITY_INVALID, 305 /** 306 * The operand is explicitly encoded in the instruction. 307 */ 308 ZYDIS_OPERAND_VISIBILITY_EXPLICIT, 309 /** 310 * The operand is part of the opcode, but listed as an operand. 311 */ 312 ZYDIS_OPERAND_VISIBILITY_IMPLICIT, 313 /** 314 * The operand is part of the opcode, and not typically listed as an operand. 315 */ 316 ZYDIS_OPERAND_VISIBILITY_HIDDEN, 317 318 /** 319 * Maximum value of this enum. 320 */ 321 ZYDIS_OPERAND_VISIBILITY_MAX_VALUE = ZYDIS_OPERAND_VISIBILITY_HIDDEN, 322 /** 323 * The minimum number of bits required to represent all values of this enum. 324 */ 325 ZYDIS_OPERAND_VISIBILITY_REQUIRED_BITS = 326 ZYAN_BITS_TO_REPRESENT(ZYDIS_OPERAND_VISIBILITY_MAX_VALUE) 327 } ZydisOperandVisibility; 328 329 /* ---------------------------------------------------------------------------------------------- */ 330 /* Operand action */ 331 /* ---------------------------------------------------------------------------------------------- */ 332 333 /** 334 * Defines the `ZydisOperandAction` enum. 335 */ 336 typedef enum ZydisOperandAction_ 337 { 338 /* ------------------------------------------------------------------------------------------ */ 339 /* Elemental actions */ 340 /* ------------------------------------------------------------------------------------------ */ 341 342 /** 343 * The operand is read by the instruction. 344 */ 345 ZYDIS_OPERAND_ACTION_READ = 0x01, 346 /** 347 * The operand is written by the instruction (must write). 348 */ 349 ZYDIS_OPERAND_ACTION_WRITE = 0x02, 350 /** 351 * The operand is conditionally read by the instruction. 352 */ 353 ZYDIS_OPERAND_ACTION_CONDREAD = 0x04, 354 /** 355 * The operand is conditionally written by the instruction (may write). 356 */ 357 ZYDIS_OPERAND_ACTION_CONDWRITE = 0x08, 358 359 /* ------------------------------------------------------------------------------------------ */ 360 /* Combined actions */ 361 /* ------------------------------------------------------------------------------------------ */ 362 363 /** 364 * The operand is read (must read) and written by the instruction (must write). 365 */ 366 ZYDIS_OPERAND_ACTION_READWRITE = ZYDIS_OPERAND_ACTION_READ | ZYDIS_OPERAND_ACTION_WRITE, 367 /** 368 * The operand is conditionally read (may read) and conditionally written by 369 * the instruction (may write). 370 */ 371 ZYDIS_OPERAND_ACTION_CONDREAD_CONDWRITE = 372 ZYDIS_OPERAND_ACTION_CONDREAD | ZYDIS_OPERAND_ACTION_CONDWRITE, 373 /** 374 * The operand is read (must read) and conditionally written by the 375 * instruction (may write). 376 */ 377 ZYDIS_OPERAND_ACTION_READ_CONDWRITE = 378 ZYDIS_OPERAND_ACTION_READ | ZYDIS_OPERAND_ACTION_CONDWRITE, 379 /** 380 * The operand is written (must write) and conditionally read by the 381 * instruction (may read). 382 */ 383 ZYDIS_OPERAND_ACTION_CONDREAD_WRITE = 384 ZYDIS_OPERAND_ACTION_CONDREAD | ZYDIS_OPERAND_ACTION_WRITE, 385 386 /** 387 * Mask combining all reading access flags. 388 */ 389 ZYDIS_OPERAND_ACTION_MASK_READ = ZYDIS_OPERAND_ACTION_READ | ZYDIS_OPERAND_ACTION_CONDREAD, 390 /** 391 * Mask combining all writing access flags. 392 */ 393 ZYDIS_OPERAND_ACTION_MASK_WRITE = ZYDIS_OPERAND_ACTION_WRITE | ZYDIS_OPERAND_ACTION_CONDWRITE, 394 395 /* ------------------------------------------------------------------------------------------ */ 396 397 /** 398 * The minimum number of bits required to represent all values of this bitset. 399 */ 400 ZYDIS_OPERAND_ACTION_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_OPERAND_ACTION_CONDWRITE) 401 } ZydisOperandAction; 402 403 /** 404 * Defines the `ZydisOperandActions` data-type. 405 */ 406 typedef ZyanU8 ZydisOperandActions; 407 408 /* ---------------------------------------------------------------------------------------------- */ 409 /* Instruction encoding */ 410 /* ---------------------------------------------------------------------------------------------- */ 411 412 /** 413 * Defines the `ZydisInstructionEncoding` enum. 414 */ 415 typedef enum ZydisInstructionEncoding_ 416 { 417 /** 418 * The instruction uses the legacy encoding. 419 */ 420 ZYDIS_INSTRUCTION_ENCODING_LEGACY, 421 /** 422 * The instruction uses the AMD 3DNow-encoding. 423 */ 424 ZYDIS_INSTRUCTION_ENCODING_3DNOW, 425 /** 426 * The instruction uses the AMD XOP-encoding. 427 */ 428 ZYDIS_INSTRUCTION_ENCODING_XOP, 429 /** 430 * The instruction uses the VEX-encoding. 431 */ 432 ZYDIS_INSTRUCTION_ENCODING_VEX, 433 /** 434 * The instruction uses the EVEX-encoding. 435 */ 436 ZYDIS_INSTRUCTION_ENCODING_EVEX, 437 /** 438 * The instruction uses the MVEX-encoding. 439 */ 440 ZYDIS_INSTRUCTION_ENCODING_MVEX, 441 442 /** 443 * Maximum value of this enum. 444 */ 445 ZYDIS_INSTRUCTION_ENCODING_MAX_VALUE = ZYDIS_INSTRUCTION_ENCODING_MVEX, 446 /** 447 * The minimum number of bits required to represent all values of this enum. 448 */ 449 ZYDIS_INSTRUCTION_ENCODING_REQUIRED_BITS = 450 ZYAN_BITS_TO_REPRESENT(ZYDIS_INSTRUCTION_ENCODING_MAX_VALUE) 451 } ZydisInstructionEncoding; 452 453 /* ---------------------------------------------------------------------------------------------- */ 454 /* Opcode map */ 455 /* ---------------------------------------------------------------------------------------------- */ 456 457 /** 458 * Defines the `ZydisOpcodeMap` enum. 459 */ 460 typedef enum ZydisOpcodeMap_ 461 { 462 ZYDIS_OPCODE_MAP_DEFAULT, 463 ZYDIS_OPCODE_MAP_0F, 464 ZYDIS_OPCODE_MAP_0F38, 465 ZYDIS_OPCODE_MAP_0F3A, 466 ZYDIS_OPCODE_MAP_MAP4, // not used 467 ZYDIS_OPCODE_MAP_MAP5, 468 ZYDIS_OPCODE_MAP_MAP6, 469 ZYDIS_OPCODE_MAP_MAP7, // not used 470 ZYDIS_OPCODE_MAP_0F0F, 471 ZYDIS_OPCODE_MAP_XOP8, 472 ZYDIS_OPCODE_MAP_XOP9, 473 ZYDIS_OPCODE_MAP_XOPA, 474 475 /** 476 * Maximum value of this enum. 477 */ 478 ZYDIS_OPCODE_MAP_MAX_VALUE = ZYDIS_OPCODE_MAP_XOPA, 479 /** 480 * The minimum number of bits required to represent all values of this enum. 481 */ 482 ZYDIS_OPCODE_MAP_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT(ZYDIS_OPCODE_MAP_MAX_VALUE) 483 } ZydisOpcodeMap; 484 485 /* ---------------------------------------------------------------------------------------------- */ 486 /* Instruction attributes */ 487 /* ---------------------------------------------------------------------------------------------- */ 488 489 /** 490 * @defgroup instruction_attributes Instruction attributes 491 * 492 * Constants describing various properties of an instruction. Used in the 493 * @ref ZydisDecodedInstruction.attributes and @ref ZydisEncoderRequest.prefixes fields. 494 * 495 * @{ 496 */ 497 498 /** 499 * Defines the `ZydisInstructionAttributes` data-type. 500 */ 501 typedef ZyanU64 ZydisInstructionAttributes; 502 503 /** 504 * The instruction has the `ModRM` byte. 505 */ 506 #define ZYDIS_ATTRIB_HAS_MODRM (1ULL << 0) 507 /** 508 * The instruction has the `SIB` byte. 509 */ 510 #define ZYDIS_ATTRIB_HAS_SIB (1ULL << 1) 511 /** 512 * The instruction has the `REX` prefix. 513 */ 514 #define ZYDIS_ATTRIB_HAS_REX (1ULL << 2) 515 /** 516 * The instruction has the `XOP` prefix. 517 */ 518 #define ZYDIS_ATTRIB_HAS_XOP (1ULL << 3) 519 /** 520 * The instruction has the `VEX` prefix. 521 */ 522 #define ZYDIS_ATTRIB_HAS_VEX (1ULL << 4) 523 /** 524 * The instruction has the `EVEX` prefix. 525 */ 526 #define ZYDIS_ATTRIB_HAS_EVEX (1ULL << 5) 527 /** 528 * The instruction has the `MVEX` prefix. 529 */ 530 #define ZYDIS_ATTRIB_HAS_MVEX (1ULL << 6) 531 /** 532 * The instruction has one or more operands with position-relative offsets. 533 */ 534 #define ZYDIS_ATTRIB_IS_RELATIVE (1ULL << 7) 535 /** 536 * The instruction is privileged. 537 * 538 * Privileged instructions are any instructions that require a current ring level below 3. 539 */ 540 #define ZYDIS_ATTRIB_IS_PRIVILEGED (1ULL << 8) 541 /** 542 * The instruction accesses one or more CPU-flags. 543 */ 544 #define ZYDIS_ATTRIB_CPUFLAG_ACCESS (1ULL << 9) 545 /** 546 * The instruction may conditionally read the general CPU state. 547 */ 548 #define ZYDIS_ATTRIB_CPU_STATE_CR (1ULL << 10) 549 /** 550 * The instruction may conditionally write the general CPU state. 551 */ 552 #define ZYDIS_ATTRIB_CPU_STATE_CW (1ULL << 11) 553 /** 554 * The instruction may conditionally read the FPU state (X87, MMX). 555 */ 556 #define ZYDIS_ATTRIB_FPU_STATE_CR (1ULL << 12) 557 /** 558 * The instruction may conditionally write the FPU state (X87, MMX). 559 */ 560 #define ZYDIS_ATTRIB_FPU_STATE_CW (1ULL << 13) 561 /** 562 * The instruction may conditionally read the XMM state (AVX, AVX2, AVX-512). 563 */ 564 #define ZYDIS_ATTRIB_XMM_STATE_CR (1ULL << 14) 565 /** 566 * The instruction may conditionally write the XMM state (AVX, AVX2, AVX-512). 567 */ 568 #define ZYDIS_ATTRIB_XMM_STATE_CW (1ULL << 15) 569 /** 570 * The instruction accepts the `LOCK` prefix (`0xF0`). 571 */ 572 #define ZYDIS_ATTRIB_ACCEPTS_LOCK (1ULL << 16) 573 /** 574 * The instruction accepts the `REP` prefix (`0xF3`). 575 */ 576 #define ZYDIS_ATTRIB_ACCEPTS_REP (1ULL << 17) 577 /** 578 * The instruction accepts the `REPE`/`REPZ` prefix (`0xF3`). 579 */ 580 #define ZYDIS_ATTRIB_ACCEPTS_REPE (1ULL << 18) 581 /** 582 * The instruction accepts the `REPE`/`REPZ` prefix (`0xF3`). 583 */ 584 #define ZYDIS_ATTRIB_ACCEPTS_REPZ ZYDIS_ATTRIB_ACCEPTS_REPE 585 /** 586 * The instruction accepts the `REPNE`/`REPNZ` prefix (`0xF2`). 587 */ 588 #define ZYDIS_ATTRIB_ACCEPTS_REPNE (1ULL << 19) 589 /** 590 * The instruction accepts the `REPNE`/`REPNZ` prefix (`0xF2`). 591 */ 592 #define ZYDIS_ATTRIB_ACCEPTS_REPNZ ZYDIS_ATTRIB_ACCEPTS_REPNE 593 /** 594 * The instruction accepts the `BND` prefix (`0xF2`). 595 */ 596 #define ZYDIS_ATTRIB_ACCEPTS_BND (1ULL << 20) 597 /** 598 * The instruction accepts the `XACQUIRE` prefix (`0xF2`). 599 */ 600 #define ZYDIS_ATTRIB_ACCEPTS_XACQUIRE (1ULL << 21) 601 /** 602 * The instruction accepts the `XRELEASE` prefix (`0xF3`). 603 */ 604 #define ZYDIS_ATTRIB_ACCEPTS_XRELEASE (1ULL << 22) 605 /** 606 * The instruction accepts the `XACQUIRE`/`XRELEASE` prefixes (`0xF2`, `0xF3`) 607 * without the `LOCK` prefix (`0x0F`). 608 */ 609 #define ZYDIS_ATTRIB_ACCEPTS_HLE_WITHOUT_LOCK (1ULL << 23) 610 /** 611 * The instruction accepts branch hints (0x2E, 0x3E). 612 */ 613 #define ZYDIS_ATTRIB_ACCEPTS_BRANCH_HINTS (1ULL << 24) 614 /** 615 * The instruction accepts the `CET` `no-track` prefix (`0x3E`). 616 */ 617 #define ZYDIS_ATTRIB_ACCEPTS_NOTRACK (1ULL << 25) 618 /** 619 * The instruction accepts segment prefixes (`0x2E`, `0x36`, `0x3E`, `0x26`, 620 * `0x64`, `0x65`). 621 */ 622 #define ZYDIS_ATTRIB_ACCEPTS_SEGMENT (1ULL << 26) 623 /** 624 * The instruction has the `LOCK` prefix (`0xF0`). 625 */ 626 #define ZYDIS_ATTRIB_HAS_LOCK (1ULL << 27) 627 /** 628 * The instruction has the `REP` prefix (`0xF3`). 629 */ 630 #define ZYDIS_ATTRIB_HAS_REP (1ULL << 28) 631 /** 632 * The instruction has the `REPE`/`REPZ` prefix (`0xF3`). 633 */ 634 #define ZYDIS_ATTRIB_HAS_REPE (1ULL << 29) 635 /** 636 * The instruction has the `REPE`/`REPZ` prefix (`0xF3`). 637 */ 638 #define ZYDIS_ATTRIB_HAS_REPZ ZYDIS_ATTRIB_HAS_REPE 639 /** 640 * The instruction has the `REPNE`/`REPNZ` prefix (`0xF2`). 641 */ 642 #define ZYDIS_ATTRIB_HAS_REPNE (1ULL << 30) 643 /** 644 * The instruction has the `REPNE`/`REPNZ` prefix (`0xF2`). 645 */ 646 #define ZYDIS_ATTRIB_HAS_REPNZ ZYDIS_ATTRIB_HAS_REPNE 647 /** 648 * The instruction has the `BND` prefix (`0xF2`). 649 */ 650 #define ZYDIS_ATTRIB_HAS_BND (1ULL << 31) 651 /** 652 * The instruction has the `XACQUIRE` prefix (`0xF2`). 653 */ 654 #define ZYDIS_ATTRIB_HAS_XACQUIRE (1ULL << 32) 655 /** 656 * The instruction has the `XRELEASE` prefix (`0xF3`). 657 */ 658 #define ZYDIS_ATTRIB_HAS_XRELEASE (1ULL << 33) 659 /** 660 * The instruction has the branch-not-taken hint (`0x2E`). 661 */ 662 #define ZYDIS_ATTRIB_HAS_BRANCH_NOT_TAKEN (1ULL << 34) 663 /** 664 * The instruction has the branch-taken hint (`0x3E`). 665 */ 666 #define ZYDIS_ATTRIB_HAS_BRANCH_TAKEN (1ULL << 35) 667 /** 668 * The instruction has the `CET` `no-track` prefix (`0x3E`). 669 */ 670 #define ZYDIS_ATTRIB_HAS_NOTRACK (1ULL << 36) 671 /** 672 * The instruction has the `CS` segment modifier (`0x2E`). 673 */ 674 #define ZYDIS_ATTRIB_HAS_SEGMENT_CS (1ULL << 37) 675 /** 676 * The instruction has the `SS` segment modifier (`0x36`). 677 */ 678 #define ZYDIS_ATTRIB_HAS_SEGMENT_SS (1ULL << 38) 679 /** 680 * The instruction has the `DS` segment modifier (`0x3E`). 681 */ 682 #define ZYDIS_ATTRIB_HAS_SEGMENT_DS (1ULL << 39) 683 /** 684 * The instruction has the `ES` segment modifier (`0x26`). 685 */ 686 #define ZYDIS_ATTRIB_HAS_SEGMENT_ES (1ULL << 40) 687 /** 688 * The instruction has the `FS` segment modifier (`0x64`). 689 */ 690 #define ZYDIS_ATTRIB_HAS_SEGMENT_FS (1ULL << 41) 691 /** 692 * The instruction has the `GS` segment modifier (`0x65`). 693 */ 694 #define ZYDIS_ATTRIB_HAS_SEGMENT_GS (1ULL << 42) 695 /** 696 * The instruction has a segment modifier. 697 */ 698 #define ZYDIS_ATTRIB_HAS_SEGMENT (ZYDIS_ATTRIB_HAS_SEGMENT_CS | \ 699 ZYDIS_ATTRIB_HAS_SEGMENT_SS | \ 700 ZYDIS_ATTRIB_HAS_SEGMENT_DS | \ 701 ZYDIS_ATTRIB_HAS_SEGMENT_ES | \ 702 ZYDIS_ATTRIB_HAS_SEGMENT_FS | \ 703 ZYDIS_ATTRIB_HAS_SEGMENT_GS) 704 /** 705 * The instruction has the operand-size override prefix (`0x66`). 706 */ 707 #define ZYDIS_ATTRIB_HAS_OPERANDSIZE (1ULL << 43) // TODO: rename 708 /** 709 * The instruction has the address-size override prefix (`0x67`). 710 */ 711 #define ZYDIS_ATTRIB_HAS_ADDRESSSIZE (1ULL << 44) // TODO: rename 712 /** 713 * The instruction has the `EVEX.b` bit set. 714 * 715 * This attribute is mainly used by the encoder. 716 */ 717 #define ZYDIS_ATTRIB_HAS_EVEX_B (1ULL << 45) // TODO: rename 718 719 /** 720 * @} 721 */ 722 723 /* ---------------------------------------------------------------------------------------------- */ 724 725 /* ============================================================================================== */ 726 727 #ifdef __cplusplus 728 } 729 #endif 730 731 #endif /* ZYDIS_SHAREDTYPES_H */ 732