dis.h revision 0aa1ba1d1ea27baa7762e4fe891824df38697189
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DIS - The VirtualBox Disassembler.
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync * Copyright (C) 2006-2012 Oracle Corporation
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * available from http://www.virtualbox.org. This file is free software;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * you can redistribute it and/or modify it under the terms of the GNU
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * General Public License (GPL) as published by the Free Software
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * The contents of this file may alternatively be used under the terms
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * of the Common Development and Distribution License Version 1.0
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * VirtualBox OSE distribution, in which case the provisions of the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * CDDL are applicable instead of those of the GPL.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * You may elect to license modified versions of this file under the
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * terms and conditions of either the GPL or the CDDL or both.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * CPU mode flags (DISCPUSTATE::mode).
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /** hack forcing the size of the enum to 32-bits. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Prefix byte flags (DISCPUSTATE::prefix_rex).
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** non-default address size. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** non-default operand size. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** lock prefix. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** segment prefix. */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** rep(e) prefix (not a prefix, but we'll treat is as one). */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** rep(e) prefix (not a prefix, but we'll treat is as one). */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** REX prefix (64 bits) */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name 64 bits prefix byte flags (DISCPUSTATE::prefix_rex).
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync#define DISPREFIX_REX_OP_2_FLAGS(a) (a - OP_PARM_REX_START)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_B DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_B)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_X DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_X)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_XB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_XB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_R DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_R)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_RB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_RB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_RX DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_RX)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_RXB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_RXB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_W DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_W)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WX DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WX)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WXB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WXB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WR DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WR)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WRB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WRB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WRX DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WRX)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISPREFIX_REX_FLAGS_WRXB DISPREFIX_REX_OP_2_FLAGS(OP_PARM_REX_WRXB)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Operand type.
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync#define DISOPTYPE_POTENTIALLY_DANGEROUS RT_BIT_32(3)
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync#define DISOPTYPE_RRM_DANGEROUS RT_BIT_32(14) /**< Some additional dangerous ones when recompiling raw r0. */
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync#define DISOPTYPE_RRM_DANGEROUS_16 RT_BIT_32(15) /**< Some additional dangerous ones when recompiling 16-bit raw r0. */
1d17a5f9688f3622ffe088b664588629b1e95801vboxsync#define DISOPTYPE_RRM_MASK (DISOPTYPE_RRM_DANGEROUS | DISOPTYPE_RRM_DANGEROUS_16)
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync#define DISOPTYPE_INHIBIT_IRQS RT_BIT_32(16) /**< Will or can inhibit irqs (sti, pop ss, mov ss) */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_INVALID_64 RT_BIT_32(19) /**< Invalid in 64 bits mode */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_ONLY_64 RT_BIT_32(20) /**< Only valid in 64 bits mode */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_DEFAULT_64_OP_SIZE RT_BIT_32(21) /**< Default 64 bits operand size */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_FORCED_64_OP_SIZE RT_BIT_32(22) /**< Forced 64 bits operand size; regardless of prefix bytes */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_REXB_EXTENDS_OPREG RT_BIT_32(23) /**< REX.B extends the register field in the opcode byte */
254365851c06fac7efeae0a0bf727ed6c6940611vboxsync#define DISOPTYPE_MOD_FIXED_11 RT_BIT_32(24) /**< modrm.mod is always 11b */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync#define DISOPTYPE_FORCED_32_OP_SIZE_X86 RT_BIT_32(25) /**< Forced 32 bits operand size; regardless of prefix bytes (only in 16 & 32 bits mode!) */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Parameter usage flags.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** DS:ESI */
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** ES:EDI */
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync/** Mask of immediate use flags. */
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync/** Check if the use flags indicates an effective address. */
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync#define DISUSE_IS_EFFECTIVE_ADDR(a_fUseFlags) (!!( (a_fUseFlags) \
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync/** @name 64-bit general register indexes.
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync * This matches the AMD64 register encoding. It is found used in
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync * DISOPPARAM::base.reg_gen and DISOPPARAM::index.reg_gen.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @note Safe to assume same values as the 16-bit and 32-bit general registers.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name 32-bit general register indexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_gen and DISOPPARAM::index.reg_gen.
f1acc1e99894e016bd1a6ee65c56b3fc064fa4ebvboxsync * @note Safe to assume same values as the 16-bit and 64-bit general registers.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name 16-bit general register indexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_gen and DISOPPARAM::index.reg_gen.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * @note Safe to assume same values as the 32-bit and 64-bit general registers.
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync/** @name 8-bit general register indexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This mostly (?) matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_gen and DISOPPARAM::index.reg_gen.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Segment registerindexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This matches the AMD64 register encoding. It is found used in
9704f1d0180960069e2c4eb8fe2ddee350910e5dvboxsync * DISOPPARAM::base.reg_seg.
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsynctypedef enum
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync /** The usual 32-bit paranoia. */
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync/** @name FPU register indexes.
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync * This matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_fp.
aca7a56d52c58d8b388343450503c22822fd6620vboxsync/** @name Control register indexes.
aca7a56d52c58d8b388343450503c22822fd6620vboxsync * This matches the AMD64 register encoding. It is found used in
aca7a56d52c58d8b388343450503c22822fd6620vboxsync * DISOPPARAM::base.reg_ctrl.
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync/** @name Debug register indexes.
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync * This matches the AMD64 register encoding. It is found used in
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync * DISOPPARAM::base.reg_dbg.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name MMX register indexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_mmx.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name SSE register indexes.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * This matches the AMD64 register encoding. It is found used in
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync * DISOPPARAM::base.reg_xmm.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Flags returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync/** @name Types returned by DISQueryParamVal (DISQPVPARAMVAL::flags).
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsynctypedef struct
typedef enum DISQPVWHICH
} DISQPVWHICH;
typedef struct DISOPPARAM
} uDisp;
} base;
} index;
} DISOPPARAM;
typedef DECLCALLBACK(int) FNDISREADBYTES(PDISCPUSTATE pDisState, uint8_t *pbDst, RTUINTPTR uSrcAddr, uint32_t cbToRead);
* @remark no DECLCALLBACK() here because it's considered to be internal (really, I'm too lazy to update all the functions). */
typedef unsigned FNDISPARSE(RTUINTPTR pu8CodeBlock, PCDISOPCODE pOp, PDISOPPARAM pParam, PDISCPUSTATE pCpu);
typedef struct DISCPUSTATE
} Bits;
} ModRM;
} Bits;
} SIB;
} DISCPUSTATE;
typedef struct DISOPCODE
#ifndef DIS_CORE_ONLY
const char *pszOpcode;
} DISOPCODE;
DISDECL(int) DISInstrToStrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
DISDECL(int) DISInstr(void const *pvInstr, DISCPUMODE enmCpuMode, PDISCPUSTATE pCpu, uint32_t *pcbInstr);
DISDECL(int) DISInstrWithReader(RTUINTPTR uInstrAddr, DISCPUMODE enmCpuMode, PFNDISREADBYTES pfnReadBytes, void *pvUser,
DISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, PDISQPVPARAMVAL pParamVal, DISQPVWHICH parmtype);
DISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, PDISOPPARAM pParam, void **ppReg, size_t *pcbSize);
DISDECL(int) DISFetchRegSegEx(PCCPUMCTXCORE pCtx, DISSELREG sel, RTSEL *pVal, PCPUMSELREGHID *ppSelHidReg);
typedef DECLCALLBACK(int) FNDISGETSYMBOL(PCDISCPUSTATE pCpu, uint32_t u32Sel, RTUINTPTR uAddress, char *pszBuf, size_t cchBuf, RTINTPTR *poff, void *pvUser);
&& ((fFlags) & (DIS_FMT_FLAGS_ADDR_RIGHT | DIS_FMT_FLAGS_ADDR_LEFT)) != (DIS_FMT_FLAGS_ADDR_RIGHT | DIS_FMT_FLAGS_ADDR_LEFT) \
&& ((fFlags) & (DIS_FMT_FLAGS_BYTES_RIGHT | DIS_FMT_FLAGS_BYTES_LEFT)) != (DIS_FMT_FLAGS_BYTES_RIGHT | DIS_FMT_FLAGS_BYTES_LEFT) \
DISDECL(size_t) DISFormatYasmEx(PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);
DISDECL(size_t) DISFormatMasmEx(PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);
DISDECL(size_t) DISFormatGasEx( PCDISCPUSTATE pCpu, char *pszBuf, size_t cchBuf, uint32_t fFlags, PFNDISGETSYMBOL pfnGetSymbol, void *pvUser);