Changeset 1155 in vbox
- Timestamp:
- Mar 2, 2007 1:45:13 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Disassembler/DisasmCore.cpp
r1150 r1155 52 52 #if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED) 53 53 static void disasmAddString(char *psz, const char *pszString); 54 static void disasmAddStringF(char *psz, const char *pszFormat, ...);54 static void disasmAddStringF(char *psz, uint32_t cbString, const char *pszFormat, ...); 55 55 static void disasmAddChar(char *psz, char ch); 56 56 #else … … 59 59 # define disasmAddStringF __noop 60 60 # else 61 # define disasmAddStringF(psz, pszFormat...) do {} while (0) /* Arg wanna get rid of that warning */61 # define disasmAddStringF(psz, cbString, pszFormat...) do {} while (0) /* Arg wanna get rid of that warning */ 62 62 # endif 63 63 # define disasmAddChar(psz, ch) do {} while (0) … … 990 990 991 991 if(base == 5 && MODRM_MOD(pCpu->ModRM) == 0) 992 disasmAddStringF(szTemp, "%s%s", szSIBIndexReg[index], szSIBScale[scale]);992 disasmAddStringF(szTemp, sizeof(szTemp), "%s%s", szSIBIndexReg[index], szSIBScale[scale]); 993 993 else 994 disasmAddStringF(szTemp, "%s+%s%s", szSIBBaseReg[base], szSIBIndexReg[index], szSIBScale[scale]);994 disasmAddStringF(szTemp, sizeof(szTemp), "%s+%s%s", szSIBBaseReg[base], szSIBIndexReg[index], szSIBScale[scale]); 995 995 } 996 996 else 997 997 { 998 998 if(base != 5 || MODRM_MOD(pCpu->ModRM) != 0) 999 disasmAddStringF(szTemp, "%s", szSIBBaseReg[base]);999 disasmAddStringF(szTemp, sizeof(szTemp), "%s", szSIBBaseReg[base]); 1000 1000 } 1001 1001 … … 1075 1075 { 1076 1076 case OP_PARM_C: //control register 1077 disasmAddStringF(pParam->szParam, "CR%d", reg);1077 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "CR%d", reg); 1078 1078 pParam->flags |= USE_REG_CR; 1079 1079 pParam->base.reg_ctrl = reg; … … 1081 1081 1082 1082 case OP_PARM_D: //debug register 1083 disasmAddStringF(pParam->szParam, "DR%d", reg);1083 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "DR%d", reg); 1084 1084 pParam->flags |= USE_REG_DBG; 1085 1085 pParam->base.reg_dbg = reg; … … 1087 1087 1088 1088 case OP_PARM_P: //MMX register 1089 disasmAddStringF(pParam->szParam, "MM%d", reg);1089 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "MM%d", reg); 1090 1090 pParam->flags |= USE_REG_MMX; 1091 1091 pParam->base.reg_mmx = reg; … … 1098 1098 1099 1099 case OP_PARM_T: //test register 1100 disasmAddStringF(pParam->szParam, "TR%d", reg);1100 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "TR%d", reg); 1101 1101 pParam->flags |= USE_REG_TEST; 1102 1102 pParam->base.reg_test = reg; … … 1104 1104 1105 1105 case OP_PARM_V: //XMM register 1106 disasmAddStringF(pParam->szParam, "XMM%d", reg);1106 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "XMM%d", reg); 1107 1107 pParam->flags |= USE_REG_XMM; 1108 1108 pParam->base.reg_xmm = reg; … … 1112 1112 if (mod == 3) 1113 1113 { 1114 disasmAddStringF(pParam->szParam, "XMM%d", rm);1114 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "XMM%d", rm); 1115 1115 pParam->flags |= USE_REG_XMM; 1116 1116 pParam->base.reg_xmm = rm; … … 1461 1461 pParam->flags |= USE_IMMEDIATE8; 1462 1462 1463 disasmAddStringF(pParam->szParam, "0%02Xh", (uint32_t)pParam->parval);1463 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%02Xh", (uint32_t)pParam->parval); 1464 1464 return sizeof(uint8_t); 1465 1465 } … … 1478 1478 pParam->parval = (uint32_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock); 1479 1479 pParam->flags |= USE_IMMEDIATE32_SX8; 1480 disasmAddStringF(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);1480 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08Xh", (uint32_t)pParam->parval); 1481 1481 } 1482 1482 else … … 1484 1484 pParam->parval = (uint16_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock); 1485 1485 pParam->flags |= USE_IMMEDIATE16_SX8; 1486 disasmAddStringF(pParam->szParam, "0%04Xh", (uint16_t)pParam->parval);1486 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04Xh", (uint16_t)pParam->parval); 1487 1487 } 1488 1488 return sizeof(uint8_t); … … 1501 1501 pParam->flags |= USE_IMMEDIATE16; 1502 1502 1503 disasmAddStringF(pParam->szParam, "0%04Xh", (uint16_t)pParam->parval);1503 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04Xh", (uint16_t)pParam->parval); 1504 1504 return sizeof(uint16_t); 1505 1505 } … … 1517 1517 pParam->flags |= USE_IMMEDIATE32; 1518 1518 1519 disasmAddStringF(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);1519 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08Xh", (uint32_t)pParam->parval); 1520 1520 return sizeof(uint32_t); 1521 1521 } … … 1533 1533 pParam->flags |= USE_IMMEDIATE64; 1534 1534 1535 disasmAddStringF(pParam->szParam, "0%08X", (uint32_t)pParam->parval);1536 disasmAddStringF(&pParam->szParam[9], "%08Xh", (uint32_t)(pParam->parval >> 32));1535 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08X", (uint32_t)pParam->parval); 1536 disasmAddStringF(&pParam->szParam[9], sizeof(pParam->szParam)-9, "%08Xh", (uint32_t)(pParam->parval >> 32)); 1537 1537 return sizeof(uint64_t); 1538 1538 } … … 1552 1552 pParam->flags |= USE_IMMEDIATE32; 1553 1553 1554 disasmAddStringF(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);1554 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08Xh", (uint32_t)pParam->parval); 1555 1555 return sizeof(uint32_t); 1556 1556 } … … 1560 1560 pParam->flags |= USE_IMMEDIATE16; 1561 1561 1562 disasmAddStringF(pParam->szParam, "0%04Xh", (uint32_t)pParam->parval);1562 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04Xh", (uint32_t)pParam->parval); 1563 1563 return sizeof(uint16_t); 1564 1564 } … … 1585 1585 pParam->flags |= USE_IMMEDIATE8_REL; 1586 1586 1587 disasmAddStringF(pParam->szParam, " (0%02Xh)", (uint32_t)pParam->parval);1587 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%02Xh)", (uint32_t)pParam->parval); 1588 1588 return sizeof(char); 1589 1589 } … … 1605 1605 pParam->flags |= USE_IMMEDIATE32_REL; 1606 1606 1607 disasmAddStringF(pParam->szParam, " (0%08Xh)", (uint32_t)pParam->parval);1607 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%08Xh)", (uint32_t)pParam->parval); 1608 1608 return sizeof(int32_t); 1609 1609 } … … 1613 1613 pParam->flags |= USE_IMMEDIATE16_REL; 1614 1614 1615 disasmAddStringF(pParam->szParam, " (0%04Xh)", (uint32_t)pParam->parval);1615 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%04Xh)", (uint32_t)pParam->parval); 1616 1616 return sizeof(uint16_t); 1617 1617 } … … 1644 1644 pParam->flags |= USE_IMMEDIATE_ADDR_16_32; 1645 1645 1646 disasmAddStringF(pParam->szParam, "0%04X:0%08Xh", (uint32_t)(pParam->parval>>32), (uint32_t)pParam->parval);1646 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04X:0%08Xh", (uint32_t)(pParam->parval>>32), (uint32_t)pParam->parval); 1647 1647 return sizeof(uint32_t) + sizeof(uint16_t); 1648 1648 } … … 1656 1656 pParam->flags |= USE_DISPLACEMENT32; 1657 1657 1658 disasmAddStringF(pParam->szParam, "[0%08Xh]", pParam->disp32);1658 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "[0%08Xh]", pParam->disp32); 1659 1659 return sizeof(uint32_t); 1660 1660 } … … 1667 1667 pParam->flags |= USE_IMMEDIATE_ADDR_16_16; 1668 1668 1669 disasmAddStringF(pParam->szParam, "0%04X:0%04Xh", (uint32_t)(pParam->parval>>16), (uint16_t)pParam->parval );1669 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04X:0%04Xh", (uint32_t)(pParam->parval>>16), (uint16_t)pParam->parval ); 1670 1670 return sizeof(uint32_t); 1671 1671 } … … 1679 1679 pParam->flags |= USE_DISPLACEMENT16; 1680 1680 1681 disasmAddStringF(pParam->szParam, "[0%04Xh]", (uint32_t)pParam->disp16);1681 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "[0%04Xh]", (uint32_t)pParam->disp16); 1682 1682 return sizeof(uint16_t); 1683 1683 } … … 1786 1786 { 1787 1787 disasmGetPtrString(pCpu, pOp, pParam); 1788 disasmAddStringF(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI");1788 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI"); 1789 1789 1790 1790 pParam->flags |= USE_POINTER_DS_BASED; … … 1805 1805 int ParseXb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu) 1806 1806 { 1807 disasmAddStringF(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI");1807 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), (pCpu->addrmode == CPUMODE_32BIT) ? "DS:ESI" : "DS:SI"); 1808 1808 1809 1809 pParam->flags |= USE_POINTER_DS_BASED; … … 1825 1825 { 1826 1826 disasmGetPtrString(pCpu, pOp, pParam); 1827 disasmAddStringF(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI");1827 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI"); 1828 1828 1829 1829 pParam->flags |= USE_POINTER_ES_BASED; … … 1844 1844 int ParseYb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu) 1845 1845 { 1846 disasmAddStringF(pParam->szParam, (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI");1846 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), (pCpu->addrmode == CPUMODE_32BIT) ? "ES:EDI" : "ES:DI"); 1847 1847 1848 1848 pParam->flags |= USE_POINTER_ES_BASED; … … 2429 2429 void disasmPrintAbs32(POP_PARAMETER pParam) 2430 2430 { 2431 disasmAddStringF(pParam->szParam, "%08Xh", pParam->disp32);2431 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%08Xh", pParam->disp32); 2432 2432 } 2433 2433 //***************************************************************************** … … 2435 2435 void disasmPrintDisp32(POP_PARAMETER pParam) 2436 2436 { 2437 disasmAddStringF(pParam->szParam, "%08Xh", pParam->disp32);2437 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%08Xh", pParam->disp32); 2438 2438 } 2439 2439 //***************************************************************************** … … 2441 2441 void disasmPrintDisp8(POP_PARAMETER pParam) 2442 2442 { 2443 disasmAddStringF(pParam->szParam, "%d", pParam->disp8);2443 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%d", pParam->disp8); 2444 2444 } 2445 2445 //***************************************************************************** … … 2447 2447 void disasmPrintDisp16(POP_PARAMETER pParam) 2448 2448 { 2449 disasmAddStringF(pParam->szParam, "%04Xh", pParam->disp16);2449 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%04Xh", pParam->disp16); 2450 2450 } 2451 2451 //***************************************************************************** … … 2495 2495 } 2496 2496 if (pCpu->prefix & PREFIX_SEG) 2497 disasmAddStringF(pParam->szParam, "%s:", szModRMSegReg[pCpu->prefix_seg]);2497 disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%s:", szModRMSegReg[pCpu->prefix_seg]); 2498 2498 } 2499 2499 #ifndef IN_GC … … 2607 2607 //***************************************************************************** 2608 2608 //***************************************************************************** 2609 void disasmAddStringF(char *psz, const char *pszFormat, ...)2609 void disasmAddStringF(char *psz, uint32_t size, const char *pszFormat, ...) 2610 2610 { 2611 2611 va_list args; 2612 2612 va_start(args, pszFormat); 2613 vsprintf(psz + strlen(psz), pszFormat, args);2613 RTStrPrintfV(psz + strlen(psz), size, pszFormat, args); 2614 2614 va_end(args); 2615 2615 }
Note:
See TracChangeset
for help on using the changeset viewer.