Disasm.cpp revision 45a5c10c52145bef626fac30bfb2b3188fce8d59
0N/A * available from http://www.virtualbox.org. This file is free software;
1472N/A * Clara, CA 95054 USA or visit http://www.sun.com if you need
1879N/A#ifdef USING_VISUAL_STUDIO
1879N/A#include "DisasmInternal.h"
1879N/A#include "DisasmTables.h"
0N/ADISDECL(int) DISBlock(PDISCPUSTATE pCpu, RTUINTPTR pvCodeBlock, unsigned cbMax, unsigned *pSize)
DISDECL(int) DISInstr(PDISCPUSTATE pCpu, RTUINTPTR pu8Instruction, unsigned u32EipOffset, unsigned *pcbSize,
char *pszOutput)
* Disassembles one instruction; only fully disassembly an instruction if it matches the filter criteria
DISDECL(int) DISInstrEx(PDISCPUSTATE pCpu, RTUINTPTR pu8Instruction, unsigned u32EipOffset, unsigned *pcbSize,
unsigned i = 0, prefixbytes;
#ifdef __L4ENV__
if (pszOutput)
prefixbytes = 0;
switch(opcode)
case OP_INVALID:
return VERR_DIS_INVALID_OPCODE;
case OP_SEG:
i += sizeof(uint8_t);
prefixbytes++;
case OP_LOCK:
i += sizeof(uint8_t);
prefixbytes++;
case OP_ADDRSIZE:
i += sizeof(uint8_t);
prefixbytes++;
case OP_OPSIZE:
pCpu->opmode = CPUMODE_16BIT; /* for 32 and 64 bits mode (there is no 32 bits operand size override prefix) */
i += sizeof(uint8_t);
prefixbytes++;
case OP_REPE:
i += sizeof(uint8_t);
case OP_REPNE:
i += sizeof(uint8_t);
case OP_REX:
i += sizeof(uint8_t);
idx = i;
if(pszOutput) {
disasmSprintf(pszOutput, pu8Instruction+i-1-prefixbytes, pCpu, &pCpu->param1, &pCpu->param2, &pCpu->param3);
i += inc;
prefixbytes = 0;
#ifndef __L4ENV__
if (pcbSize)
*pcbSize = 0;
return VERR_DIS_GEN_FAILURE;
if (pcbSize)
*pcbSize = i;
return VINF_SUCCESS;
for(i = 0; i < size; i++)
return pszOutput;
void disasmSprintf(char *pszOutput, RTUINTPTR pu8Instruction, PDISCPUSTATE pCpu, OP_PARAMETER *pParam1, OP_PARAMETER *pParam2, OP_PARAMETER *pParam3)
RTStrPrintf(&pszOutput[strlen(pszOutput)], 64, "Invalid Opcode [%02X][%02X]", DISReadByte(pCpu, pu8Instruction), DISReadByte(pCpu, pu8Instruction+1) );
while(*lpszFormat)
switch(*lpszFormat)
switch(param)
param++;