PATMPatch.h revision 17ba03925269c071aa1567eb8c5a49c37a65f62f
20593760b116c90f3e439552763eef632a3bbb17vboxsync * PATMPatch - Internal header file.
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync * Copyright (C) 2006-2007 innotek GmbH
20593760b116c90f3e439552763eef632a3bbb17vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
20593760b116c90f3e439552763eef632a3bbb17vboxsync * available from http://www.virtualbox.org. This file is free software;
20593760b116c90f3e439552763eef632a3bbb17vboxsync * you can redistribute it and/or modify it under the terms of the GNU
20593760b116c90f3e439552763eef632a3bbb17vboxsync * General Public License as published by the Free Software Foundation,
20593760b116c90f3e439552763eef632a3bbb17vboxsync * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
20593760b116c90f3e439552763eef632a3bbb17vboxsync * distribution. VirtualBox OSE is distributed in the hope that it will
20593760b116c90f3e439552763eef632a3bbb17vboxsync * be useful, but WITHOUT ANY WARRANTY of any kind.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * If you received this file as part of a commercial VirtualBox
20593760b116c90f3e439552763eef632a3bbb17vboxsync * distribution, then only the terms of your commercial VirtualBox
20593760b116c90f3e439552763eef632a3bbb17vboxsync * license agreement apply instead of the previous paragraph.
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchAddReloc32(PVM pVM, PPATCHINFO pPatch, uint8_t *pRelocHC, uint32_t uType, RTGCPTR pSource = 0, RTGCPTR pDest = 0);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchAddJump(PVM pVM, PPATCHINFO pPatch, uint8_t *pJumpHC, uint32_t offset, RTGCPTR pTargetGC, uint32_t opcode);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenCpuid(PVM pVM, PPATCHINFO pPatch, RTGCPTR pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenSxDT(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenSldtStr(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenMovControl(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenMovDebug(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu);
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncint patmPatchGenMovFromSS(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenRelJump(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t *) pTargetGC, uint32_t opcode, bool fSizeOverride);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenLoop(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t *) pTargetGC, uint32_t opcode, bool fSizeOverride);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenPushf(PVM pVM, PPATCHINFO pPatch, bool fSizeOverride);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenPopf(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t *) pReturnAddrGC, bool fSizeOverride, bool fGenJumpBack);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenSti(PVM pVM, PPATCHINFO pPatch, RTGCPTR pCurInstrGC, RTGCPTR pNextInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenIret(PVM pVM, PPATCHINFO pPatch, RTGCPTR pCurInstrGC, bool fSizeOverride);
ea9fe8748652b3e7b3f1245001f9d7cd8c9eaaccvboxsyncint patmPatchGenDuplicate(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, GCPTRTYPE(uint8_t *) pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenStats(PVM pVM, PPATCHINFO pPatch, RTGCPTR pInstrGC);
0c8eec6f5b79d800c3d25b5c0e0d7ad3f867c25cvboxsyncint patmPatchGenCall(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR pInstrGC, RTGCPTR pTargetGC, bool fIndirect);
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenRet(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, GCPTRTYPE(uint8_t *) pCurInstrGC);
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncint patmPatchGenPatchJump(PVM pVM, PPATCHINFO pPatch, RTGCPTR pCurInstrGC, GCPTRTYPE(uint8_t *) pPatchAddrGC, bool fAddLookupRecord = true);
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Generate indirect jump to unknown destination
ea9fe8748652b3e7b3f1245001f9d7cd8c9eaaccvboxsync * @returns VBox status code.
ea9fe8748652b3e7b3f1245001f9d7cd8c9eaaccvboxsync * @param pVM The VM to operate on.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pPatch Patch record
ea9fe8748652b3e7b3f1245001f9d7cd8c9eaaccvboxsync * @param pCpu Disassembly state
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pCurInstrGC Current instruction address
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenJump(PVM pVM, PPATCHINFO pPatch, DISCPUSTATE *pCpu, RTGCPTR pCurInstrGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Generate a trap handler entrypoint
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @returns VBox status code.
e86538a7bc028e823f16f8982e90f0c7ef5d4ecevboxsync * @param pVM The VM to operate on.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pPatch Patch record
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pTrapHandlerGC IDT handler address
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncint patmPatchGenTrapEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR pTrapHandlerGC);
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Generate an interrupt handler entrypoint
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @returns VBox status code.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pVM The VM to operate on.
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync * @param pPatch Patch record
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pIntHandlerGC IDT handler address
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncint patmPatchGenIntEntry(PVM pVM, PPATCHINFO pPatch, RTGCPTR pIntHandlerGC);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * Generate the jump from guest to patch code
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @returns VBox status code.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @param pVM The VM to operate on.
0f7b309cca2790ee47e71b5aa1817803b652f253vboxsync * @param pPatch Patch record
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @param pTargetGC Guest target jump
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @param fClearInhibitIRQs Clear inhibit irq flag
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsyncint patmPatchGenJumpToGuest(PVM pVM, PPATCHINFO pPatch, GCPTRTYPE(uint8_t *) pReturnAddrGC, bool fClearInhibitIRQs = false);
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * Generate illegal instruction (int 3)
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @returns VBox status code.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @param pVM The VM to operate on.
e9525bea57dc13d82fd3392913aebb33d2cb79e3vboxsync * @param pPatch Patch structure
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenIllegalInstr(PVM pVM, PPATCHINFO pPatch);
20593760b116c90f3e439552763eef632a3bbb17vboxsync * Set PATM interrupt flag
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync * @returns VBox status code.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pVM The VM to operate on.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pPatch Patch structure
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pInstrGC Corresponding guest instruction
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenSetPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR pInstrGC);
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsync * Clear PATM interrupt flag
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @returns VBox status code.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pVM The VM to operate on.
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pPatch Patch structure
20593760b116c90f3e439552763eef632a3bbb17vboxsync * @param pInstrGC Corresponding guest instruction
20593760b116c90f3e439552763eef632a3bbb17vboxsyncint patmPatchGenClearPIF(PVM pVM, PPATCHINFO pPatch, RTGCPTR pInstrGC);
a18faae7b59910c9f2da2886ac10d7f31e29cd83vboxsync * Clear PATM inhibit irq flag
a18faae7b59910c9f2da2886ac10d7f31e29cd83vboxsync * @returns VBox status code.
a18faae7b59910c9f2da2886ac10d7f31e29cd83vboxsync * @param pVM The VM to operate on.
a18faae7b59910c9f2da2886ac10d7f31e29cd83vboxsync * @param pPatch Patch structure
a18faae7b59910c9f2da2886ac10d7f31e29cd83vboxsync * @param pNextInstrGC Next guest instruction
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsyncint patmPatchGenClearInhibitIRQ(PVM pVM, PPATCHINFO pPatch, RTGCPTR pNextInstrGC);
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsync * Check virtual IF flag and jump back to original guest code if set
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsync * @returns VBox status code.
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsync * @param pVM The VM to operate on.
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsync * @param pPatch Patch structure
e00b7e275dee70ffbd9e00a3e3e3e8513287e2b2vboxsync * @param pCurInstrGC Guest context pointer to the current instruction