CSAMInternal.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
/* $Id$ */
/** @file
* CSAM - Internal header file.
*/
/*
* Copyright (C) 2006-2007 innotek GmbH
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License as published by the Free Software Foundation,
* in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
* distribution. VirtualBox OSE is distributed in the hope that it will
* be useful, but WITHOUT ANY WARRANTY of any kind.
*
* If you received this file as part of a commercial VirtualBox
* distribution, then only the terms of your commercial VirtualBox
* license agreement apply instead of the previous paragraph.
*/
#ifndef ___CSAMInternal_h
#define ___CSAMInternal_h
# error "Not in CSAM! This is an internal header!"
#endif
/** Page flags.
* These are placed in the three bits available for system programs in
* the page entries.
* @{ */
#ifndef PGM_PTFLAGS_CSAM_VALIDATED
/** Scanned and approved by CSAM (tm). */
/** NOTE: Must be identical to the one defined in PGMInternal.h!! */
#endif
/** @} */
#define CSAM_SSM_VERSION 14
#define CSAM_PGDIRBMP_CHUNKS 1024
/* Maximum nr of dirty page that are cached. */
#define CSAM_MAX_DIRTY_PAGES 32
/* Maximum number of cached addresses of dangerous instructions that have been scanned before. */
/* Maximum number of possible dangerous code pages that we'll flush after a world switch */
#define CSAM_MAX_CODE_PAGES_FLUSH 32
#define CSAM_MAX_CALLEXIT_RET 16
/* copy from PATMInternal.h */
typedef struct
{
typedef struct
{
typedef struct
{
bool fCode32;
bool fMonitorActive;
bool fMonitorInvalidation;
typedef struct
{
// GC Patch pointer
// Disassembly state for original instruction
} CSAMPATCH, *PCSAMPATCH;
/**
* Lookup record for CSAM pages
*/
typedef struct CSAMPAGEREC
{
/** The key is a GC virtual address. */
} CSAMPAGEREC, *PCSAMPAGEREC;
/**
* Lookup record for patches
*/
typedef struct CSAMPATCHREC
{
/** The key is a GC virtual address. */
/**
* CSAM VM Instance data.
* Changes to this must checked against the padding of the CSAM union in VM!
* @note change SSM version when changing it!!
*/
typedef struct CSAM
{
/** Offset to the VM structure.
* See CSAM2VM(). */
#if HC_ARCH_BITS == 64
#endif
/* Array to store previously scanned dangerous instructions, so we don't need to
* switch back to ring 3 each time we encounter them in GC.
*/
struct
{
} savedstate;
/* To keep track of dirty pages */
/* To keep track of possible code pages */
/* Set when scanning has started. */
bool fScanningStarted;
/* Set when the IDT gates have been checked for the first time. */
bool fGatesChecked;
/**
* Call for analyzing the instructions following the privileged instr. for compliance with our heuristics
*
* @returns VBox status code.
* @param pVM The VM to operate on.
* @param pCpu CPU disassembly state
* @param pInstrHC Guest context pointer to privileged instruction
* @param pCurInstrGC Guest context pointer to current instruction
* @param pUserData User pointer
*
*/
typedef int (VBOXCALL *PFN_CSAMR3ANALYSE)(PVM pVM, DISCPUSTATE *pCpu, GCPTRTYPE(uint8_t *) pInstrGC, GCPTRTYPE(uint8_t *) pCurInstrGC, PCSAMP2GLOOKUPREC pCacheRec, void *pUserData);
/**
* Check if the current instruction is the start of a known guest block that requires our attention
*
* @param pVM The VM to operate on.
* @param pInstrGC Guest context pointer of instruction to check
* @param pInstrHC Host context pointer of instruction to check
* @param opcode Opcode of instruction at pInstrGC
*
* @returns true if patched
*
*/
bool csamCheckGuestSpecificPatch(PVM pVM, RTGCPTR pInstrGC, HCPTRTYPE(uint8_t *) pInstrHC, uint32_t opcode);
/**
* Calculate the branch destination
*
* @returns branch destination or 0 if failed
* @param pCpu Disassembly state of instruction.
* @param pBranchInstrGC GC pointer of branch instruction
*/
{
{
}
else
{
}
else
{
}
else
{
return 0;
}
#ifdef IN_GC
#else
#endif
}
CSAMGCDECL(int) CSAMGCCodePageWriteHandler(PVM pVM, RTGCUINT uErrorCode, PCPUMCTXCORE pRegFrame, RTGCPTR pvFault, RTGCPTR pvRange, uintptr_t offRange);
#endif