VirtualBox

Changeset 41658 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Jun 11, 2012 10:21:44 PM (13 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
78464
Message:

DIS,VMM,REM,IPRT: Disassembler API adjustments.

Location:
trunk/include/VBox
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/dis.h

    r41501 r41658  
    44
    55/*
    6  * Copyright (C) 2006-2007 Oracle Corporation
     6 * Copyright (C) 2006-2012 Oracle Corporation
    77 *
    88 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    370370typedef struct OP_PARAMETER
    371371{
    372     /** @todo switch param and parval and move disp64 and flags up here with the other 64-bit vars to get more natural alignment and save space. */
    373     int             param;
    374372    uint64_t        parval;
    375 #ifndef DIS_SEPARATE_FORMATTER
    376     char            szParam[32];
    377 #endif
    378 
    379     int32_t         disp8, disp16, disp32;
     373    uint64_t        flags;
     374    int64_t         disp64;
     375    int32_t         disp32;
     376    int32_t         disp16;
     377    int32_t         disp8;
    380378    uint32_t        size;
    381 
    382     int64_t         disp64;
    383     uint64_t        flags;
     379    int32_t         param;
    384380
    385381    union
     
    409405    uint32_t scale;
    410406
     407#ifndef DIS_SEPARATE_FORMATTER
     408    char            szParam[32];
     409#endif
    411410} OP_PARAMETER;
    412411/** Pointer to opcode parameter. */
     
    421420typedef const struct OPCODE *PCOPCODE;
    422421
    423 typedef DECLCALLBACK(int) FN_DIS_READBYTES(RTUINTPTR pSrc, uint8_t *pDest, unsigned size, void *pvUserdata);
    424 typedef FN_DIS_READBYTES *PFN_DIS_READBYTES;
     422/**
     423 * Callback for reading opcode bytes.
     424 *
     425 * @param   pDisState       Pointer to the CPU state.  The primary user argument
     426 *                          can be retrived from DISCPUSTATE::apvUserData[0]. If
     427 *                          more is required these can be passed in the
     428 *                          subsequent slots.
     429 * @param   pbDst           Pointer to output buffer.
     430 * @param   uSrcAddr        The address to start reading at.
     431 * @param   cbToRead        The number of bytes to read.
     432 */
     433typedef DECLCALLBACK(int) FNDISREADBYTES(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead);
     434/** Pointer to a opcode byte reader. */
     435typedef FNDISREADBYTES *PFNDISREADBYTES;
    425436
    426437/** Parser callback.
     
    431442typedef struct DISCPUSTATE
    432443{
    433     /* Global setting */
     444    /** Global setting. */
    434445    DISCPUMODE      mode;
    435446
    436     /* Per instruction prefix settings */
     447    /** Per instruction prefix settings. */
    437448    uint32_t        prefix;
    438449    /** segment prefix value. */
     
    452463    union
    453464    {
    454         /* Bitfield view */
     465        /** Bitfield view */
    455466        struct
    456467        {
     
    459470            unsigned        Mod : 2;
    460471        } Bits;
    461         /* unsigned view */
     472        /** unsigned view */
    462473        unsigned            u;
    463474    } ModRM;
     
    466477    union
    467478    {
    468         /* Bitfield view */
     479        /** Bitfield view */
    469480        struct
    470481        {
     
    473484            unsigned        Scale : 2;
    474485        } Bits;
    475         /* unsigned view */
     486        /** unsigned view */
    476487        unsigned            u;
    477488    } SIB;
    478 
    479     int32_t         disp;
     489    int32_t         i32SibDisp;
     490
     491    /** The instruction size. */
     492    uint32_t        opsize;
     493    /** The address of the instruction. */
     494    RTUINTPTR       uInstrAddr;
     495    /** The offsetted address of the instruction. */
     496    RTUINTPTR       opaddr;
     497    /** The size of the prefix bytes. */
     498    uint8_t         cbPrefix;
    480499
    481500    /** First opcode byte of instruction. */
    482501    uint8_t         opcode;
    483     /** Last prefix byte (for SSE2 extension tables) */
     502    /** Last prefix byte (for SSE2 extension tables). */
    484503    uint8_t         lastprefix;
    485     RTUINTPTR       opaddr;
    486     uint32_t        opsize;
     504    /** The instruction bytes. */
     505    uint8_t         abInstr[16];
     506
     507    /** Internal: pointer to disassembly function table */
     508    PFNDISPARSE    *pfnDisasmFnTable;
     509    /** Internal: instruction filter */
     510    uint32_t        uFilter;
     511    /** Return code set by a worker function like the opcode bytes readers. */
     512    int32_t         rc;
     513
     514    /** Pointer to the current instruction. */
     515    PCOPCODE        pCurInstr;
    487516#ifndef DIS_CORE_ONLY
    488517    /** Opcode format string for current instruction. */
     
    490519#endif
    491520
    492     /** Internal: pointer to disassembly function table */
    493     PFNDISPARSE    *pfnDisasmFnTable;
    494     /** Internal: instruction filter */
    495     uint32_t        uFilter;
    496 
    497     /** Pointer to the current instruction. */
    498     PCOPCODE        pCurInstr;
    499 
     521    /** Optional read function */
     522    PFNDISREADBYTES pfnReadBytes;
     523    /** User data slots for the read callback.  The first entry is used for the
     524     *  pvUser argument, the rest are up for grabs.
     525     * @remarks This must come last so that we can memset everything before this. */
    500526    void           *apvUserData[3];
    501 
    502     /** Optional read function */
    503     PFN_DIS_READBYTES pfnReadBytes;
    504 #ifdef __L4ENV__
    505     jmp_buf *pJumpBuffer;
    506 #endif /* __L4ENV__ */
    507527} DISCPUSTATE;
    508528
     
    531551
    532552
    533 /**
    534  * Disassembles a code block.
    535  *
    536  * @returns VBox error code
    537  * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    538  *                          set correctly.
    539  * @param   pvCodeBlock     Pointer to the structure to disassemble.
    540  * @param   cbMax           Maximum number of bytes to disassemble.
    541  * @param   pcbSize         Where to store the size of the instruction.
    542  *                          NULL is allowed.
    543  *
    544  *
    545  * @todo    Define output callback.
    546  * @todo    Using signed integers as sizes is a bit odd. There are still
    547  *          some GCC warnings about mixing signed and unsigned integers.
    548  * @todo    Need to extend this interface to include a code address so we
    549  *          can disassemble GC code. Perhaps a new function is better...
    550  * @remark  cbMax isn't respected as a boundary. DISInstr() will read beyond cbMax.
    551  *          This means *pcbSize >= cbMax sometimes.
    552  */
    553 DISDECL(int) DISBlock(PDISCPUSTATE pCpu, RTUINTPTR pvCodeBlock, unsigned cbMax, unsigned *pSize);
    554 
    555 /**
    556  * Disassembles one instruction
    557  *
    558  * @returns VBox error code
    559  * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    560  *                          set correctly.
    561  * @param   pu8Instruction  Pointer to the instrunction to disassemble.
    562  * @param   u32EipOffset    Offset to add to instruction address to get the real virtual address
    563  * @param   pcbSize         Where to store the size of the instruction.
    564  *                          NULL is allowed.
    565  * @param   pszOutput       Storage for disassembled instruction
    566  *
    567  * @todo    Define output callback.
    568  */
    569 DISDECL(int) DISInstr(PDISCPUSTATE pCpu, RTUINTPTR pu8Instruction, unsigned u32EipOffset, unsigned *pcbSize, char *pszOutput);
    570 
    571 /**
    572  * Disassembles one instruction
    573  *
    574  * @returns VBox error code
    575  * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    576  *                          set correctly.
    577  * @param   pu8Instruction  Pointer to the structure to disassemble.
    578  * @param   u32EipOffset    Offset to add to instruction address to get the real virtual address
    579  * @param   pcbSize         Where to store the size of the instruction.
    580  *                          NULL is allowed.
    581  * @param   pszOutput       Storage for disassembled instruction
    582  * @param   uFilter         Instruction type filter
    583  *
    584  * @todo    Define output callback.
    585  */
    586 DISDECL(int) DISInstrEx(PDISCPUSTATE pCpu, RTUINTPTR pu8Instruction, uint32_t u32EipOffset, uint32_t *pcbSize,
    587                          char *pszOutput, unsigned uFilter);
    588 
    589 /**
    590  * Parses one instruction.
    591  * The result is found in pCpu.
    592  *
    593  * @returns VBox error code
    594  * @param   pCpu            Pointer to cpu structure which has DISCPUSTATE::mode set correctly.
    595  * @param   InstructionAddr Pointer to the instruction to parse.
    596  * @param   pcbInstruction  Where to store the size of the instruction.
    597  *                          NULL is allowed.
    598  */
    599 DISDECL(int) DISCoreOne(PDISCPUSTATE pCpu, RTUINTPTR InstructionAddr, unsigned *pcbInstruction);
    600 
    601 /**
    602  * Parses one guest instruction.
    603  * The result is found in pCpu and pcbInstruction.
    604  *
    605  * @returns VBox status code.
    606  * @param   InstructionAddr Address of the instruction to decode. What this means
    607  *                          is left to the pfnReadBytes function.
    608  * @param   enmCpuMode      The CPU mode. CPUMODE_32BIT, CPUMODE_16BIT, or CPUMODE_64BIT.
    609  * @param   pfnReadBytes    Callback for reading instruction bytes.
    610  * @param   pvUser          User argument for the instruction reader. (Ends up in apvUserData[0].)
    611  * @param   pCpu            Pointer to cpu structure. Will be initialized.
    612  * @param   pcbInstruction  Where to store the size of the instruction.
    613  *                          NULL is allowed.
    614  */
    615 DISDECL(int) DISCoreOneEx(RTUINTPTR InstructionAddr, DISCPUMODE enmCpuMode, PFN_DIS_READBYTES pfnReadBytes, void *pvUser,
    616                           PDISCPUSTATE pCpu, unsigned *pcbInstruction);
     553DISDECL(int) DISInstr(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput);
     554DISDECL(int) DISInstrWithOff(PDISCPUSTATE pCpu, RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, uint32_t *pcbSize, char *pszOutput);
     555DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
     556                                PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput);
     557DISDECL(int) DISInstrEx(RTUINTPTR uInstrAddr, RTUINTPTR offRealAddr, DISCPUMODE enmCpuMode,
     558                        PFNDISREADBYTES pfnReadBytes, void *pvUser, uint32_t uFilter,
     559                        PDISCPUSTATE pCpu, uint32_t *pcbSize, char *pszOutput);
     560
     561DISDECL(int) DISCoreOne(PDISCPUSTATE pCpu, RTUINTPTR InstructionAddr, uint32_t *pcbInstruction);
     562DISDECL(int) DISCoreOneEx(RTUINTPTR InstructionAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
     563                          PDISCPUSTATE pCpu, uint32_t *pcbInstruction);
    617564
    618565DISDECL(int)        DISGetParamSize(PDISCPUSTATE pCpu, POP_PARAMETER pParam);
     
    620567DISDECL(uint8_t)    DISQuerySegPrefixByte(PDISCPUSTATE pCpu);
    621568
    622 /**
    623  * Returns the value of the parameter in pParam
    624  *
    625  * @returns VBox error code
    626  * @param   pCtx            Exception structure pointer
    627  * @param   pCpu            Pointer to cpu structure which have DISCPUSTATE::mode
    628  *                          set correctly.
    629  * @param   pParam          Pointer to the parameter to parse
    630  * @param   pParamVal       Pointer to parameter value (OUT)
    631  * @param   parmtype        Parameter type
    632  *
    633  * @note    Currently doesn't handle FPU/XMM/MMX/3DNow! parameters correctly!!
    634  *
    635  */
    636569DISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, POP_PARAMVAL pParamVal, PARAM_TYPE parmtype);
    637570DISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, void **ppReg, size_t *pcbSize);
  • trunk/include/VBox/err.h

    r41573 r41658  
    19321932/** Generic failure during disassembly. */
    19331933#define VERR_DIS_GEN_FAILURE                        (-4201)
     1934/** No read callback. */
     1935#define VERR_DIS_NO_READ_CALLBACK                   (-4202)
     1936/** Invalid Mod/RM. */
     1937#define VERR_DIS_INVALID_MODRM                      (-4203)
     1938/** Invalid parameter index. */
     1939#define VERR_DIS_INVALID_PARAMETER                  (-4204)
     1940/** Reading opcode bytes failed. */
     1941#define VERR_DIS_MEM_READ                           (-4205)
    19341942/** @} */
    19351943
  • trunk/include/VBox/vmm/iem.h

    r40453 r41658  
    4141VMMDECL(VBOXSTRICTRC)       IEMExecOne(PVMCPU pVCpu);
    4242VMMDECL(VBOXSTRICTRC)       IEMExecOneEx(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, uint32_t *pcbWritten);
     43VMMDECL(VBOXSTRICTRC)       IEMExecOneWithOpcodes(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore,
     44                                                  RTGCPTR GCPtrOpcodeBytes, const void *pvOpcodeBytes, size_t cbOpcodeBytes);
    4345VMMDECL(VBOXSTRICTRC)       IEMExecLots(PVMCPU pVCpu);
    4446VMM_INT_DECL(VBOXSTRICTRC)  IEMInjectTrap(PVMCPU pVCpu, uint8_t u8TrapNo, TRPMEVENT enmType, uint16_t uErrCode, RTGCPTR uCr2);
  • trunk/include/VBox/vmm/patm.h

    r40453 r41658  
    238238 * @param   pCtxCore    The relevant core context.
    239239 */
    240 VMMDECL(int) PATMHandleInt3PatchTrap(PVM pVM, PCPUMCTXCORE pRegFrame);
     240VMMRCDECL(int) PATMRCHandleInt3PatchTrap(PVM pVM, PCPUMCTXCORE pRegFrame);
    241241
    242242/**
Note: See TracChangeset for help on using the changeset viewer.

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