From 2845020e51d8e67d910d26c2eda0f400272a4d3e Mon Sep 17 00:00:00 2001 From: 0vercl0k <1476421+0vercl0k@users.noreply.github.com> Date: Mon, 17 Jan 2022 02:00:41 -0800 Subject: [PATCH] move the fixes for https://github.com/BeaEngine/beaengine/issues/39 at the right spots --- .../beaengine/src/Includes/Routines_ModRM.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/third_party/beaengine/src/Includes/Routines_ModRM.c b/src/third_party/beaengine/src/Includes/Routines_ModRM.c index dc5a59c..bd56451 100644 --- a/src/third_party/beaengine/src/Includes/Routines_ModRM.c +++ b/src/third_party/beaengine/src/Includes/Routines_ModRM.c @@ -173,9 +173,13 @@ void __bea_callspec__ fillRegister(int index, OPTYPE* pMyOperand, PDISASM pMyDis OperandSize8Reg(pMyOperand, pMyDisasm, i, index); break; case 16: + if (index >= 0 && index < 16) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) pMyOperand->OpMnemonic+i, Registers16Bits[index]); #endif + } else { + pMyOperand->OpMnemonic[i] = 0; + } pMyOperand->OpType = REGISTER_TYPE; pMyOperand->Registers.type = GENERAL_REG; pMyOperand->Registers.gpr = REGS[index]; @@ -191,9 +195,13 @@ void __bea_callspec__ fillRegister(int index, OPTYPE* pMyOperand, PDISASM pMyDis pMyOperand->OpSize = 32; break; case 64: + if (index >= 0 && index < 16) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) pMyOperand->OpMnemonic+i, Registers64Bits[index]); #endif + } else { + pMyOperand->OpMnemonic[i] = 0; + } pMyOperand->OpType = REGISTER_TYPE; pMyOperand->Registers.type = GENERAL_REG; pMyOperand->Registers.gpr = REGS[index]; @@ -1436,13 +1444,9 @@ void __bea_callspec__ fillModrm3Register(OPTYPE* pMyOperand, PDISASM pMyDisasm, switch (GV.OperandSize) { case 64: index_final = (GV.REX.B_ == 1) ? index + 8 : index + 0; - if (index >= 0 && index < 16) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) pMyOperand->OpMnemonic+i, Registers64Bits[index_final]); #endif - } else { - pMyOperand->OpMnemonic[i] = 0; - } pMyOperand->OpType = REGISTER_TYPE; pMyOperand->Registers.type = GENERAL_REG; pMyOperand->Registers.gpr = REGS[index_final]; @@ -1461,13 +1465,9 @@ void __bea_callspec__ fillModrm3Register(OPTYPE* pMyOperand, PDISASM pMyDisasm, case 16: index_final = (GV.REX.B_ == 1) ? index + 8 : index + 0; - if (index >= 0 && index < 16) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) pMyOperand->OpMnemonic+i, Registers16Bits[index_final]); #endif - } else { - pMyOperand->OpMnemonic[i] = 0; - } pMyOperand->OpType = REGISTER_TYPE; pMyOperand->Registers.type = GENERAL_REG; pMyOperand->Registers.gpr = REGS[index_final];