Changeset 41795 in vbox
- Timestamp:
- Jun 17, 2012 1:15:06 AM (13 years ago)
- svn:sync-xref-src-repo-rev:
- 78613
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/DisasmCore.cpp
r41794 r41795 517 517 //***************************************************************************** 518 518 //***************************************************************************** 519 static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, size_t cbExtra) 520 { 521 size_t size = 0; 522 519 static size_t disParseInstruction(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis) 520 { 523 521 Assert(pOp); Assert(pDis); 524 522 … … 568 566 if (pOp->idxParse1 != IDX_ParseNop) 569 567 { 570 size += pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, pDis, &pDis->Param1);568 offInstr = pDis->pfnDisasmFnTable[pOp->idxParse1](offInstr, pOp, pDis, &pDis->Param1); 571 569 if (fFiltered == false) pDis->Param1.cb = DISGetParamSize(pDis, &pDis->Param1); 572 570 } … … 574 572 if (pOp->idxParse2 != IDX_ParseNop) 575 573 { 576 size += pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr+size, pOp, pDis, &pDis->Param2);574 offInstr = pDis->pfnDisasmFnTable[pOp->idxParse2](offInstr, pOp, pDis, &pDis->Param2); 577 575 if (fFiltered == false) pDis->Param2.cb = DISGetParamSize(pDis, &pDis->Param2); 578 576 } … … 580 578 if (pOp->idxParse3 != IDX_ParseNop) 581 579 { 582 size += pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr+size, pOp, pDis, &pDis->Param3);580 offInstr = pDis->pfnDisasmFnTable[pOp->idxParse3](offInstr, pOp, pDis, &pDis->Param3); 583 581 if (fFiltered == false) pDis->Param3.cb = DISGetParamSize(pDis, &pDis->Param3); 584 582 } 585 583 // else simple one byte instruction 586 584 587 return size + cbExtra;585 return offInstr; 588 586 } 589 587 //***************************************************************************** … … 635 633 636 634 // Little hack to make sure the ModRM byte is included in the returned size 637 size_t size = 0;638 635 if (fpop->idxParse1 != IDX_ParseModRM && fpop->idxParse2 != IDX_ParseModRM) 639 size = sizeof(uint8_t); //ModRM byte636 offInstr++; //ModRM byte 640 637 641 638 if (fpop->idxParse1 != IDX_ParseNop) 642 size += pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr+size, fpop, pDis, pParam);639 offInstr = pDis->pfnDisasmFnTable[fpop->idxParse1](offInstr, fpop, pDis, pParam); 643 640 644 641 if (fpop->idxParse2 != IDX_ParseNop) 645 size += pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr+size, fpop, pDis, pParam);646 647 return size;642 offInstr = pDis->pfnDisasmFnTable[fpop->idxParse2](offInstr, fpop, pDis, pParam); 643 644 return offInstr; 648 645 } 649 646 … … 707 704 static size_t ParseSIB(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 708 705 { 709 unsigned size = sizeof(uint8_t);710 706 NOREF(pOp); NOREF(pParam); 711 707 712 u nsignedSIB = disReadByte(pDis, offInstr);713 offInstr += size;708 uint8_t SIB = disReadByte(pDis, offInstr); 709 offInstr++; 714 710 715 711 pDis->SIB.Bits.Base = SIB_BASE(SIB); … … 731 727 /* Additional 32 bits displacement. No change in long mode. */ 732 728 pDis->i32SibDisp = disReadDWord(pDis, offInstr); 733 size += sizeof(int32_t);734 } 735 return size;729 offInstr += 4; 730 } 731 return offInstr; 736 732 } 737 733 … … 739 735 static size_t ParseSIB_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 740 736 { 741 unsigned size = sizeof(uint8_t);742 737 NOREF(pOp); NOREF(pParam); 743 738 744 unsigned SIB = disReadByte(pDis, offInstr); 739 uint8_t SIB = disReadByte(pDis, offInstr); 740 offInstr++; 745 741 746 742 pDis->SIB.Bits.Base = SIB_BASE(SIB); … … 760 756 { 761 757 /* Additional 32 bits displacement. No change in long mode. */ 762 size += sizeof(int32_t);763 } 764 return size;758 offInstr += 4; 759 } 760 return offInstr; 765 761 } 766 762 … … 886 882 { 887 883 unsigned vtype = OP_PARM_VTYPE(pParam->fParam); 888 u nsignedreg = pDis->ModRM.Bits.Reg;889 u nsignedmod = pDis->ModRM.Bits.Mod;890 u nsignedrm = pDis->ModRM.Bits.Rm;884 uint8_t reg = pDis->ModRM.Bits.Reg; 885 uint8_t mod = pDis->ModRM.Bits.Mod; 886 uint8_t rm = pDis->ModRM.Bits.Rm; 891 887 892 888 switch (vtype) … … 894 890 case OP_PARM_G: //general purpose register 895 891 disasmModRMReg(reg, pOp, pDis, pParam, 0); 896 return 0;892 return offInstr; 897 893 898 894 default: … … 913 909 else 914 910 pParam->Base.idxCtrlReg = reg; 915 return 0;911 return offInstr; 916 912 917 913 case OP_PARM_D: //debug register 918 914 pParam->fUse |= DISUSE_REG_DBG; 919 915 pParam->Base.idxDbgReg = reg; 920 return 0;916 return offInstr; 921 917 922 918 case OP_PARM_P: //MMX register … … 924 920 pParam->fUse |= DISUSE_REG_MMX; 925 921 pParam->Base.idxMmxReg = reg; 926 return 0;922 return offInstr; 927 923 928 924 case OP_PARM_S: //segment register … … 930 926 disasmModRMSReg(reg, pOp, pDis, pParam); 931 927 pParam->fUse |= DISUSE_REG_SEG; 932 return 0;928 return offInstr; 933 929 934 930 case OP_PARM_T: //test register … … 936 932 pParam->fUse |= DISUSE_REG_TEST; 937 933 pParam->Base.idxTestReg = reg; 938 return 0;934 return offInstr; 939 935 940 936 case OP_PARM_W: //XMM register or memory operand … … 947 943 pParam->fUse |= DISUSE_REG_XMM; 948 944 pParam->Base.idxXmmReg = reg; 949 return 0;945 return offInstr; 950 946 } 951 947 } 952 948 } 953 949 954 /* @todo bound */950 /** @todo bound */ 955 951 956 952 if (pDis->uAddrMode != DISCPUMODE_16BIT) … … 1051 1047 } 1052 1048 } 1053 return 0; //everything was already fetched in ParseModRM1049 return offInstr; 1054 1050 } 1055 1051 //***************************************************************************** 1056 1052 // Query the size of the ModRM parameters and fetch the immediate data (if any) 1057 1053 //***************************************************************************** 1058 static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc) 1059 { 1060 size_t sibinc; 1061 size_t size = 0; 1062 // unsigned reg = pDis->ModRM.Bits.Reg; 1063 unsigned mod = pDis->ModRM.Bits.Mod; 1064 unsigned rm = pDis->ModRM.Bits.Rm; 1065 1066 if (!pSibInc) 1067 pSibInc = &sibinc; 1068 1069 *pSibInc = 0; 1054 static size_t QueryModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1055 { 1056 uint8_t mod = pDis->ModRM.Bits.Mod; 1057 uint8_t rm = pDis->ModRM.Bits.Rm; 1070 1058 1071 1059 if (pDis->uAddrMode != DISCPUMODE_16BIT) … … 1076 1064 * Note: displacements in long mode are 8 or 32 bits and sign-extended to 64 bits 1077 1065 */ 1078 if (mod != 3 && rm == 4) 1079 { /* SIB byte follows ModRM */ 1080 *pSibInc = ParseSIB(offInstr, pOp, pDis, pParam); 1081 offInstr += *pSibInc; 1082 size += *pSibInc; 1083 } 1066 if (mod != 3 && rm == 4) /* SIB byte follows ModRM */ 1067 offInstr = ParseSIB(offInstr, pOp, pDis, pParam); 1084 1068 1085 1069 switch (mod) 1086 1070 { 1087 1071 case 0: /* Effective address */ 1088 if (rm == 5) { /* 32 bits displacement */ 1072 if (rm == 5) /* 32 bits displacement */ 1073 { 1089 1074 pDis->i32SibDisp = disReadDWord(pDis, offInstr); 1090 size += sizeof(int32_t);1075 offInstr += 4; 1091 1076 } 1092 1077 /* else register address */ … … 1095 1080 case 1: /* Effective address + 8 bits displacement */ 1096 1081 pDis->i32SibDisp = (int8_t)disReadByte(pDis, offInstr); 1097 size += sizeof(char);1082 offInstr++; 1098 1083 break; 1099 1084 1100 1085 case 2: /* Effective address + 32 bits displacement */ 1101 1086 pDis->i32SibDisp = disReadDWord(pDis, offInstr); 1102 size += sizeof(int32_t);1087 offInstr += 4; 1103 1088 break; 1104 1089 … … 1113 1098 { 1114 1099 case 0: /* Effective address */ 1115 if (rm == 6) { 1100 if (rm == 6) 1101 { 1116 1102 pDis->i32SibDisp = disReadWord(pDis, offInstr); 1117 size += sizeof(uint16_t);1103 offInstr += 2; 1118 1104 } 1119 1105 /* else register address */ … … 1122 1108 case 1: /* Effective address + 8 bits displacement */ 1123 1109 pDis->i32SibDisp = (int8_t)disReadByte(pDis, offInstr); 1124 size += sizeof(char);1110 offInstr++; 1125 1111 break; 1126 1112 1127 1113 case 2: /* Effective address + 32 bits displacement */ 1128 1114 pDis->i32SibDisp = (int16_t)disReadWord(pDis, offInstr); 1129 size += sizeof(uint16_t);1115 offInstr += 2; 1130 1116 break; 1131 1117 … … 1134 1120 } 1135 1121 } 1136 return size; 1137 } 1138 //***************************************************************************** 1139 // Query the size of the ModRM parameters and fetch the immediate data (if any) 1140 //***************************************************************************** 1141 static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam, size_t *pSibInc) 1142 { 1143 size_t sibinc; 1144 size_t size = 0; 1145 // unsigned reg = pDis->ModRM.Bits.Reg; 1146 unsigned mod = pDis->ModRM.Bits.Mod; 1147 unsigned rm = pDis->ModRM.Bits.Rm; 1148 1149 if (!pSibInc) 1150 pSibInc = &sibinc; 1151 1152 *pSibInc = 0; 1122 return offInstr; 1123 } 1124 //***************************************************************************** 1125 // Parse the ModRM parameters and fetch the immediate data (if any) 1126 //***************************************************************************** 1127 static size_t QueryModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1128 { 1129 uint8_t mod = pDis->ModRM.Bits.Mod; 1130 uint8_t rm = pDis->ModRM.Bits.Rm; 1153 1131 1154 1132 if (pDis->uAddrMode != DISCPUMODE_16BIT) … … 1160 1138 if (mod != 3 && rm == 4) 1161 1139 { /* SIB byte follows ModRM */ 1162 *pSibInc = ParseSIB_SizeOnly(offInstr, pOp, pDis, pParam); 1163 offInstr += *pSibInc; 1164 size += *pSibInc; 1140 offInstr = ParseSIB_SizeOnly(offInstr, pOp, pDis, pParam); 1165 1141 } 1166 1142 … … 1168 1144 { 1169 1145 case 0: //effective address 1170 if (rm == 5) { /* 32 bits displacement */ 1171 size += sizeof(int32_t); 1172 } 1146 if (rm == 5) /* 32 bits displacement */ 1147 offInstr += 4; 1173 1148 /* else register address */ 1174 1149 break; 1175 1150 1176 1151 case 1: /* Effective address + 8 bits displacement */ 1177 size += sizeof(char);1152 offInstr += 1; 1178 1153 break; 1179 1154 1180 1155 case 2: /* Effective address + 32 bits displacement */ 1181 size += sizeof(int32_t);1156 offInstr += 4; 1182 1157 break; 1183 1158 … … 1192 1167 { 1193 1168 case 0: //effective address 1194 if (rm == 6) { 1195 size += sizeof(uint16_t); 1196 } 1169 if (rm == 6) 1170 offInstr += 2; 1197 1171 /* else register address */ 1198 1172 break; 1199 1173 1200 1174 case 1: /* Effective address + 8 bits displacement */ 1201 size += sizeof(char);1175 offInstr++; 1202 1176 break; 1203 1177 1204 1178 case 2: /* Effective address + 32 bits displacement */ 1205 size += sizeof(uint16_t);1179 offInstr += 2; 1206 1180 break; 1207 1181 … … 1210 1184 } 1211 1185 } 1212 return size;1186 return offInstr; 1213 1187 } 1214 1188 //***************************************************************************** … … 1216 1190 static size_t ParseIllegal(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1217 1191 { 1218 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1192 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1219 1193 AssertFailed(); 1220 return 0;1194 return offInstr; 1221 1195 } 1222 1196 //***************************************************************************** … … 1224 1198 static size_t ParseModRM(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1225 1199 { 1226 size_t size = sizeof(uint8_t); //ModRM byte 1227 size_t sibinc; 1228 1229 unsigned ModRM = disReadByte(pDis, offInstr); 1230 offInstr += sizeof(uint8_t); 1200 uint8_t ModRM = disReadByte(pDis, offInstr); 1201 offInstr++; 1231 1202 1232 1203 pDis->ModRM.Bits.Rm = MODRM_RM(ModRM); … … 1260 1231 } 1261 1232 } 1262 size += QueryModRM(offInstr, pOp, pDis, pParam, &sibinc); 1263 offInstr += sibinc; 1264 1265 UseModRM(offInstr, pOp, pDis, pParam); 1266 return size; 1233 offInstr = QueryModRM(offInstr, pOp, pDis, pParam); 1234 1235 return UseModRM(offInstr, pOp, pDis, pParam); 1267 1236 } 1268 1237 //***************************************************************************** … … 1270 1239 static size_t ParseModRM_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1271 1240 { 1272 size_t size = sizeof(uint8_t); //ModRM byte 1273 size_t sibinc; 1274 1275 unsigned ModRM = disReadByte(pDis, offInstr); 1276 offInstr += sizeof(uint8_t); 1241 uint8_t ModRM = disReadByte(pDis, offInstr); 1242 offInstr++; 1277 1243 1278 1244 pDis->ModRM.Bits.Rm = MODRM_RM(ModRM); … … 1307 1273 } 1308 1274 1309 size += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam, &sibinc); 1310 offInstr += sibinc; 1275 offInstr += QueryModRM_SizeOnly(offInstr, pOp, pDis, pParam); 1311 1276 1312 1277 /* UseModRM is not necessary here; we're only interested in the opcode size */ 1313 return size;1278 return offInstr; 1314 1279 } 1315 1280 //***************************************************************************** … … 1319 1284 ////AssertMsgFailed(("??\n")); 1320 1285 //nothing to do apparently 1321 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1322 return 0;1286 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1287 return offInstr; 1323 1288 } 1324 1289 //***************************************************************************** … … 1330 1295 pParam->fUse |= DISUSE_IMMEDIATE8; 1331 1296 pParam->cb = sizeof(uint8_t); 1332 return sizeof(uint8_t);1297 return offInstr + 1; 1333 1298 } 1334 1299 //***************************************************************************** … … 1336 1301 static size_t ParseImmByte_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1337 1302 { 1338 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1339 return sizeof(uint8_t);1303 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1304 return offInstr + 1; 1340 1305 } 1341 1306 //***************************************************************************** … … 1363 1328 pParam->cb = sizeof(uint16_t); 1364 1329 } 1365 return sizeof(uint8_t);1330 return offInstr + 1; 1366 1331 } 1367 1332 //***************************************************************************** … … 1369 1334 static size_t ParseImmByteSX_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1370 1335 { 1371 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1372 return sizeof(uint8_t);1336 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1337 return offInstr + 1; 1373 1338 } 1374 1339 //***************************************************************************** … … 1380 1345 pParam->fUse |= DISUSE_IMMEDIATE16; 1381 1346 pParam->cb = sizeof(uint16_t); 1382 return sizeof(uint16_t);1347 return offInstr + 2; 1383 1348 } 1384 1349 //***************************************************************************** … … 1386 1351 static size_t ParseImmUshort_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1387 1352 { 1388 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1389 return sizeof(uint16_t);1353 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1354 return offInstr + 2; 1390 1355 } 1391 1356 //***************************************************************************** … … 1397 1362 pParam->fUse |= DISUSE_IMMEDIATE32; 1398 1363 pParam->cb = sizeof(uint32_t); 1399 return sizeof(uint32_t);1364 return offInstr + 4; 1400 1365 } 1401 1366 //***************************************************************************** … … 1403 1368 static size_t ParseImmUlong_SizeOnly(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1404 1369 { 1405 NOREF( offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis);1406 return sizeof(uint32_t);1370 NOREF(pOp); NOREF(pParam); NOREF(pDis); 1371 return offInstr + 4; 1407 1372 } 1408 1373 //***************************************************************************** … … 1414 1379 pParam->fUse |= DISUSE_IMMEDIATE64; 1415 1380 pParam->cb = sizeof(uint64_t); 1416 return sizeof(uint64_t);1381 return offInstr + 8; 1417 1382 } 1418 1383 //***************************************************************************** … … 1421 1386 { 1422 1387 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis); 1423 return sizeof(uint64_t);1388 return offInstr + 8; 1424 1389 } 1425 1390 //***************************************************************************** … … 1433 1398 pParam->fUse |= DISUSE_IMMEDIATE32; 1434 1399 pParam->cb = sizeof(uint32_t); 1435 return sizeof(uint32_t);1400 return offInstr + 4; 1436 1401 } 1437 1402 … … 1441 1406 pParam->fUse |= DISUSE_IMMEDIATE64; 1442 1407 pParam->cb = sizeof(uint64_t); 1443 return sizeof(uint64_t);1408 return offInstr + 8; 1444 1409 } 1445 1410 … … 1447 1412 pParam->fUse |= DISUSE_IMMEDIATE16; 1448 1413 pParam->cb = sizeof(uint16_t); 1449 return sizeof(uint16_t);1414 return offInstr + 2; 1450 1415 } 1451 1416 //***************************************************************************** … … 1455 1420 NOREF(offInstr); NOREF(pOp); NOREF(pParam); 1456 1421 if (pDis->uOpMode == DISCPUMODE_32BIT) 1457 return sizeof(uint32_t);1422 return offInstr + 4; 1458 1423 if (pDis->uOpMode == DISCPUMODE_64BIT) 1459 return sizeof(uint64_t);1460 return sizeof(uint16_t);1424 return offInstr + 8; 1425 return offInstr + 2; 1461 1426 } 1462 1427 //***************************************************************************** … … 1471 1436 pParam->fUse |= DISUSE_IMMEDIATE16; 1472 1437 pParam->cb = sizeof(uint16_t); 1473 return sizeof(uint16_t);1438 return offInstr + 2; 1474 1439 } 1475 1440 … … 1487 1452 pParam->cb = sizeof(uint32_t); 1488 1453 } 1489 return sizeof(uint32_t);1454 return offInstr + 4; 1490 1455 } 1491 1456 //***************************************************************************** … … 1497 1462 if (pDis->uOpMode == DISCPUMODE_16BIT) 1498 1463 return sizeof(uint16_t); 1499 return sizeof(uint32_t);1464 return offInstr + 4; 1500 1465 } 1501 1466 … … 1509 1474 pParam->fUse |= DISUSE_IMMEDIATE8_REL; 1510 1475 pParam->cb = sizeof(uint8_t); 1511 return sizeof(char);1476 return offInstr + 1; 1512 1477 } 1513 1478 //***************************************************************************** … … 1517 1482 { 1518 1483 NOREF(offInstr); NOREF(pOp); NOREF(pParam); NOREF(pDis); 1519 return sizeof(char);1484 return offInstr + 1; 1520 1485 } 1521 1486 //***************************************************************************** … … 1530 1495 pParam->fUse |= DISUSE_IMMEDIATE32_REL; 1531 1496 pParam->cb = sizeof(int32_t); 1532 return sizeof(int32_t);1497 return offInstr + 4; 1533 1498 } 1534 1499 … … 1539 1504 pParam->fUse |= DISUSE_IMMEDIATE64_REL; 1540 1505 pParam->cb = sizeof(int64_t); 1541 return sizeof(int32_t);1506 return offInstr + 4; 1542 1507 } 1543 1508 … … 1545 1510 pParam->fUse |= DISUSE_IMMEDIATE16_REL; 1546 1511 pParam->cb = sizeof(int16_t); 1547 return sizeof(int16_t);1512 return offInstr + 2; 1548 1513 } 1549 1514 //***************************************************************************** … … 1554 1519 NOREF(offInstr); NOREF(pOp); NOREF(pParam); 1555 1520 if (pDis->uOpMode == DISCPUMODE_16BIT) 1556 return sizeof(int16_t);1521 return offInstr + 2; 1557 1522 /* Both 32 & 64 bits mode use 32 bits relative immediates. */ 1558 return sizeof(int32_t);1523 return offInstr + 4; 1559 1524 } 1560 1525 //***************************************************************************** … … 1571 1536 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_32; 1572 1537 pParam->cb = sizeof(uint16_t) + sizeof(uint32_t); 1573 return sizeof(uint32_t) + sizeof(uint16_t);1538 return offInstr + 4 + 2; 1574 1539 } 1575 1540 … … 1583 1548 pParam->fUse |= DISUSE_DISPLACEMENT32; 1584 1549 pParam->cb = sizeof(uint32_t); 1585 return sizeof(uint32_t);1550 return offInstr + 4; 1586 1551 } 1587 1552 1588 1553 if (pDis->uAddrMode == DISCPUMODE_64BIT) 1589 1554 { 1590 Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p);1591 1555 /* 1592 1556 * near 64 bits pointer … … 1595 1559 * so we treat it like displacement. 1596 1560 */ 1561 Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p); 1597 1562 pParam->uDisp.i64 = disReadQWord(pDis, offInstr); 1598 1563 pParam->fUse |= DISUSE_DISPLACEMENT64; 1599 1564 pParam->cb = sizeof(uint64_t); 1600 return sizeof(uint64_t);1565 return offInstr + 8; 1601 1566 } 1602 1567 if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p) … … 1606 1571 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_16; 1607 1572 pParam->cb = 2*sizeof(uint16_t); 1608 return sizeof(uint32_t);1573 return offInstr + 4; 1609 1574 } 1610 1575 … … 1618 1583 pParam->fUse |= DISUSE_DISPLACEMENT16; 1619 1584 pParam->cb = sizeof(uint16_t); 1620 return sizeof(uint16_t);1585 return offInstr + 2; 1621 1586 } 1622 1587 //***************************************************************************** … … 1628 1593 { 1629 1594 if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p) 1630 {// far 16:32 pointer 1631 return sizeof(uint32_t) + sizeof(uint16_t); 1632 } 1633 else 1634 {// near 32 bits pointer 1635 return sizeof(uint32_t); 1636 } 1595 return offInstr + 4 + 2; /* far 16:32 pointer */ 1596 return offInstr + 4; /* near 32 bits pointer */ 1637 1597 } 1638 1598 if (pDis->uAddrMode == DISCPUMODE_64BIT) 1639 1599 { 1640 1600 Assert(OP_PARM_VSUBTYPE(pParam->fParam) != OP_PARM_p); 1641 return sizeof(uint64_t); 1642 } 1643 else 1644 { 1645 if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p) 1646 {// far 16:16 pointer 1647 return sizeof(uint32_t); 1648 } 1649 else 1650 {// near 16 bits pointer 1651 return sizeof(uint16_t); 1652 } 1653 } 1601 return offInstr + 8; 1602 } 1603 if (OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p) 1604 return offInstr + 4; /* far 16:16 pointer */ 1605 return offInstr + 2; /* near 16 bits pointer */ 1654 1606 } 1655 1607 //***************************************************************************** … … 1667 1619 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_32; 1668 1620 pParam->cb = sizeof(uint16_t) + sizeof(uint32_t); 1669 return sizeof(uint32_t) + sizeof(uint16_t);1621 return offInstr + 4 + 2; 1670 1622 } 1671 1623 … … 1674 1626 pParam->fUse |= DISUSE_IMMEDIATE_ADDR_16_16; 1675 1627 pParam->cb = 2*sizeof(uint16_t); 1676 return sizeof(uint32_t);1628 return offInstr + 2 + 2; 1677 1629 } 1678 1630 //***************************************************************************** … … 1685 1637 Assert(OP_PARM_VSUBTYPE(pParam->fParam) == OP_PARM_p); 1686 1638 if (pDis->uOpMode == DISCPUMODE_32BIT) 1687 { 1688 // far 16:32 pointer 1689 return sizeof(uint32_t) + sizeof(uint16_t); 1690 } 1691 else 1692 { 1693 // far 16:16 pointer 1694 return sizeof(uint32_t); 1695 } 1639 return offInstr + 4 + 2; /* far 16:32 pointer */ 1640 return offInstr + 2 + 2; /* far 16:16 pointer */ 1696 1641 } 1697 1642 //***************************************************************************** … … 1708 1653 { 1709 1654 /* No parameter at all. */ 1710 return 0;1655 return offInstr; 1711 1656 } 1712 1657 … … 1794 1739 /* else - not supported for now registers. */ 1795 1740 1796 return 0;1741 return offInstr; 1797 1742 } 1798 1743 //***************************************************************************** … … 1800 1745 static size_t ParseXv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1801 1746 { 1802 NOREF( offInstr);1747 NOREF(pOp); 1803 1748 1804 1749 pParam->fUse |= DISUSE_POINTER_DS_BASED; … … 1819 1764 pParam->fUse |= DISUSE_REG_GEN16; 1820 1765 } 1821 return 0; //no additional opcode bytes1766 return offInstr; 1822 1767 } 1823 1768 //***************************************************************************** … … 1825 1770 static size_t ParseXb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1826 1771 { 1827 NOREF( offInstr); NOREF(pOp);1772 NOREF(pOp); 1828 1773 1829 1774 pParam->fUse |= DISUSE_POINTER_DS_BASED; … … 1844 1789 pParam->fUse |= DISUSE_REG_GEN16; 1845 1790 } 1846 return 0; //no additional opcode bytes1791 return offInstr; 1847 1792 } 1848 1793 //***************************************************************************** … … 1850 1795 static size_t ParseYv(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1851 1796 { 1852 NOREF( offInstr);1797 NOREF(pOp); 1853 1798 1854 1799 pParam->fUse |= DISUSE_POINTER_ES_BASED; … … 1869 1814 pParam->fUse |= DISUSE_REG_GEN16; 1870 1815 } 1871 return 0; //no additional opcode bytes1816 return offInstr; 1872 1817 } 1873 1818 //***************************************************************************** … … 1875 1820 static size_t ParseYb(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1876 1821 { 1877 NOREF( offInstr); NOREF(pOp);1822 NOREF(pOp); 1878 1823 1879 1824 pParam->fUse |= DISUSE_POINTER_ES_BASED; … … 1894 1839 pParam->fUse |= DISUSE_REG_GEN16; 1895 1840 } 1896 return 0; //no additional opcode bytes1841 return offInstr; 1897 1842 } 1898 1843 //***************************************************************************** … … 1900 1845 static size_t ParseTwoByteEsc(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1901 1846 { 1902 PCDISOPCODE pOpcode;1903 size_t size = sizeof(uint8_t);1904 1847 NOREF(pOp); NOREF(pParam); 1905 1848 1906 1849 /* 2nd byte */ 1907 1850 pDis->bOpCode = disReadByte(pDis, offInstr); 1851 offInstr++; 1908 1852 1909 1853 /* default to the non-prefixed table. */ 1910 pOpcode= &g_aTwoByteMapX86[pDis->bOpCode];1854 PCDISOPCODE pOpcode = &g_aTwoByteMapX86[pDis->bOpCode]; 1911 1855 1912 1856 /* Handle opcode table extensions that rely on the address, repe or repne prefix byte. */ … … 1952 1896 } 1953 1897 1954 return disParseInstruction(offInstr +size, pOpcode, pDis, size);1898 return disParseInstruction(offInstr, pOpcode, pDis); 1955 1899 } 1956 1900 //***************************************************************************** … … 1958 1902 static size_t ParseThreeByteEsc4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 1959 1903 { 1960 PCDISOPCODE pOpcode;1961 size_t size = sizeof(uint8_t);1962 1904 NOREF(pOp); NOREF(pParam); 1963 1905 1964 1906 /* 3rd byte */ 1965 1907 pDis->bOpCode = disReadByte(pDis, offInstr); 1908 offInstr++; 1966 1909 1967 1910 /* default to the non-prefixed table. */ 1911 PCDISOPCODE pOpcode; 1968 1912 if (g_apThreeByteMapX86_0F38[pDis->bOpCode >> 4]) 1969 1913 { … … 2012 1956 } 2013 1957 2014 return disParseInstruction(offInstr +size, pOpcode, pDis, size);1958 return disParseInstruction(offInstr, pOpcode, pDis); 2015 1959 } 2016 1960 //***************************************************************************** … … 2018 1962 static size_t ParseThreeByteEsc5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2019 1963 { 2020 PCDISOPCODE pOpcode;2021 size_t size = sizeof(uint8_t);2022 1964 NOREF(pOp); NOREF(pParam); 2023 1965 2024 1966 /* 3rd byte */ 2025 1967 pDis->bOpCode = disReadByte(pDis, offInstr); 1968 offInstr++; 2026 1969 2027 1970 /** @todo Should we take the first or last prefix byte in case of multiple prefix bytes??? */ … … 2029 1972 2030 1973 /* default to the non-prefixed table. */ 1974 PCDISOPCODE pOpcode; 2031 1975 if (g_apThreeByteMapX86_660F3A[pDis->bOpCode >> 4]) 2032 1976 { … … 2046 1990 pOpcode = &g_InvalidOpcode[0]; 2047 1991 2048 return disParseInstruction(offInstr +size, pOpcode, pDis, size);1992 return disParseInstruction(offInstr, pOpcode, pDis); 2049 1993 } 2050 1994 //***************************************************************************** … … 2052 1996 static size_t ParseNopPause(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2053 1997 { 2054 size_t size = 0;2055 1998 NOREF(pParam); 2056 1999 … … 2063 2006 pOp = &g_aMapX86_NopPause[0]; /* NOP */ 2064 2007 2065 return disParseInstruction(offInstr, pOp, pDis , size);2008 return disParseInstruction(offInstr, pOp, pDis); 2066 2009 } 2067 2010 //***************************************************************************** … … 2069 2012 static size_t ParseImmGrpl(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2070 2013 { 2071 int idx = (pDis->bOpCode - 0x80) * 8;2072 size_t size = 0;2073 2014 NOREF(pParam); 2074 2015 2075 unsigned modrm = disReadByte(pDis, offInstr); 2076 unsigned reg = MODRM_REG(modrm); 2016 uint8_t modrm = disReadByte(pDis, offInstr); 2017 uint8_t reg = MODRM_REG(modrm); 2018 unsigned idx = (pDis->bOpCode - 0x80) * 8; 2077 2019 2078 2020 pOp = &g_aMapX86_Group1[idx+reg]; 2079 2021 //little hack to make sure the ModRM byte is included in the returned size 2080 2022 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2081 size = sizeof(uint8_t); //ModRM byte2082 2083 return disParseInstruction(offInstr, pOp, pDis , size);2023 offInstr++; 2024 2025 return disParseInstruction(offInstr, pOp, pDis); 2084 2026 } 2085 2027 //***************************************************************************** … … 2087 2029 static size_t ParseShiftGrp2(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2088 2030 { 2089 int idx;2090 size_t size = 0;2091 2031 NOREF(pParam); 2092 2032 2033 unsigned idx; 2093 2034 switch (pDis->bOpCode) 2094 2035 { … … 2106 2047 2107 2048 default: 2108 AssertMsgFailed(("Oops\n")); 2109 return sizeof(uint8_t); 2110 } 2111 2112 unsigned modrm = disReadByte(pDis, offInstr); 2113 unsigned reg = MODRM_REG(modrm); 2049 Log(("ParseShiftGrp2: bOpCode=%#x\n", pDis->bOpCode)); 2050 pDis->rc = VERR_DIS_INVALID_OPCODE; 2051 return offInstr; 2052 } 2053 2054 uint8_t modrm = disReadByte(pDis, offInstr); 2055 uint8_t reg = MODRM_REG(modrm); 2114 2056 2115 2057 pOp = &g_aMapX86_Group2[idx+reg]; … … 2117 2059 //little hack to make sure the ModRM byte is included in the returned size 2118 2060 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2119 size = sizeof(uint8_t); //ModRM byte2120 2121 return disParseInstruction(offInstr, pOp, pDis , size);2061 offInstr++; 2062 2063 return disParseInstruction(offInstr, pOp, pDis); 2122 2064 } 2123 2065 //***************************************************************************** … … 2125 2067 static size_t ParseGrp3(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2126 2068 { 2127 int idx = (pDis->bOpCode - 0xF6) * 8; 2128 size_t size = 0; 2069 unsigned idx = (pDis->bOpCode - 0xF6) * 8; 2129 2070 NOREF(pParam); 2130 2071 2131 u nsignedmodrm = disReadByte(pDis, offInstr);2132 u nsignedreg = MODRM_REG(modrm);2072 uint8_t modrm = disReadByte(pDis, offInstr); 2073 uint8_t reg = MODRM_REG(modrm); 2133 2074 2134 2075 pOp = &g_aMapX86_Group3[idx+reg]; … … 2136 2077 //little hack to make sure the ModRM byte is included in the returned size 2137 2078 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2138 size = sizeof(uint8_t); //ModRM byte2139 2140 return disParseInstruction(offInstr, pOp, pDis , size);2079 offInstr++; 2080 2081 return disParseInstruction(offInstr, pOp, pDis); 2141 2082 } 2142 2083 //***************************************************************************** … … 2144 2085 static size_t ParseGrp4(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2145 2086 { 2146 size_t size = 0;2147 2087 NOREF(pParam); 2148 2088 2149 u nsignedmodrm = disReadByte(pDis, offInstr);2150 u nsignedreg = MODRM_REG(modrm);2089 uint8_t modrm = disReadByte(pDis, offInstr); 2090 uint8_t reg = MODRM_REG(modrm); 2151 2091 2152 2092 pOp = &g_aMapX86_Group4[reg]; … … 2154 2094 //little hack to make sure the ModRM byte is included in the returned size 2155 2095 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2156 size = sizeof(uint8_t); //ModRM byte2157 2158 return disParseInstruction(offInstr, pOp, pDis , size);2096 offInstr++; 2097 2098 return disParseInstruction(offInstr, pOp, pDis); 2159 2099 } 2160 2100 //***************************************************************************** … … 2162 2102 static size_t ParseGrp5(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2163 2103 { 2164 size_t size = 0;2165 2104 NOREF(pParam); 2166 2105 2167 u nsignedmodrm = disReadByte(pDis, offInstr);2168 u nsignedreg = MODRM_REG(modrm);2106 uint8_t modrm = disReadByte(pDis, offInstr); 2107 uint8_t reg = MODRM_REG(modrm); 2169 2108 2170 2109 pOp = &g_aMapX86_Group5[reg]; … … 2172 2111 //little hack to make sure the ModRM byte is included in the returned size 2173 2112 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2174 size = sizeof(uint8_t); //ModRM byte2175 2176 return disParseInstruction(offInstr, pOp, pDis , size);2113 offInstr++; 2114 2115 return disParseInstruction(offInstr, pOp, pDis); 2177 2116 } 2178 2117 //***************************************************************************** … … 2184 2123 static size_t Parse3DNow(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2185 2124 { 2186 size_t size = 0;2187 2188 2125 #ifdef DEBUG_Sander 2189 2126 //needs testing … … 2191 2128 #endif 2192 2129 2193 u nsignedModRM = disReadByte(pDis, offInstr);2130 uint8_t ModRM = disReadByte(pDis, offInstr); 2194 2131 pDis->ModRM.Bits.Rm = MODRM_RM(ModRM); 2195 2132 pDis->ModRM.Bits.Mod = MODRM_MOD(ModRM); 2196 2133 pDis->ModRM.Bits.Reg = MODRM_REG(ModRM); 2197 2134 2198 size_t modrmsize = QueryModRM(offInstr+sizeof(uint8_t), pOp, pDis, pParam, NULL);2199 2200 uint8_t opcode = disReadByte(pDis, off Instr+sizeof(uint8_t)+modrmsize);2201 2135 size_t offRet = QueryModRM(offInstr + 1, pOp, pDis, pParam); 2136 2137 uint8_t opcode = disReadByte(pDis, offRet); 2138 offRet++; 2202 2139 pOp = &g_aTwoByteMapX86_3DNow[opcode]; 2203 2140 2204 2141 //little hack to make sure the ModRM byte is included in the returned size 2205 2142 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2206 { 2207 #ifdef DEBUG_Sander /* bird, 2005-06-28: Alex is getting this during full installation of win2ksp4. */ 2208 AssertMsgFailed(("Oops!\n")); //shouldn't happen! 2209 #endif 2210 size = sizeof(uint8_t); //ModRM byte 2211 } 2212 2213 size += sizeof(uint8_t); //imm8_opcode uint8_t 2214 return disParseInstruction(offInstr, pOp, pDis, size); 2143 offInstr++; /* for illegal opcodes */ 2144 2145 size_t offStrict = disParseInstruction(offInstr, pOp, pDis); 2146 Assert(offStrict == offRet - 1); NOREF(offStrict); /* the imm8_opcode */ 2147 return offRet; 2215 2148 } 2216 2149 //***************************************************************************** … … 2218 2151 static size_t ParseGrp6(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2219 2152 { 2220 size_t size = 0;2221 2153 NOREF(pParam); 2222 2154 2223 u nsignedmodrm = disReadByte(pDis, offInstr);2224 u nsignedreg = MODRM_REG(modrm);2155 uint8_t modrm = disReadByte(pDis, offInstr); 2156 uint8_t reg = MODRM_REG(modrm); 2225 2157 2226 2158 pOp = &g_aMapX86_Group6[reg]; … … 2228 2160 //little hack to make sure the ModRM byte is included in the returned size 2229 2161 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2230 size = sizeof(uint8_t); //ModRM byte2231 2232 return disParseInstruction(offInstr, pOp, pDis , size);2162 offInstr++; 2163 2164 return disParseInstruction(offInstr, pOp, pDis); 2233 2165 } 2234 2166 //***************************************************************************** … … 2236 2168 static size_t ParseGrp7(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2237 2169 { 2238 size_t size = 0;2239 2170 NOREF(pParam); 2240 2171 2241 u nsignedmodrm = disReadByte(pDis, offInstr);2242 u nsignedmod = MODRM_MOD(modrm);2243 u nsignedreg = MODRM_REG(modrm);2244 u nsignedrm = MODRM_RM(modrm);2172 uint8_t modrm = disReadByte(pDis, offInstr); 2173 uint8_t mod = MODRM_MOD(modrm); 2174 uint8_t reg = MODRM_REG(modrm); 2175 uint8_t rm = MODRM_RM(modrm); 2245 2176 2246 2177 if (mod == 3 && rm == 0) … … 2254 2185 //little hack to make sure the ModRM byte is included in the returned size 2255 2186 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2256 size = sizeof(uint8_t); //ModRM byte2257 2258 return disParseInstruction(offInstr, pOp, pDis , size);2187 offInstr++; 2188 2189 return disParseInstruction(offInstr, pOp, pDis); 2259 2190 } 2260 2191 //***************************************************************************** … … 2262 2193 static size_t ParseGrp8(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2263 2194 { 2264 size_t size = 0;2265 2195 NOREF(pParam); 2266 2196 2267 u nsignedmodrm = disReadByte(pDis, offInstr);2268 u nsignedreg = MODRM_REG(modrm);2197 uint8_t modrm = disReadByte(pDis, offInstr); 2198 uint8_t reg = MODRM_REG(modrm); 2269 2199 2270 2200 pOp = &g_aMapX86_Group8[reg]; … … 2272 2202 //little hack to make sure the ModRM byte is included in the returned size 2273 2203 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2274 size = sizeof(uint8_t); //ModRM byte2275 2276 return disParseInstruction(offInstr, pOp, pDis , size);2204 offInstr++; 2205 2206 return disParseInstruction(offInstr, pOp, pDis); 2277 2207 } 2278 2208 //***************************************************************************** … … 2280 2210 static size_t ParseGrp9(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2281 2211 { 2282 size_t size = 0;2283 2212 NOREF(pParam); 2284 2213 2285 u nsignedmodrm = disReadByte(pDis, offInstr);2286 u nsignedreg = MODRM_REG(modrm);2214 uint8_t modrm = disReadByte(pDis, offInstr); 2215 uint8_t reg = MODRM_REG(modrm); 2287 2216 2288 2217 pOp = &g_aMapX86_Group9[reg]; … … 2290 2219 //little hack to make sure the ModRM byte is included in the returned size 2291 2220 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2292 size = sizeof(uint8_t); //ModRM byte2293 2294 return disParseInstruction(offInstr, pOp, pDis , size);2221 offInstr++; 2222 2223 return disParseInstruction(offInstr, pOp, pDis); 2295 2224 } 2296 2225 //***************************************************************************** … … 2298 2227 static size_t ParseGrp10(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2299 2228 { 2300 size_t size = 0;2301 2229 NOREF(pParam); 2302 2230 2303 u nsignedmodrm = disReadByte(pDis, offInstr);2304 u nsignedreg = MODRM_REG(modrm);2231 uint8_t modrm = disReadByte(pDis, offInstr); 2232 uint8_t reg = MODRM_REG(modrm); 2305 2233 2306 2234 pOp = &g_aMapX86_Group10[reg]; … … 2308 2236 //little hack to make sure the ModRM byte is included in the returned size 2309 2237 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2310 size = sizeof(uint8_t); //ModRM byte2311 2312 return disParseInstruction(offInstr, pOp, pDis , size);2238 offInstr++; 2239 2240 return disParseInstruction(offInstr, pOp, pDis); 2313 2241 } 2314 2242 //***************************************************************************** … … 2316 2244 static size_t ParseGrp12(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2317 2245 { 2318 size_t size = 0;2319 2246 NOREF(pParam); 2320 2247 2321 u nsignedmodrm = disReadByte(pDis, offInstr);2322 u nsignedreg = MODRM_REG(modrm);2248 uint8_t modrm = disReadByte(pDis, offInstr); 2249 uint8_t reg = MODRM_REG(modrm); 2323 2250 2324 2251 if (pDis->fPrefix & DISPREFIX_OPSIZE) … … 2329 2256 //little hack to make sure the ModRM byte is included in the returned size 2330 2257 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2331 size = sizeof(uint8_t); //ModRM byte2332 2333 return disParseInstruction(offInstr, pOp, pDis , size);2258 offInstr++; 2259 2260 return disParseInstruction(offInstr, pOp, pDis); 2334 2261 } 2335 2262 //***************************************************************************** 2336 2263 //***************************************************************************** 2337 2264 static size_t ParseGrp13(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2338 {2339 size_t size = 0;2340 NOREF(pParam);2341 2342 unsigned modrm = disReadByte(pDis, offInstr);2343 unsigned reg = MODRM_REG(modrm);2344 if (pDis->fPrefix & DISPREFIX_OPSIZE)2345 reg += 8; //2nd table2346 2347 pOp = &g_aMapX86_Group13[reg];2348 2349 //little hack to make sure the ModRM byte is included in the returned size2350 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)2351 size = sizeof(uint8_t); //ModRM byte2352 2353 return disParseInstruction(offInstr, pOp, pDis, size);2354 }2355 //*****************************************************************************2356 //*****************************************************************************2357 static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam)2358 2265 { 2359 2266 NOREF(pParam); … … 2364 2271 reg += 8; //2nd table 2365 2272 2273 pOp = &g_aMapX86_Group13[reg]; 2274 2275 //little hack to make sure the ModRM byte is included in the returned size 2276 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2277 offInstr++; 2278 2279 return disParseInstruction(offInstr, pOp, pDis); 2280 } 2281 //***************************************************************************** 2282 //***************************************************************************** 2283 static size_t ParseGrp14(size_t offInstr, PCDISOPCODE pOp, PDISSTATE pDis, PDISOPPARAM pParam) 2284 { 2285 NOREF(pParam); 2286 2287 uint8_t modrm = disReadByte(pDis, offInstr); 2288 uint8_t reg = MODRM_REG(modrm); 2289 if (pDis->fPrefix & DISPREFIX_OPSIZE) 2290 reg += 8; //2nd table 2291 2366 2292 pOp = &g_aMapX86_Group14[reg]; 2367 2293 … … 2369 2295 size_t size = 0; 2370 2296 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2371 size = sizeof(uint8_t); //ModRM byte2372 2373 return disParseInstruction(offInstr, pOp, pDis , size);2297 offInstr++; 2298 2299 return disParseInstruction(offInstr, pOp, pDis); 2374 2300 } 2375 2301 //***************************************************************************** … … 2392 2318 size_t size = 0; 2393 2319 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2394 size = sizeof(uint8_t); //ModRM byte2395 2396 return disParseInstruction(offInstr, pOp, pDis , size);2320 offInstr++; 2321 2322 return disParseInstruction(offInstr, pOp, pDis); 2397 2323 } 2398 2324 //***************************************************************************** … … 2406 2332 2407 2333 //little hack to make sure the ModRM byte is included in the returned size 2408 size_t size = 0;2409 2334 if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM) 2410 size = sizeof(uint8_t); //ModRM byte2411 2412 return disParseInstruction(offInstr, pOp, pDis , size);2335 offInstr++; 2336 2337 return disParseInstruction(offInstr, pOp, pDis); 2413 2338 } 2414 2339 … … 2594 2519 pDis->bOpCode = codebyte; 2595 2520 pDis->cbPrefix = (uint8_t)offInstr - 1; 2596 offInstr = disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis , offInstr);2521 offInstr = disParseInstruction(offInstr, &paOneByteMap[pDis->bOpCode], pDis); 2597 2522 break; 2598 2523 }
Note:
See TracChangeset
for help on using the changeset viewer.