KiTpEmulateInstruction
__int64 __fastcall KiTpEmulateInstruction(UINT8 *a1, _QWORD *a2){
int v2;
int InstructionBytes;
int v6;
CHAR v7;
CHAR v8;
CHAR v9;
INT64 v10;
INT64 *v11;
__int64 v12;
INT64 v13;
INT64 v14;
INT64 *v15;
__int64 v16;
INT64 v17;
INT64 *v18;
__int64 v19;
int v20;
INT64 v21;
INT64 v22;
int v23;
_DWORD *v24;
UINT64 v26;
INT64 v27;
__int64 v28[3];
__int64 v29;
CHAR v30;
__int64 v31;
INT64 v32;
v2 = a1[21];
v27 = 0i64;
v28[0] = 0i64;
v26 = 0i64;
LOBYTE(v31) = 0;
v30 = 0;
LOBYTE(v29) = 0;
LODWORD(v32) = v2;
InstructionBytes = KiTpFetchInstructionBytes((__int64)a1, &v31, 1, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( (v31 & 0xF0) == 80 )
{
v6 = KiTpEmulateRegisterPushPop((INT64)a1, (INT64)a2, v31);
goto LABEL_89;
}
if( (v31 & 0xF0) == 0xB0 )
{
v6 = KiTpEmulateMovRegImm((INT64)a1, (__int64)a2, v31, &v32);
goto LABEL_89;
}
if( (v31 & 0xC4) == 0 )
{
v6 = KiTpEmulateGroup0Instruction(a1, (INT64)a2, v31, &v32);
goto LABEL_89;
}
if( (unsigned __int8)v31 > 0x8Au )
{
if( (unsigned __int8)v31 > 0xC6u )
{
if( (unsigned __int8)v31 != 199 )
goto LABEL_77;
if( !a2 )
goto LABEL_87;
}
else
{
if( (unsigned __int8)v31 != 198 )
{
if( (unsigned __int8)v31 == 139 )
{
LABEL_59:
InstructionBytes = KiTpDecodeModRm(a1, (INT64)a2, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( !a2 )
goto LABEL_47;
KiTpDecodeModRmOperand((INT64)a1, (INT64)a2, (UINT64)&v26, (CHAR)&v30, (CHAR)&v29);
LOBYTE(v22) = v30;
InstructionBytes = KiTpReadOperandValue((INT64)a1, (INT64)a2, v26, v22, v29, (INT64)v28);
if( InstructionBytes < 0 )
goto LABEL_92;
v21 = v28[0];
goto LABEL_56;
}
if( (unsigned __int8)v31 == 141 )
{
InstructionBytes = KiTpDecodeModRm(a1, (INT64)a2, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( !a2 )
goto LABEL_47;
KiTpDecodeModRmOperand((INT64)a1, (INT64)a2, (UINT64)&v26, (CHAR)&v30, (CHAR)&v29);
if( (_BYTE)v29 )
{
v24 = (_DWORD *)*a2;
InstructionBytes = -1073741795;
v24[6] = 0;
*v24 = -1073741795;
goto LABEL_92;
}
v21 = v26;
LABEL_56:
KiTpWriteRegisterValue((INT64)a1, (INT64)a2, (a1[26] >> 3) & 7, (a1[25] & 4) != 0, v21);
goto LABEL_90;
}
if( (unsigned __int8)v31 != 144 )
{
if( (unsigned __int8)v31 == 194 )
{
if( a2 )
{
LABEL_74:
KiTpAccessMemory();
InstructionBytes = v23;
if( v23 >= 0 )
{
*(_QWORD *)(a2[1] + 248i64) = v27;
*(_QWORD *)(a2[1] + 152i64) += *((_QWORD *)a1 + 4) + 8i64;
InstructionBytes = 0;
}
goto LABEL_92;
}
InstructionBytes = KiTpFetchInstructionBytes((__int64)a1, a1 + 32, 2, &v32);
if( InstructionBytes < 0 )
return(unsigned int)InstructionBytes;
}
else if( (unsigned __int8)v31 != 195 )
{
goto LABEL_77;
}
if( !a2 )
goto LABEL_47;
goto LABEL_74;
}
if( (a1[25] & 1) == 0 )
goto LABEL_90;
LABEL_77:
InstructionBytes = -1073741637;
goto LABEL_92;
}
if( !a2 )
{
a1[1] = 8;
LABEL_87:
KiTpSetImmediateOperandSize((INT64)a1, 16, 32, 32);
}
}
v6 = KiTpEmulateGroup11Instruction((INT64)a1, (INT64)a2, &v32);
goto LABEL_89;
}
if( (unsigned __int8)v31 == 138 )
{
if( !a2 )
a1[1] = 8;
goto LABEL_59;
}
if( (unsigned __int8)v31 > 0x84u )
{
if( (unsigned __int8)v31 == 133 )
goto LABEL_33;
if( (unsigned __int8)v31 == 134 )
{
if( !a2 )
a1[1] = 8;
}
else if( (unsigned __int8)v31 != 135 )
{
if( (unsigned __int8)v31 == 136 )
{
if( !a2 )
a1[1] = 8;
}
else if( (unsigned __int8)v31 != 137 )
{
goto LABEL_77;
}
InstructionBytes = KiTpDecodeModRm(a1, (INT64)a2, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( a2 )
{
KiTpDecodeModRmOperand((INT64)a1, (INT64)a2, (UINT64)&v26, (CHAR)&v30, (CHAR)&v29);
LODWORD(v15) = KiTpGetRegisterAddressByIndex((INT64)a1, (INT64)a2, (a1[26] >> 3) & 7, (a1[25] & 4) != 0, 1);
LODWORD(v16) = KiTpSignExtendOperandValue((INT64)a1, *v15);
v28[0] = v16;
v31 = v16;
KiTpAccessMemory();
goto LABEL_89;
}
LABEL_47:
InstructionBytes = 0;
LABEL_94:
a1[24] = v32;
return(unsigned int)InstructionBytes;
}
InstructionBytes = KiTpDecodeModRm(a1, (INT64)a2, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( !a2 )
goto LABEL_47;
KiTpDecodeModRmOperand((INT64)a1, (INT64)a2, (UINT64)&v26, (CHAR)&v30, (CHAR)&v29);
LOBYTE(v17) = v30;
InstructionBytes = KiTpReadOperandValue((INT64)a1, (INT64)a2, v26, v17, v29, (INT64)&v27);
if( InstructionBytes >= 0 )
{
LODWORD(v18) = KiTpGetRegisterAddressByIndex((INT64)a1, (INT64)a2, (a1[26] >> 3) & 7, (a1[25] & 4) != 0, 1);
LODWORD(v19) = KiTpSignExtendOperandValue((INT64)a1, *v18);
v28[0] = v19;
v29 = v19;
KiTpAccessMemory();
InstructionBytes = v20;
if( v20 >= 0 )
{
v21 = v27;
goto LABEL_56;
}
}
LABEL_92:
if( a2 )
return(unsigned int)InstructionBytes;
goto LABEL_93;
}
if( (unsigned __int8)v31 == 132 )
{
if( !a2 )
a1[1] = 8;
LABEL_33:
InstructionBytes = KiTpDecodeModRm(a1, (INT64)a2, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( a2 )
{
KiTpDecodeModRmOperand((INT64)a1, (INT64)a2, (UINT64)&v26, (CHAR)&v30, (CHAR)&v29);
LOBYTE(v10) = v30;
InstructionBytes = KiTpReadOperandValue((INT64)a1, (INT64)a2, v26, v10, v29, (INT64)&v27);
if( InstructionBytes < 0 )
goto LABEL_92;
LODWORD(v11) = KiTpGetRegisterAddressByIndex((INT64)a1, (INT64)a2, (a1[26] >> 3) & 7, (a1[25] & 4) != 0, 1);
LODWORD(v12) = KiTpSignExtendOperandValue((INT64)a1, *v11);
v28[0] = v12;
v13 = v27 & v12;
*(_DWORD *)(a2[1] + 68i64) &= 0xFFFFF7FE;
KiTpSetFlagsZeroSignParity(v14, (INT64)a2, v13);
goto LABEL_90;
}
goto LABEL_47;
}
if( (unsigned __int8)v31 != 15 )
{
if( (unsigned __int8)v31 == 128 )
{
if( a2 )
goto LABEL_23;
a1[1] = 8;
}
else if( (unsigned __int8)v31 != 129 )
{
if( (unsigned __int8)v31 == 130 )
{
if( a2 )
goto LABEL_23;
a1[1] = 8;
}
else if( (unsigned __int8)v31 != 131 )
{
goto LABEL_77;
}
if( !a2 )
{
v7 = 8;
v8 = 8;
v9 = 8;
LABEL_22:
KiTpSetImmediateOperandSize((INT64)a1, v9, v8, v7);
}
LABEL_23:
v6 = KiTpEmulateGroup1Instruction((INT64)a1, (INT64)a2, &v32);
goto LABEL_89;
}
if( a2 )
goto LABEL_23;
v7 = 32;
v9 = 16;
v8 = 32;
goto LABEL_22;
}
InstructionBytes = KiTpFetchInstructionBytes((__int64)a1, &v31, 1, &v32);
if( InstructionBytes < 0 )
goto LABEL_92;
if( (unsigned __int8)(v31 + 74) > 1u )
goto LABEL_77;
v6 = KiTpEmulateMovzx(a1, (INT64)a2, 8 * ((v31 & 1) + 1), &v32);
LABEL_89:
InstructionBytes = v6;
if( v6 < 0 )
goto LABEL_92;
LABEL_90:
if( a2 )
{
*(_QWORD *)(a2[1] + 248i64) += a1[24];
goto LABEL_92;
}
LABEL_93:
if( InstructionBytes >= 0 )
goto LABEL_94;
return(unsigned int)InstructionBytes;
}Referenced by:
KiTpCompletion
KiTpHandleTrap
KiTpParseInstruction