@@ -721,59 +721,6 @@ static ZyanBool ZydisCheckAsz(ZydisEncoderInstructionMatch *match, ZydisRegister
721
721
return match -> easz == (ZyanU8 )reg_width ? ZYAN_TRUE : ZYAN_FALSE ;
722
722
}
723
723
724
- /**
725
- * Checks if opcode is allowed to use `REX2` prefix.
726
- *
727
- * @param match A pointer to `ZydisEncoderInstructionMatch` struct.
728
- *
729
- * @return True if `REX2` prefix can be used, false otherwise.
730
- */
731
- static ZyanBool ZydisIsRex2Allowed (ZydisEncoderInstructionMatch * match )
732
- {
733
- // TODO: Remove this function, use `no_rex2` filter
734
- const ZydisOpcodeMap opcode_map = match -> definition -> opcode_map ;
735
- if ((opcode_map != ZYDIS_OPCODE_MAP_DEFAULT ) &&
736
- (opcode_map != ZYDIS_OPCODE_MAP_0F ))
737
- {
738
- return ZYAN_FALSE ;
739
- }
740
- switch (match -> request -> mnemonic )
741
- {
742
- case ZYDIS_MNEMONIC_XRSTOR :
743
- case ZYDIS_MNEMONIC_XRSTOR64 :
744
- case ZYDIS_MNEMONIC_XRSTORS :
745
- case ZYDIS_MNEMONIC_XRSTORS64 :
746
- case ZYDIS_MNEMONIC_XSAVE :
747
- case ZYDIS_MNEMONIC_XSAVE64 :
748
- case ZYDIS_MNEMONIC_XSAVEC :
749
- case ZYDIS_MNEMONIC_XSAVEC64 :
750
- case ZYDIS_MNEMONIC_XSAVEOPT :
751
- case ZYDIS_MNEMONIC_XSAVEOPT64 :
752
- case ZYDIS_MNEMONIC_XSAVES :
753
- case ZYDIS_MNEMONIC_XSAVES64 :
754
- return ZYAN_FALSE ;
755
- default :
756
- break ;
757
- }
758
- static const ZyanBool is_rex2_allowed [2 ][16 ] =
759
- {
760
- {
761
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE ,
762
- ZYAN_FALSE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_FALSE ,
763
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_FALSE , ZYAN_TRUE ,
764
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_FALSE , ZYAN_TRUE ,
765
- },
766
- {
767
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_FALSE ,
768
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE ,
769
- ZYAN_FALSE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE ,
770
- ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE , ZYAN_TRUE ,
771
- },
772
- };
773
- const ZyanU8 row = (match -> definition -> opcode & 0xF0 ) >> 4 ;
774
- return is_rex2_allowed [opcode_map ][row ];
775
- }
776
-
777
724
/**
778
725
* Returns the id of the specified register as used in physical encoding.
779
726
*
@@ -833,7 +780,7 @@ static ZyanBool ZydisIsRegisterAllowed(ZydisEncoderInstructionMatch *match, Zydi
833
780
case ZYDIS_REGCLASS_GPR16 :
834
781
case ZYDIS_REGCLASS_GPR32 :
835
782
case ZYDIS_REGCLASS_GPR64 :
836
- return ZydisIsRex2Allowed (match ) ||
783
+ return (match -> definition -> rex2 != ZYDIS_REX2_TYPE_FORBIDDEN ) ||
837
784
(ZydisGetPhysicalId (reg , reg_class ) < 16 );
838
785
default :
839
786
return reg_id < 16 ;
@@ -989,8 +936,7 @@ static ZyanBool ZydisIsValidAddressingClass(ZydisEncoderInstructionMatch *match,
989
936
switch (match -> definition -> encoding )
990
937
{
991
938
case ZYDIS_INSTRUCTION_ENCODING_LEGACY :
992
- result &=
993
- ZydisIsRex2Allowed (match );
939
+ result &= (match -> definition -> rex2 != ZYDIS_REX2_TYPE_FORBIDDEN );
994
940
break ;
995
941
case ZYDIS_INSTRUCTION_ENCODING_EVEX :
996
942
break ;
@@ -4157,7 +4103,7 @@ static ZyanStatus ZydisBuildInstruction(ZydisEncoderInstructionMatch *match,
4157
4103
{
4158
4104
instruction -> attributes |= ZYDIS_ATTRIB_HAS_MODRM ;
4159
4105
}
4160
- if (match -> definition -> rex2 )
4106
+ if (match -> definition -> rex2 == ZYDIS_REX2_TYPE_MANDATORY )
4161
4107
{
4162
4108
instruction -> attributes |= ZYDIS_ATTRIB_HAS_REX2 ;
4163
4109
}
0 commit comments