VirtualBox

Changeset 11460 in vbox for trunk


Ignore:
Timestamp:
Aug 18, 2008 11:51:27 AM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
34906
Message:

Check for force flags when determining the new opcode in instruction groups.

File:
1 edited

Legend:

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

    r11406 r11460  
    404404    return VINF_SUCCESS;
    405405}
    406 //*****************************************************************************
    407 //*****************************************************************************
    408 unsigned ParseInstruction(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, PDISCPUSTATE pCpu)
    409 {
    410     int  size = 0;
    411     bool fFiltered = false;
    412 
    413     // Store the opcode format string for disasmPrintf
    414 #ifndef DIS_CORE_ONLY
    415     pCpu->pszOpcode = pOp->pszOpcode;
    416 #endif
    417     pCpu->pCurInstr = pOp;
    418 
    419     /*
    420      * Apply filter to instruction type to determine if a full disassembly is required.
    421      * @note Multibyte opcodes are always marked harmless until the final byte.
    422      */
    423     if ((pOp->optype & pCpu->uFilter) == 0)
    424     {
    425         fFiltered = true;
    426         pCpu->pfnDisasmFnTable = pfnCalcSize;
    427     }
    428     else
    429     {
    430         /* Not filtered out -> full disassembly */
    431         pCpu->pfnDisasmFnTable = pfnFullDisasm;
    432     }
    433 
    434     // Should contain the parameter type on input
    435     pCpu->param1.param = pOp->param1;
    436     pCpu->param2.param = pOp->param2;
    437     pCpu->param3.param = pOp->param3;
    438 
     406/**************************************************************************************/
     407/* Correct the operand size if the instruction is marked as forced or default 64 bits */
     408/**************************************************************************************/
     409static void CheckForceFlags(PDISCPUSTATE pCpu, PCOPCODE pOp)
     410{
    439411    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
    440412    if (pCpu->mode == CPUMODE_64BIT)
     
    447419            pCpu->opsize = CPUMODE_64BIT;
    448420    }
     421}
     422//*****************************************************************************
     423//*****************************************************************************
     424unsigned ParseInstruction(RTUINTPTR lpszCodeBlock, PCOPCODE pOp, PDISCPUSTATE pCpu)
     425{
     426    int  size = 0;
     427    bool fFiltered = false;
     428
     429    // Store the opcode format string for disasmPrintf
     430#ifndef DIS_CORE_ONLY
     431    pCpu->pszOpcode = pOp->pszOpcode;
     432#endif
     433    pCpu->pCurInstr = pOp;
     434
     435    /*
     436     * Apply filter to instruction type to determine if a full disassembly is required.
     437     * @note Multibyte opcodes are always marked harmless until the final byte.
     438     */
     439    if ((pOp->optype & pCpu->uFilter) == 0)
     440    {
     441        fFiltered = true;
     442        pCpu->pfnDisasmFnTable = pfnCalcSize;
     443    }
     444    else
     445    {
     446        /* Not filtered out -> full disassembly */
     447        pCpu->pfnDisasmFnTable = pfnFullDisasm;
     448    }
     449
     450    // Should contain the parameter type on input
     451    pCpu->param1.param = pOp->param1;
     452    pCpu->param2.param = pOp->param2;
     453    pCpu->param3.param = pOp->param3;
     454
     455    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     456    CheckForceFlags(pCpu, pOp);
    449457
    450458    if (pOp->idxParse1 != IDX_ParseNop)
     
    17921800        pOp = &g_aMapX86_NopPause[0]; /* NOP */
    17931801
     1802    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1803    CheckForceFlags(pCpu, pOp);
     1804
    17941805    size += ParseInstruction(pu8CodeBlock, pOp, pCpu);
    17951806    return size;
     
    18091820    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
    18101821        size = sizeof(uint8_t); //ModRM byte
     1822
     1823    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1824    CheckForceFlags(pCpu, pOp);
    18111825
    18121826    size += ParseInstruction(lpszCodeBlock, pOp, pCpu);
     
    18451859    pOp = (PCOPCODE)&g_aMapX86_Group2[idx+reg];
    18461860
     1861    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1862    CheckForceFlags(pCpu, pOp);
     1863
    18471864    //little hack to make sure the ModRM byte is included in the returned size
    18481865    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    18651882    pOp = (PCOPCODE)&g_aMapX86_Group3[idx+reg];
    18661883
     1884    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1885    CheckForceFlags(pCpu, pOp);
     1886
    18671887    //little hack to make sure the ModRM byte is included in the returned size
    18681888    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    18841904    pOp = (PCOPCODE)&g_aMapX86_Group4[reg];
    18851905
     1906    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1907    CheckForceFlags(pCpu, pOp);
     1908
    18861909    //little hack to make sure the ModRM byte is included in the returned size
    18871910    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    19021925
    19031926    pOp = (PCOPCODE)&g_aMapX86_Group5[reg];
     1927
     1928    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1929    CheckForceFlags(pCpu, pOp);
    19041930
    19051931    //little hack to make sure the ModRM byte is included in the returned size
     
    19371963    pOp = (PCOPCODE)&g_aTwoByteMapX86_3DNow[opcode];
    19381964
     1965    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1966    CheckForceFlags(pCpu, pOp);
     1967
    19391968    //little hack to make sure the ModRM byte is included in the returned size
    19401969    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    19621991    pOp = (PCOPCODE)&g_aMapX86_Group6[reg];
    19631992
     1993    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     1994    CheckForceFlags(pCpu, pOp);
     1995
    19641996    //little hack to make sure the ModRM byte is included in the returned size
    19651997    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    19892021        pOp = (PCOPCODE)&g_aMapX86_Group7_mem[reg];
    19902022
     2023    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2024    CheckForceFlags(pCpu, pOp);
     2025
    19912026    //little hack to make sure the ModRM byte is included in the returned size
    19922027    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    20082043    pOp = (PCOPCODE)&g_aMapX86_Group8[reg];
    20092044
     2045    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2046    CheckForceFlags(pCpu, pOp);
     2047
    20102048    //little hack to make sure the ModRM byte is included in the returned size
    20112049    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    20272065    pOp = (PCOPCODE)&g_aMapX86_Group9[reg];
    20282066
     2067    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2068    CheckForceFlags(pCpu, pOp);
     2069
    20292070    //little hack to make sure the ModRM byte is included in the returned size
    20302071    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    20462087    pOp = (PCOPCODE)&g_aMapX86_Group10[reg];
    20472088
     2089    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2090    CheckForceFlags(pCpu, pOp);
     2091
    20482092    //little hack to make sure the ModRM byte is included in the returned size
    20492093    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    20672111
    20682112    pOp = (PCOPCODE)&g_aMapX86_Group12[reg];
     2113
     2114    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2115    CheckForceFlags(pCpu, pOp);
    20692116
    20702117    //little hack to make sure the ModRM byte is included in the returned size
     
    20882135    pOp = (PCOPCODE)&g_aMapX86_Group13[reg];
    20892136
     2137    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2138    CheckForceFlags(pCpu, pOp);
     2139
    20902140    //little hack to make sure the ModRM byte is included in the returned size
    20912141    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    21092159    pOp = (PCOPCODE)&g_aMapX86_Group14[reg];
    21102160
     2161    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2162    CheckForceFlags(pCpu, pOp);
     2163
    21112164    //little hack to make sure the ModRM byte is included in the returned size
    21122165    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    21332186        pOp = (PCOPCODE)&g_aMapX86_Group15_mem[reg];
    21342187
     2188    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2189    CheckForceFlags(pCpu, pOp);
     2190
    21352191    //little hack to make sure the ModRM byte is included in the returned size
    21362192    if (pOp->idxParse1 != IDX_ParseModRM && pOp->idxParse2 != IDX_ParseModRM)
     
    21502206
    21512207    pOp = (PCOPCODE)&g_aMapX86_Group16[reg];
     2208
     2209    /* Correct the operand size if the instruction is marked as forced or default 64 bits */
     2210    CheckForceFlags(pCpu, pOp);
    21522211
    21532212    //little hack to make sure the ModRM byte is included in the returned size
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