Constantified opcodes

This commit is contained in:
PatrickvL 2017-02-09 15:43:05 +01:00
parent 0a0d9f569a
commit fef5c793b3
3 changed files with 10 additions and 5 deletions

View File

@ -46,6 +46,11 @@
extern "C" {
#endif
#define OPCODE_NOP_90 0x90
#define OPCODE_INT3_CC 0xCC
#define OPCODE_CALL_E8 0xE8
#define OPCODE_JMP_E9 0xE9
/*! xbaddr is the type of a physical address */
typedef uint32 xbaddr;

View File

@ -311,12 +311,12 @@ void EmuInitFS()
DbgPrintf("Patching FS Instruction at 0x%08X\n", addr);
// Write Call opcode
*(uint08*)addr = 0xE8;
*(uint08*)addr = OPCODE_CALL_E8;
*(uint32*)(addr + 1) = (uint32)fsInstructions[i].functionPtr - addr - 5;
// Fill the remaining bytes with nop instructions
int remaining_bytes = fsInstructions[i].data.size() - 5;
memset((void*)(addr + 5), 0x90, remaining_bytes);
memset((void*)(addr + 5), OPCODE_NOP_90, remaining_bytes);
addr += sizeOfData - 1;
break;
}

View File

@ -602,7 +602,7 @@ static inline void EmuInstallPatch(xbaddr FunctionAddr, void *Patch)
{
uint08 *FuncBytes = (uint08*)FunctionAddr;
*(uint08*)&FuncBytes[0] = 0xE9; // = opcode for JMP rel32 (Jump near, relative, displacement relative to next instruction)
*(uint08*)&FuncBytes[0] = OPCODE_JMP_E9; // = opcode for JMP rel32 (Jump near, relative, displacement relative to next instruction)
*(uint32*)&FuncBytes[1] = (uint32)Patch - FunctionAddr - 5;
}
@ -742,8 +742,8 @@ static void EmuInstallPatches(OOVPATable *OovpaTable, uint32 OovpaTableSize, Xbe
// Only place an XRef trapping patch when the OOVPA registration wasn't disabled
if ((OovpaTable[a].Flags & Flag_DontScan) == 0)
{
// Insert breakpoint
*(uint8_t*)pFunc = 0xCC;
// Write breakpoint opcode
*(uint8_t*)pFunc = OPCODE_INT3_CC;
EmuInstallPatch(pFunc + 1, EmuXRefFailure);
}
}