@@ -457,129 +457,82 @@ typedef ZyanU64 ZydisInstructionAttributes;
457
457
#define ZYDIS_ATTRIB_HAS_NOTRACK 0x0000100000000000 // (1 << 44) // TODO: rebase
458
458
459
459
/* ---------------------------------------------------------------------------------------------- */
460
- /* R/E/FLAGS info */
460
+ /* CPU/FPU flags */
461
461
/* ---------------------------------------------------------------------------------------------- */
462
462
463
463
/**
464
464
* Defines the `ZydisCPUFlags` data-type.
465
465
*/
466
466
typedef ZyanU32 ZydisCPUFlags ;
467
467
468
- /**
469
- * Defines the `ZydisCPUFlag` data-type.
470
- */
471
- typedef ZyanU8 ZydisCPUFlag ;
472
-
473
468
/**
474
469
* Carry flag.
475
470
*/
476
- #define ZYDIS_CPUFLAG_CF 0
471
+ #define ZYDIS_CPUFLAG_CF (1ul << 0)
477
472
/**
478
473
* Parity flag.
479
474
*/
480
- #define ZYDIS_CPUFLAG_PF 2
475
+ #define ZYDIS_CPUFLAG_PF (1ul << 2)
481
476
/**
482
477
* Adjust flag.
483
478
*/
484
- #define ZYDIS_CPUFLAG_AF 4
479
+ #define ZYDIS_CPUFLAG_AF (1ul << 4)
485
480
/**
486
481
* Zero flag.
487
482
*/
488
- #define ZYDIS_CPUFLAG_ZF 6
483
+ #define ZYDIS_CPUFLAG_ZF (1ul << 6)
489
484
/**
490
485
* Sign flag.
491
486
*/
492
- #define ZYDIS_CPUFLAG_SF 7
487
+ #define ZYDIS_CPUFLAG_SF (1ul << 7)
493
488
/**
494
489
* Trap flag.
495
490
*/
496
- #define ZYDIS_CPUFLAG_TF 8
491
+ #define ZYDIS_CPUFLAG_TF (1ul << 8)
497
492
/**
498
493
* Interrupt enable flag.
499
494
*/
500
- #define ZYDIS_CPUFLAG_IF 9
495
+ #define ZYDIS_CPUFLAG_IF (1ul << 9)
501
496
/**
502
497
* Direction flag.
503
498
*/
504
- #define ZYDIS_CPUFLAG_DF 10
499
+ #define ZYDIS_CPUFLAG_DF (1ul << 10)
505
500
/**
506
501
* Overflow flag.
507
502
*/
508
- #define ZYDIS_CPUFLAG_OF 11
503
+ #define ZYDIS_CPUFLAG_OF (1ul << 11)
509
504
/**
510
505
* I/O privilege level flag.
511
506
*/
512
- #define ZYDIS_CPUFLAG_IOPL 12
507
+ #define ZYDIS_CPUFLAG_IOPL (1ul << 12)
513
508
/**
514
509
* Nested task flag.
515
510
*/
516
- #define ZYDIS_CPUFLAG_NT 14
511
+ #define ZYDIS_CPUFLAG_NT (1ul << 14)
517
512
/**
518
513
* Resume flag.
519
514
*/
520
- #define ZYDIS_CPUFLAG_RF 16
515
+ #define ZYDIS_CPUFLAG_RF (1ul << 16)
521
516
/**
522
517
* Virtual 8086 mode flag.
523
518
*/
524
- #define ZYDIS_CPUFLAG_VM 17
519
+ #define ZYDIS_CPUFLAG_VM (1ul << 17)
525
520
/**
526
521
* Alignment check.
527
522
*/
528
- #define ZYDIS_CPUFLAG_AC 18
523
+ #define ZYDIS_CPUFLAG_AC (1ul << 18)
529
524
/**
530
525
* Virtual interrupt flag.
531
526
*/
532
- #define ZYDIS_CPUFLAG_VIF 19
527
+ #define ZYDIS_CPUFLAG_VIF (1ul << 19)
533
528
/**
534
529
* Virtual interrupt pending.
535
530
*/
536
- #define ZYDIS_CPUFLAG_VIP 20
531
+ #define ZYDIS_CPUFLAG_VIP (1ul << 20)
537
532
/**
538
533
* Able to use CPUID instruction.
539
534
*/
540
- #define ZYDIS_CPUFLAG_ID 21
541
-
542
- ///////////////////////////////////////////////////////////////////////////////////////////////////
543
-
544
- /**
545
- * FPU condition-code flag 0.
546
- *
547
- * DEPRECATED. This flag is not actually part of `FLAGS/EFLAGS/RFLAGS` and will be removed in the
548
- * next major release. Please refer to the `fpu_flags_read`/`fpu_flags_written` field instead and
549
- * use one of the `ZYDIS_FPUFLAG_XXX` masks to check for specific a flag.
550
- */
551
- #define ZYDIS_CPUFLAG_C0 22
552
- /**
553
- * FPU condition-code flag 1.
554
- *
555
- * DEPRECATED. This flag is not actually part of `FLAGS/EFLAGS/RFLAGS` and will be removed in the
556
- * next major release. Please refer to the `fpu_flags_read`/`fpu_flags_written` field instead and
557
- * use one of the `ZYDIS_FPUFLAG_XXX` masks to check for specific a flag.
558
- */
559
- #define ZYDIS_CPUFLAG_C1 23
560
- /**
561
- * FPU condition-code flag 2.
562
- *
563
- * DEPRECATED. This flag is not actually part of `FLAGS/EFLAGS/RFLAGS` and will be removed in the
564
- * next major release. Please refer to the `fpu_flags_read`/`fpu_flags_written` field instead and
565
- * use one of the `ZYDIS_FPUFLAG_XXX` masks to check for specific a flag.
566
- */
567
- #define ZYDIS_CPUFLAG_C2 24
568
- /**
569
- * FPU condition-code flag 3.
570
- *
571
- * DEPRECATED. This flag is not actually part of `FLAGS/EFLAGS/RFLAGS` and will be removed in the
572
- * next major release. Please refer to the `fpu_flags_read`/`fpu_flags_written` field instead and
573
- * use one of the `ZYDIS_FPUFLAG_XXX` masks to check for specific a flag.
574
- */
575
- #define ZYDIS_CPUFLAG_C3 25
576
-
577
- /**
578
- * DEPRECATED. This define will be removed in the next major release.
579
- */
580
- #define ZYDIS_CPUFLAG_MAX_VALUE ZYDIS_CPUFLAG_C3
581
-
582
- ///////////////////////////////////////////////////////////////////////////////////////////////////
535
+ #define ZYDIS_CPUFLAG_ID (1ul << 21)
583
536
584
537
/**
585
538
* Defines the `ZydisFPUFlags` data-type.
@@ -589,65 +542,19 @@ typedef ZyanU8 ZydisFPUFlags;
589
542
/**
590
543
* FPU condition-code flag 0.
591
544
*/
592
- #define ZYDIS_FPUFLAG_C0 0x00 // (1 << 0)
545
+ #define ZYDIS_FPUFLAG_C0 (1 << 0)
593
546
/**
594
547
* FPU condition-code flag 1.
595
548
*/
596
- #define ZYDIS_FPUFLAG_C1 0x01 // (1 << 1)
549
+ #define ZYDIS_FPUFLAG_C1 (1 << 1)
597
550
/**
598
551
* FPU condition-code flag 2.
599
552
*/
600
- #define ZYDIS_FPUFLAG_C2 0x02 // (1 << 2)
553
+ #define ZYDIS_FPUFLAG_C2 (1 << 2)
601
554
/**
602
555
* FPU condition-code flag 3.
603
556
*/
604
- #define ZYDIS_FPUFLAG_C3 0x04 // (1 << 3)
605
-
606
- /**
607
- * Defines the `ZydisCPUFlagAction` enum.
608
- *
609
- * DEPRECATED. This enum will be removed in the next major release.
610
- */
611
- typedef enum ZydisCPUFlagAction_
612
- {
613
- /**
614
- * The CPU flag is not touched by the instruction.
615
- */
616
- ZYDIS_CPUFLAG_ACTION_NONE ,
617
- /**
618
- * The CPU flag is tested (read).
619
- */
620
- ZYDIS_CPUFLAG_ACTION_TESTED ,
621
- /**
622
- * The CPU flag is tested and modified afterwards (read-write).
623
- */
624
- ZYDIS_CPUFLAG_ACTION_TESTED_MODIFIED ,
625
- /**
626
- * The CPU flag is modified (write).
627
- */
628
- ZYDIS_CPUFLAG_ACTION_MODIFIED ,
629
- /**
630
- * The CPU flag is set to 0 (write).
631
- */
632
- ZYDIS_CPUFLAG_ACTION_SET_0 ,
633
- /**
634
- * The CPU flag is set to 1 (write).
635
- */
636
- ZYDIS_CPUFLAG_ACTION_SET_1 ,
637
- /**
638
- * The CPU flag is undefined (write).
639
- */
640
- ZYDIS_CPUFLAG_ACTION_UNDEFINED ,
641
-
642
- /**
643
- * Maximum value of this enum.
644
- */
645
- ZYDIS_CPUFLAG_ACTION_MAX_VALUE = ZYDIS_CPUFLAG_ACTION_UNDEFINED ,
646
- /**
647
- * The minimum number of bits required to represent all values of this enum.
648
- */
649
- ZYDIS_CPUFLAG_ACTION_REQUIRED_BITS = ZYAN_BITS_TO_REPRESENT (ZYDIS_CPUFLAG_ACTION_MAX_VALUE )
650
- } ZydisCPUFlagAction ;
557
+ #define ZYDIS_FPUFLAG_C3 (1 << 3)
651
558
652
559
/* ---------------------------------------------------------------------------------------------- */
653
560
/* Branch types */
@@ -1020,40 +927,56 @@ typedef struct ZydisDecodedInstruction_
1020
927
*/
1021
928
ZydisInstructionAttributes attributes ;
1022
929
/**
1023
- * Information about accessed CPU flags.
930
+ * Information about CPU/FPU flags accessed by the instruction .
1024
931
*
1025
- * DEPRECATED. This field will be removed in the next major release. Please use the
1026
- * `cpu_flags_read`/`cpu_flags_written` or `fpu_flags_read`/`fpu_flags_written` fields
1027
- * instead.
932
+ * The bits in the masks correspond to the actual bits in the `FLAGS/EFLAGS/RFLAGS`
933
+ * register.
1028
934
*/
1029
- struct ZydisDecodedInstructionAccessedFlags_
935
+ struct ZydisAccessedCPUFlags_
1030
936
{
1031
- /**
1032
- * The CPU-flag action.
1033
- *
1034
- * Use `ZydisGetAccessedFlagsByAction` to get a mask with all flags matching a specific
1035
- * action.
937
+ /*
938
+ * As mask containing the CPU flags `TESTED` by the instruction.
939
+ */
940
+ ZydisCPUFlags tested ;
941
+ /*
942
+ * As mask containing the CPU flags `MODIFIED` by the instruction.
943
+ */
944
+ ZydisCPUFlags modified ;
945
+ /*
946
+ * As mask containing the CPU flags `SET_0` by the instruction.
947
+ */
948
+ ZydisCPUFlags set_0 ;
949
+ /*
950
+ * As mask containing the CPU flags `SET_1` by the instruction.
1036
951
*/
1037
- ZydisCPUFlagAction action ;
1038
- } accessed_flags [ZYDIS_CPUFLAG_MAX_VALUE + 1 ];
952
+ ZydisCPUFlags set_1 ;
953
+ /*
954
+ * As mask containing the CPU flags `SET_0` by the instruction.
955
+ */
956
+ ZydisCPUFlags undefined ;
957
+ } cpu_flags ;
1039
958
/**
1040
959
* A mask containing the CPU flags read by the instruction.
1041
960
*
1042
961
* The bits in this mask correspond to the actual bits in the `FLAGS/EFLAGS/RFLAGS`
1043
962
* register.
1044
963
*
1045
964
* This mask includes the actions `TESTED` and `TESTED_MODIFIED`.
965
+ *
966
+ * DEPRECATED. Use the masks inside of `cpu_flags` instead.
1046
967
*/
1047
- ZydisCPUFlags cpu_flags_read ;
968
+ ZydisCPUFlags cpu_flags_read ; // TODO: Remove in next version
1048
969
/**
1049
970
* A mask containing the CPU flags written by the instruction.
1050
971
*
1051
972
* The bits in this mask correspond to the actual bits in the `FLAGS/EFLAGS/RFLAGS`
1052
973
* register.
1053
974
*
1054
975
* This mask includes the actions `TESTED_MODIFIED`, `SET_0`, `SET_1` and `UNDEFINED`.
976
+ *
977
+ * DEPRECATED. Use the masks inside of `cpu_flags` instead.
1055
978
*/
1056
- ZydisCPUFlags cpu_flags_written ;
979
+ ZydisCPUFlags cpu_flags_written ; // TODO: Remove in next version
1057
980
/**
1058
981
* A mask containing the FPU flags read by the instruction.
1059
982
*/
0 commit comments