DisasmReg.cpp revision f5eadb22976c1f9813300e4042b8255cfaef7e19
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/** @file
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * VBox disassembler:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Core components
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/*
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync * Copyright (C) 2006-2007 Oracle Corporation
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * available from http://www.virtualbox.org. This file is free software;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * you can redistribute it and/or modify it under the terms of the GNU
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * General Public License (GPL) as published by the Free Software
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/*******************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync* Header Files *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync*******************************************************************************/
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define LOG_GROUP LOG_GROUP_DIS
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#ifdef USING_VISUAL_STUDIO
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync# include <stdafx.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#endif
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <VBox/dis.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <VBox/disopcode.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <VBox/err.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <VBox/log.h>
43747b1f0bc8302a238fb35e55857a5e9aa1933dvboxsync#include <VBox/vmm/cpum.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <iprt/assert.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <iprt/string.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include <iprt/stdarg.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include "DisasmInternal.h"
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#include "DisasmTables.h"
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#if !defined(DIS_CORE_ONLY) && defined(LOG_ENABLED)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync# include <stdlib.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync# include <stdio.h>
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#endif
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/*******************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync* Global Variables *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync*******************************************************************************/
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Array for accessing 64-bit general registers in VMMREGFRAME structure
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * by register's index from disasm.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aReg64Index[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rax), /* USE_REG_RAX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rcx), /* USE_REG_RCX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rdx), /* USE_REG_RDX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rbx), /* USE_REG_RBX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rsp), /* USE_REG_RSP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rbp), /* USE_REG_RBP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rsi), /* USE_REG_RSI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, rdi), /* USE_REG_RDI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r8), /* USE_REG_R8 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r9), /* USE_REG_R9 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r10), /* USE_REG_R10 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r11), /* USE_REG_R11 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r12), /* USE_REG_R12 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r13), /* USE_REG_R13 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r14), /* USE_REG_R14 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r15) /* USE_REG_R15 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Macro for accessing 64-bit general purpose registers in CPUMCTXCORE structure.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_READ_REG64(p, idx) (*(uint64_t *)((char *)(p) + g_aReg64Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_WRITE_REG64(p, idx, val) (*(uint64_t *)((char *)(p) + g_aReg64Index[idx]) = val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_PTR_REG64(p, idx) ( (uint64_t *)((char *)(p) + g_aReg64Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Array for accessing 32-bit general registers in VMMREGFRAME structure
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * by register's index from disasm.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aReg32Index[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, eax), /* USE_REG_EAX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ecx), /* USE_REG_ECX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edx), /* USE_REG_EDX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebx), /* USE_REG_EBX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esp), /* USE_REG_ESP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebp), /* USE_REG_EBP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esi), /* USE_REG_ESI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edi), /* USE_REG_EDI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r8), /* USE_REG_R8D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r9), /* USE_REG_R9D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r10), /* USE_REG_R10D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r11), /* USE_REG_R11D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r12), /* USE_REG_R12D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r13), /* USE_REG_R13D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r14), /* USE_REG_R14D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r15) /* USE_REG_R15D */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Macro for accessing 32-bit general purpose registers in CPUMCTXCORE structure.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_READ_REG32(p, idx) (*(uint32_t *)((char *)(p) + g_aReg32Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/* From http://www.cs.cmu.edu/~fp/courses/15213-s06/misc/asm64-handout.pdf:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * ``Perhaps unexpectedly, instructions that move or generate 32-bit register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * values also set the upper 32 bits of the register to zero. Consequently
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * there is no need for an instruction movzlq.''
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_WRITE_REG32(p, idx, val) (*(uint64_t *)((char *)(p) + g_aReg32Index[idx]) = (uint32_t)val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_PTR_REG32(p, idx) ( (uint32_t *)((char *)(p) + g_aReg32Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Array for accessing 16-bit general registers in CPUMCTXCORE structure
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * by register's index from disasm.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aReg16Index[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, eax), /* USE_REG_AX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ecx), /* USE_REG_CX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edx), /* USE_REG_DX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebx), /* USE_REG_BX */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esp), /* USE_REG_SP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebp), /* USE_REG_BP */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esi), /* USE_REG_SI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edi), /* USE_REG_DI */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r8), /* USE_REG_R8W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r9), /* USE_REG_R9W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r10), /* USE_REG_R10W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r11), /* USE_REG_R11W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r12), /* USE_REG_R12W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r13), /* USE_REG_R13W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r14), /* USE_REG_R14W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r15) /* USE_REG_R15W */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Macro for accessing 16-bit general purpose registers in CPUMCTXCORE structure.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_READ_REG16(p, idx) (*(uint16_t *)((char *)(p) + g_aReg16Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_WRITE_REG16(p, idx, val) (*(uint16_t *)((char *)(p) + g_aReg16Index[idx]) = val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_PTR_REG16(p, idx) ( (uint16_t *)((char *)(p) + g_aReg16Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Array for accessing 8-bit general registers in CPUMCTXCORE structure
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * by register's index from disasm.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aReg8Index[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, eax), /* USE_REG_AL */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ecx), /* USE_REG_CL */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edx), /* USE_REG_DL */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebx), /* USE_REG_BL */
d6d241114679140e07ab40acda5adf0fc87b0c85vboxsync RT_OFFSETOF_ADD(CPUMCTXCORE, eax, 1), /* USE_REG_AH */
d6d241114679140e07ab40acda5adf0fc87b0c85vboxsync RT_OFFSETOF_ADD(CPUMCTXCORE, ecx, 1), /* USE_REG_CH */
d6d241114679140e07ab40acda5adf0fc87b0c85vboxsync RT_OFFSETOF_ADD(CPUMCTXCORE, edx, 1), /* USE_REG_DH */
d6d241114679140e07ab40acda5adf0fc87b0c85vboxsync RT_OFFSETOF_ADD(CPUMCTXCORE, ebx, 1), /* USE_REG_BH */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r8), /* USE_REG_R8B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r9), /* USE_REG_R9B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r10), /* USE_REG_R10B*/
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r11), /* USE_REG_R11B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r12), /* USE_REG_R12B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r13), /* USE_REG_R13B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r14), /* USE_REG_R14B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, r15), /* USE_REG_R15B */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esp), /* USE_REG_SPL; with REX prefix only */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ebp), /* USE_REG_BPL; with REX prefix only */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esi), /* USE_REG_SIL; with REX prefix only */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, edi) /* USE_REG_DIL; with REX prefix only */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Macro for accessing 8-bit general purpose registers in CPUMCTXCORE structure.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_READ_REG8(p, idx) (*(uint8_t *)((char *)(p) + g_aReg8Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_WRITE_REG8(p, idx, val) (*(uint8_t *)((char *)(p) + g_aReg8Index[idx]) = val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_PTR_REG8(p, idx) ( (uint8_t *)((char *)(p) + g_aReg8Index[idx]))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Array for accessing segment registers in CPUMCTXCORE structure
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * by register's index from disasm.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aRegSegIndex[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, es), /* DIS_SELREG_ES */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, cs), /* DIS_SELREG_CS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ss), /* DIS_SELREG_SS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ds), /* DIS_SELREG_DS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, fs), /* DIS_SELREG_FS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, gs) /* DIS_SELREG_GS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncstatic const unsigned g_aRegHidSegIndex[] =
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, esHid), /* DIS_SELREG_ES */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, csHid), /* DIS_SELREG_CS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, ssHid), /* DIS_SELREG_SS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, dsHid), /* DIS_SELREG_DS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, fsHid), /* DIS_SELREG_FS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync RT_OFFSETOF(CPUMCTXCORE, gsHid) /* DIS_SELREG_GS */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync};
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Macro for accessing segment registers in CPUMCTXCORE structure.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_READ_REGSEG(p, idx) (*((uint16_t *)((char *)(p) + g_aRegSegIndex[idx])))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync#define DIS_WRITE_REGSEG(p, idx, val) (*((uint16_t *)((char *)(p) + g_aRegSegIndex[idx])) = val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISGetParamSize(PDISCPUSTATE pCpu, POP_PARAMETER pParam)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync int subtype = OP_PARM_VSUBTYPE(pParam->param);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (subtype == OP_PARM_v)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync switch(pCpu->opmode)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case CPUMODE_32BIT:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync subtype = OP_PARM_d;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync break;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case CPUMODE_64BIT:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync subtype = OP_PARM_q;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync break;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case CPUMODE_16BIT:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync subtype = OP_PARM_w;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync break;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync default:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync /* make gcc happy */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync break;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync switch(subtype)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_b:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 1;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_w:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 2;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_d:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 4;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_q:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_dq:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case OP_PARM_p: /* far pointer */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->addrmode == CPUMODE_32BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 6; /* 16:32 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->addrmode == CPUMODE_64BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 12; /* 16:64 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 4; /* 16:16 */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync default:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->size)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return pParam->size;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else //@todo dangerous!!!
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 4;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(DIS_SELREG) DISDetectSegReg(PDISCPUSTATE pCpu, POP_PARAMETER pParam)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->prefix & PREFIX_SEG)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync /* Use specified SEG: prefix. */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return pCpu->enmPrefixSeg;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync /* Guess segment register by parameter type. */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_REG_GEN32|USE_REG_GEN64|USE_REG_GEN16))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(USE_REG_ESP == USE_REG_RSP);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(USE_REG_EBP == USE_REG_RBP);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(USE_REG_ESP == USE_REG_SP);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(USE_REG_EBP == USE_REG_BP);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->base.reg_gen == USE_REG_ESP || pParam->base.reg_gen == USE_REG_EBP)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return DIS_SELREG_SS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync /* Default is use DS: for data access. */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return DIS_SELREG_DS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(uint8_t) DISQuerySegPrefixByte(PDISCPUSTATE pCpu)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pCpu->prefix & PREFIX_SEG);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync switch(pCpu->enmPrefixSeg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_ES:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x26;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_CS:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x2E;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_SS:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x36;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_DS:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x3E;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_FS:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync case DIS_SELREG_GS:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0x65;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync default:
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertFailed();
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return 0;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified 8 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchReg8(PCCPUMCTXCORE pCtx, unsigned reg8, uint8_t *pVal)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg8 < RT_ELEMENTS(g_aReg8Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REG8(pCtx, reg8);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified 16 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchReg16(PCCPUMCTXCORE pCtx, unsigned reg16, uint16_t *pVal)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg16 < RT_ELEMENTS(g_aReg16Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REG16(pCtx, reg16);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified 32 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchReg32(PCCPUMCTXCORE pCtx, unsigned reg32, uint32_t *pVal)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg32 < RT_ELEMENTS(g_aReg32Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REG32(pCtx, reg32);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified 64 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchReg64(PCCPUMCTXCORE pCtx, unsigned reg64, uint64_t *pVal)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg64 < RT_ELEMENTS(g_aReg64Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REG64(pCtx, reg64);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the pointer to the specified 8 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISPtrReg8(PCPUMCTXCORE pCtx, unsigned reg8, uint8_t **ppReg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg8 < RT_ELEMENTS(g_aReg8Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = DIS_PTR_REG8(pCtx, reg8);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the pointer to the specified 16 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISPtrReg16(PCPUMCTXCORE pCtx, unsigned reg16, uint16_t **ppReg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg16 < RT_ELEMENTS(g_aReg16Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = DIS_PTR_REG16(pCtx, reg16);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the pointer to the specified 32 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISPtrReg32(PCPUMCTXCORE pCtx, unsigned reg32, uint32_t **ppReg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg32 < RT_ELEMENTS(g_aReg32Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = DIS_PTR_REG32(pCtx, reg32);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the pointer to the specified 64 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISPtrReg64(PCPUMCTXCORE pCtx, unsigned reg64, uint64_t **ppReg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg64 < RT_ELEMENTS(g_aReg64Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = DIS_PTR_REG64(pCtx, reg64);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified segment register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchRegSeg(PCCPUMCTXCORE pCtx, DIS_SELREG sel, RTSEL *pVal)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn((unsigned)sel < RT_ELEMENTS(g_aRegSegIndex), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(sizeof(uint16_t) == sizeof(RTSEL));
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REGSEG(pCtx, sel);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the specified segment register including a pointer to the hidden register in the supplied cpu context
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISFetchRegSegEx(PCCPUMCTXCORE pCtx, DIS_SELREG sel, RTSEL *pVal, CPUMSELREGHID **ppSelHidReg)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn((unsigned)sel < RT_ELEMENTS(g_aRegSegIndex), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(sizeof(uint16_t) == sizeof(RTSEL));
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pVal = DIS_READ_REGSEG(pCtx, sel);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppSelHidReg = (CPUMSELREGHID *)((char *)pCtx + g_aRegHidSegIndex[sel]);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Updates the value of the specified 64 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISWriteReg64(PCPUMCTXCORE pRegFrame, unsigned reg64, uint64_t val64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg64 < RT_ELEMENTS(g_aReg64Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync DIS_WRITE_REG64(pRegFrame, reg64, val64);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Updates the value of the specified 32 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISWriteReg32(PCPUMCTXCORE pRegFrame, unsigned reg32, uint32_t val32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg32 < RT_ELEMENTS(g_aReg32Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync DIS_WRITE_REG32(pRegFrame, reg32, val32);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Updates the value of the specified 16 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISWriteReg16(PCPUMCTXCORE pRegFrame, unsigned reg16, uint16_t val16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg16 < RT_ELEMENTS(g_aReg16Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync DIS_WRITE_REG16(pRegFrame, reg16, val16);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Updates the specified 8 bits general purpose register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISWriteReg8(PCPUMCTXCORE pRegFrame, unsigned reg8, uint8_t val8)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn(reg8 < RT_ELEMENTS(g_aReg8Index), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync DIS_WRITE_REG8(pRegFrame, reg8, val8);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Updates the specified segment register
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISWriteRegSeg(PCPUMCTXCORE pCtx, DIS_SELREG sel, RTSEL val)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
e9a584ee0777ab2612e206eeec264ccb1a8ce333vboxsync AssertReturn((unsigned)sel < RT_ELEMENTS(g_aRegSegIndex), VERR_INVALID_PARAMETER);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertCompile(sizeof(uint16_t) == sizeof(RTSEL));
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync DIS_WRITE_REGSEG(pCtx, sel, val);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the value of the parameter in pParam
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @returns VBox error code
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pCtx CPU context structure pointer
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pCpu Pointer to cpu structure which have DISCPUSTATE::mode
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * set correctly.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pParam Pointer to the parameter to parse
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pParamVal Pointer to parameter value (OUT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param parmtype Parameter type
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @note Currently doesn't handle FPU/XMM/MMX/3DNow! parameters correctly!!
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISQueryParamVal(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, POP_PARAMVAL pParamVal, PARAM_TYPE parmtype)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync memset(pParamVal, 0, sizeof(*pParamVal));
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (DIS_IS_EFFECTIVE_ADDR(pParam->flags))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync // Effective address
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->type = PARMTYPE_ADDRESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = pParam->size;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_BASE)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN8)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL8;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg8(pCtx, pParam->base.reg_gen, &pParamVal->val.val8))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL16;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg16(pCtx, pParam->base.reg_gen, &pParamVal->val.val16))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL32;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg32(pCtx, pParam->base.reg_gen, &pParamVal->val.val32))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL64;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg64(pCtx, pParam->base.reg_gen, &pParamVal->val.val64))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertFailed();
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync // Note that scale implies index (SIB byte)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_INDEX)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint16_t val16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL16;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg16(pCtx, pParam->index.reg_gen, &val16))) return VERR_INVALID_PARAMETER;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(!(pParam->flags & USE_SCALE)); /* shouldn't be possible in 16 bits mode */
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val16 += val16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint32_t val32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL32;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg32(pCtx, pParam->index.reg_gen, &val32))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_SCALE)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync val32 *= pParam->scale;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val32 += val32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint64_t val64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL64;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg64(pCtx, pParam->index.reg_gen, &val64))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_SCALE)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync val64 *= pParam->scale;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 += val64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync AssertFailed();
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_DISPLACEMENT8)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->mode == CPUMODE_32BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val32 += (int32_t)pParam->disp8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->mode == CPUMODE_64BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 += (int64_t)pParam->disp8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val16 += (int16_t)pParam->disp8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_DISPLACEMENT16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->mode == CPUMODE_32BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val32 += (int32_t)pParam->disp16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->mode == CPUMODE_64BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 += (int64_t)pParam->disp16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val16 += pParam->disp16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_DISPLACEMENT32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pCpu->mode == CPUMODE_32BIT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val32 += pParam->disp32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 += pParam->disp32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_DISPLACEMENT64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pCpu->mode == CPUMODE_64BIT);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 += (int64_t)pParam->disp64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_RIPDISPLACEMENT32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pCpu->mode == CPUMODE_64BIT);
7d126da2d4ddf0f075dbdce89c2fb953a464e6bfvboxsync /* Relative to the RIP of the next instruction. */
7d126da2d4ddf0f075dbdce89c2fb953a464e6bfvboxsync pParamVal->val.val64 += pParam->disp32 + pCtx->rip + pCpu->opsize;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_REG_GEN8|USE_REG_GEN16|USE_REG_GEN32|USE_REG_GEN64|USE_REG_FP|USE_REG_MMX|USE_REG_XMM|USE_REG_CR|USE_REG_DBG|USE_REG_SEG|USE_REG_TEST))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (parmtype == PARAM_DEST)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync // Caller needs to interpret the register according to the instruction (source/target, special value etc)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->type = PARMTYPE_REGISTER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = pParam->size;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync //else PARAM_SOURCE
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->type = PARMTYPE_IMMEDIATE;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN8)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint8_t);
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg8(pCtx, pParam->base.reg_gen, &pParamVal->val.val8))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint16_t);
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg16(pCtx, pParam->base.reg_gen, &pParamVal->val.val16))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint32_t);
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg32(pCtx, pParam->base.reg_gen, &pParamVal->val.val32))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint64_t);
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_FAILURE(DISFetchReg64(pCtx, pParam->base.reg_gen, &pParamVal->val.val64))) return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync // Caller needs to interpret the register according to the instruction (source/target, special value etc)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->type = PARMTYPE_REGISTER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(!(pParam->flags & USE_IMMEDIATE));
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_IMMEDIATE)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->type = PARMTYPE_IMMEDIATE;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE8|USE_IMMEDIATE8_REL))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL8;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->size == 2)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint16_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val16 = (uint8_t)pParam->parval;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint8_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val8 = (uint8_t)pParam->parval;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE16|USE_IMMEDIATE16_REL|USE_IMMEDIATE_ADDR_0_16|USE_IMMEDIATE16_SX8))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint16_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val16 = (uint16_t)pParam->parval;
cca8c8c55206ccd60f1b32843a67ce737447ac60vboxsync AssertMsg(pParamVal->size == pParam->size || ((pParam->size == 1) && (pParam->flags & USE_IMMEDIATE16_SX8)), ("pParamVal->size %d vs %d EIP=%RX32\n", pParamVal->size, pParam->size, pCtx->eip) );
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE32|USE_IMMEDIATE32_REL|USE_IMMEDIATE_ADDR_0_32|USE_IMMEDIATE32_SX8))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint32_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val32 = (uint32_t)pParam->parval;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pParamVal->size == pParam->size || ((pParam->size == 1) && (pParam->flags & USE_IMMEDIATE32_SX8)) );
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE64 | USE_IMMEDIATE64_REL | USE_IMMEDIATE64_SX8))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VAL64;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint64_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.val64 = pParam->parval;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pParamVal->size == pParam->size || ((pParam->size == 1) && (pParam->flags & USE_IMMEDIATE64_SX8)) );
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE_ADDR_16_16))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VALFARPTR16;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint16_t)*2;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.farptr.sel = (uint16_t)RT_LOWORD(pParam->parval >> 16);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.farptr.offset = (uint32_t)RT_LOWORD(pParam->parval);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pParamVal->size == pParam->size);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_IMMEDIATE_ADDR_16_32))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->flags |= PARAM_VALFARPTR32;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->size = sizeof(uint16_t) + sizeof(uint32_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.farptr.sel = (uint16_t)RT_LOWORD(pParam->parval >> 32);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync pParamVal->val.farptr.offset = (uint32_t)(pParam->parval & 0xFFFFFFFF);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync Assert(pParam->size == 8);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync/**
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * Returns the pointer to a register of the parameter in pParam. We need this
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * pointer when an interpreted instruction updates a register as a side effect.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * In CMPXCHG we know that only [r/e]ax is updated, but with XADD this could
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * be every register.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @returns VBox error code
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pCtx CPU context structure pointer
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pCpu Pointer to cpu structure which have DISCPUSTATE::mode
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * set correctly.
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pParam Pointer to the parameter to parse
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param pReg Pointer to parameter value (OUT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @param cbsize Parameter size (OUT)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync * @note Currently doesn't handle FPU/XMM/MMX/3DNow! parameters correctly!!
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync */
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsyncDISDECL(int) DISQueryParamRegPtr(PCPUMCTXCORE pCtx, PDISCPUSTATE pCpu, POP_PARAMETER pParam, void **ppReg, size_t *pcbSize)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync{
f5eadb22976c1f9813300e4042b8255cfaef7e19vboxsync NOREF(pCpu);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & (USE_REG_GEN8|USE_REG_GEN16|USE_REG_GEN32|USE_REG_FP|USE_REG_MMX|USE_REG_XMM|USE_REG_CR|USE_REG_DBG|USE_REG_SEG|USE_REG_TEST))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN8)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint8_t *pu8Reg;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_SUCCESS(DISPtrReg8(pCtx, pParam->base.reg_gen, &pu8Reg)))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pcbSize = sizeof(uint8_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = (void *)pu8Reg;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN16)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint16_t *pu16Reg;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_SUCCESS(DISPtrReg16(pCtx, pParam->base.reg_gen, &pu16Reg)))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pcbSize = sizeof(uint16_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = (void *)pu16Reg;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN32)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint32_t *pu32Reg;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_SUCCESS(DISPtrReg32(pCtx, pParam->base.reg_gen, &pu32Reg)))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pcbSize = sizeof(uint32_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = (void *)pu32Reg;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync else
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync if (pParam->flags & USE_REG_GEN64)
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync uint64_t *pu64Reg;
240f7d7012a5f64bcde850bcf048531a710d81cfvboxsync if (RT_SUCCESS(DISPtrReg64(pCtx, pParam->base.reg_gen, &pu64Reg)))
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync {
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *pcbSize = sizeof(uint64_t);
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync *ppReg = (void *)pu64Reg;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VINF_SUCCESS;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync }
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync return VERR_INVALID_PARAMETER;
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync}
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************
b4aee06a140a74517eedd6e55625cb88bd7b3d87vboxsync//*****************************************************************************