VirtualBox

Changeset 1155 in vbox


Ignore:
Timestamp:
Mar 2, 2007 1:45:13 PM (18 years ago)
Author:
vboxsync
Message:

Use RTStrPrintfV (%04X still broken though)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Disassembler/DisasmCore.cpp

    r1150 r1155  
    5252#if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
    5353static void disasmAddString(char *psz, const char *pszString);
    54 static void disasmAddStringF(char *psz, const char *pszFormat, ...);
     54static void disasmAddStringF(char *psz, uint32_t cbString, const char *pszFormat, ...);
    5555static void disasmAddChar(char *psz, char ch);
    5656#else
     
    5959#  define disasmAddStringF __noop
    6060# 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 */
    6262# endif
    6363# define disasmAddChar(psz, ch)                 do {} while (0)
     
    990990
    991991         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]);
    993993         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]);
    995995    }
    996996    else
    997997    {
    998998         if(base != 5 || MODRM_MOD(pCpu->ModRM) != 0)
    999              disasmAddStringF(szTemp, "%s", szSIBBaseReg[base]);
     999             disasmAddStringF(szTemp, sizeof(szTemp), "%s", szSIBBaseReg[base]);
    10001000    }
    10011001
     
    10751075            {
    10761076            case OP_PARM_C: //control register
    1077                 disasmAddStringF(pParam->szParam, "CR%d", reg);
     1077                disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "CR%d", reg);
    10781078                pParam->flags |= USE_REG_CR;
    10791079                pParam->base.reg_ctrl = reg;
     
    10811081
    10821082            case OP_PARM_D: //debug register
    1083                 disasmAddStringF(pParam->szParam, "DR%d", reg);
     1083                disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "DR%d", reg);
    10841084                pParam->flags |= USE_REG_DBG;
    10851085                pParam->base.reg_dbg = reg;
     
    10871087
    10881088            case OP_PARM_P: //MMX register
    1089                 disasmAddStringF(pParam->szParam, "MM%d", reg);
     1089                disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "MM%d", reg);
    10901090                pParam->flags |= USE_REG_MMX;
    10911091                pParam->base.reg_mmx = reg;
     
    10981098
    10991099            case OP_PARM_T: //test register
    1100                 disasmAddStringF(pParam->szParam, "TR%d", reg);
     1100                disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "TR%d", reg);
    11011101                pParam->flags |= USE_REG_TEST;
    11021102                pParam->base.reg_test = reg;
     
    11041104
    11051105            case OP_PARM_V: //XMM register
    1106                 disasmAddStringF(pParam->szParam, "XMM%d", reg);
     1106                disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "XMM%d", reg);
    11071107                pParam->flags |= USE_REG_XMM;
    11081108                pParam->base.reg_xmm = reg;
     
    11121112                if (mod == 3)
    11131113                {
    1114                     disasmAddStringF(pParam->szParam, "XMM%d", rm);
     1114                    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "XMM%d", rm);
    11151115                    pParam->flags |= USE_REG_XMM;
    11161116                    pParam->base.reg_xmm = rm;
     
    14611461    pParam->flags |= USE_IMMEDIATE8;
    14621462
    1463     disasmAddStringF(pParam->szParam, "0%02Xh", (uint32_t)pParam->parval);
     1463    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%02Xh", (uint32_t)pParam->parval);
    14641464    return sizeof(uint8_t);
    14651465}
     
    14781478        pParam->parval = (uint32_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock);
    14791479        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);
    14811481    }
    14821482    else
     
    14841484        pParam->parval = (uint16_t)(int8_t)DISReadByte(pCpu, lpszCodeBlock);
    14851485        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);
    14871487    }
    14881488    return sizeof(uint8_t);
     
    15011501    pParam->flags |= USE_IMMEDIATE16;
    15021502
    1503     disasmAddStringF(pParam->szParam, "0%04Xh", (uint16_t)pParam->parval);
     1503    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04Xh", (uint16_t)pParam->parval);
    15041504    return sizeof(uint16_t);
    15051505}
     
    15171517    pParam->flags |= USE_IMMEDIATE32;
    15181518
    1519     disasmAddStringF(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
     1519    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08Xh", (uint32_t)pParam->parval);
    15201520    return sizeof(uint32_t);
    15211521}
     
    15331533    pParam->flags |= USE_IMMEDIATE64;
    15341534
    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));
    15371537    return sizeof(uint64_t);
    15381538}
     
    15521552        pParam->flags |= USE_IMMEDIATE32;
    15531553
    1554         disasmAddStringF(pParam->szParam, "0%08Xh", (uint32_t)pParam->parval);
     1554        disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%08Xh", (uint32_t)pParam->parval);
    15551555        return sizeof(uint32_t);
    15561556    }
     
    15601560        pParam->flags |= USE_IMMEDIATE16;
    15611561
    1562         disasmAddStringF(pParam->szParam, "0%04Xh", (uint32_t)pParam->parval);
     1562        disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "0%04Xh", (uint32_t)pParam->parval);
    15631563        return sizeof(uint16_t);
    15641564    }
     
    15851585    pParam->flags |= USE_IMMEDIATE8_REL;
    15861586
    1587     disasmAddStringF(pParam->szParam, " (0%02Xh)", (uint32_t)pParam->parval);
     1587    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%02Xh)", (uint32_t)pParam->parval);
    15881588    return sizeof(char);
    15891589}
     
    16051605        pParam->flags |= USE_IMMEDIATE32_REL;
    16061606
    1607         disasmAddStringF(pParam->szParam, " (0%08Xh)", (uint32_t)pParam->parval);
     1607        disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%08Xh)", (uint32_t)pParam->parval);
    16081608        return sizeof(int32_t);
    16091609    }
     
    16131613        pParam->flags |= USE_IMMEDIATE16_REL;
    16141614
    1615         disasmAddStringF(pParam->szParam, " (0%04Xh)", (uint32_t)pParam->parval);
     1615        disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), " (0%04Xh)", (uint32_t)pParam->parval);
    16161616        return sizeof(uint16_t);
    16171617    }
     
    16441644            pParam->flags  |= USE_IMMEDIATE_ADDR_16_32;
    16451645
    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);
    16471647            return sizeof(uint32_t) + sizeof(uint16_t);
    16481648        }
     
    16561656            pParam->flags |= USE_DISPLACEMENT32;
    16571657
    1658             disasmAddStringF(pParam->szParam, "[0%08Xh]", pParam->disp32);
     1658            disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "[0%08Xh]", pParam->disp32);
    16591659            return sizeof(uint32_t);
    16601660        }
     
    16671667            pParam->flags |= USE_IMMEDIATE_ADDR_16_16;
    16681668
    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 );
    16701670            return sizeof(uint32_t);
    16711671        }
     
    16791679            pParam->flags |= USE_DISPLACEMENT16;
    16801680
    1681             disasmAddStringF(pParam->szParam, "[0%04Xh]", (uint32_t)pParam->disp16);
     1681            disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "[0%04Xh]", (uint32_t)pParam->disp16);
    16821682            return sizeof(uint16_t);
    16831683        }
     
    17861786{
    17871787    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");
    17891789
    17901790    pParam->flags |= USE_POINTER_DS_BASED;
     
    18051805int ParseXb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    18061806{
    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");
    18081808
    18091809    pParam->flags |= USE_POINTER_DS_BASED;
     
    18251825{
    18261826    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");
    18281828
    18291829    pParam->flags |= USE_POINTER_ES_BASED;
     
    18441844int ParseYb(RTUINTPTR pu8CodeBlock, PCOPCODE pOp, POP_PARAMETER pParam, PDISCPUSTATE pCpu)
    18451845{
    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");
    18471847
    18481848    pParam->flags |= USE_POINTER_ES_BASED;
     
    24292429void disasmPrintAbs32(POP_PARAMETER pParam)
    24302430{
    2431     disasmAddStringF(pParam->szParam, "%08Xh", pParam->disp32);
     2431    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%08Xh", pParam->disp32);
    24322432}
    24332433//*****************************************************************************
     
    24352435void disasmPrintDisp32(POP_PARAMETER pParam)
    24362436{
    2437     disasmAddStringF(pParam->szParam, "%08Xh", pParam->disp32);
     2437    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%08Xh", pParam->disp32);
    24382438}
    24392439//*****************************************************************************
     
    24412441void disasmPrintDisp8(POP_PARAMETER pParam)
    24422442{
    2443     disasmAddStringF(pParam->szParam, "%d", pParam->disp8);
     2443    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%d", pParam->disp8);
    24442444}
    24452445//*****************************************************************************
     
    24472447void disasmPrintDisp16(POP_PARAMETER pParam)
    24482448{
    2449     disasmAddStringF(pParam->szParam, "%04Xh", pParam->disp16);
     2449    disasmAddStringF(pParam->szParam, sizeof(pParam->szParam), "%04Xh", pParam->disp16);
    24502450}
    24512451//*****************************************************************************
     
    24952495    }
    24962496    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]);
    24982498}
    24992499#ifndef IN_GC
     
    26072607//*****************************************************************************
    26082608//*****************************************************************************
    2609 void disasmAddStringF(char *psz, const char *pszFormat, ...)
     2609void disasmAddStringF(char *psz, uint32_t size, const char *pszFormat, ...)
    26102610{
    26112611    va_list args;
    26122612    va_start(args, pszFormat);
    2613     vsprintf(psz + strlen(psz), pszFormat, args);
     2613    RTStrPrintfV(psz + strlen(psz), size, pszFormat, args);
    26142614    va_end(args);
    26152615}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette