diff --git a/.gitattributes b/.gitattributes index ceeda54e4374bf96398ea74aad2a399dbc19e2cd..3c4f10959047b3a230b074e8854b903711fd2c98 100644 --- a/.gitattributes +++ b/.gitattributes @@ -294,6 +294,9 @@ libtransform/tests/simpletest.c -text libtransform/tests/unsigned_add.c -text libtransform/tests/unsigned_mul.c -text third_party/README -text +third_party/beaengine166.tar.gz -text +third_party/beaengine175.tar.gz -text +third_party/do_bea_update.sh -text third_party/elfio-2.2.tar.gz -text third_party/sqlite-autoconf-3071300.tar.gz -text tools/Makefile -text diff --git a/beaengine/beaengineSources/Includes/Routines_Disasm.c b/beaengine/beaengineSources/Includes/Routines_Disasm.c index 90b78a802b925196d4a81a0623496f20dae76a6d..0efab2775092996659339f672f40ed02916a2c1b 100644 --- a/beaengine/beaengineSources/Includes/Routines_Disasm.c +++ b/beaengine/beaengineSources/Includes/Routines_Disasm.c @@ -92,7 +92,10 @@ int __bea_callspec__ InitVariables (PDISASM pMyDisasm) { (*pMyDisasm).Argument1.AccessMode = WRITE; (*pMyDisasm).Argument1.ArgPosition = LowPosition; (*pMyDisasm).Argument2.ArgPosition = LowPosition; - (*pMyDisasm).Argument3.ArgPosition = LowPosition; + (*pMyDisasm).Argument3.ArgPosition = LowPosition; + (*pMyDisasm).Argument1.ArgType = NO_ARGUMENT; + (*pMyDisasm).Argument2.ArgType = NO_ARGUMENT; + (*pMyDisasm).Argument3.ArgType = NO_ARGUMENT; (*pMyDisasm).Argument2.AccessMode = READ; (*pMyDisasm).Argument3.AccessMode = READ; (void) memset (&(*pMyDisasm).Instruction, 0, sizeof (INSTRTYPE)); @@ -254,7 +257,12 @@ void __bea_callspec__ EvIv(PDISASM pMyDisasm) GV.EIP_ += GV.DECALAGE_EIP+6; if (!Security(0, pMyDisasm)) return; #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) *((UInt32*)(UIntPtr) (GV.EIP_-4))); + if (GV.OperandSize == 64) { + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64) *((Int32*)(UIntPtr) (GV.EIP_-4))); + } + else { + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) *((UInt32*)(UIntPtr) (GV.EIP_-4))); + } #endif (*pMyDisasm).Argument2.ArgType = CONSTANT_TYPE+ABSOLUTE_; @@ -325,7 +333,7 @@ void __bea_callspec__ EvIb(PDISASM pMyDisasm, int signed_byte) (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64)*((UInt8*)(UIntPtr) (GV.EIP_-1))); } else { - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16lX",(Int64)*((Int8*)(IntPtr) (GV.EIP_-1))); + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64)*((Int8*)(IntPtr) (GV.EIP_-1))); } #endif } @@ -359,7 +367,7 @@ void __bea_callspec__ EbIb(PDISASM pMyDisasm) GV.EIP_ += GV.DECALAGE_EIP+3; if (!Security(0, pMyDisasm)) return; #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64)*((Int8*)(UIntPtr) (GV.EIP_-1))); #endif (*pMyDisasm).Instruction.Immediat = *((UInt8*)(UIntPtr) (GV.EIP_-1)); } @@ -456,7 +464,10 @@ void __bea_callspec__ GxEx(PDISASM pMyDisasm) void __bea_callspec__ GvEw(PDISASM pMyDisasm) { GV.MemDecoration = Arg2word; + GV.OriginalOperandSize = GV.OperandSize; + GV.OperandSize = 16; MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + GV.OperandSize = GV.OriginalOperandSize; Reg_Opcode(&(*pMyDisasm).Argument1, pMyDisasm); GV.EIP_ += GV.DECALAGE_EIP+2; } @@ -471,7 +482,7 @@ void __bea_callspec__ ALIb(PDISASM pMyDisasm) GV.ImmediatSize = 8; MyNumber = *((Int8*)(IntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) MyNumber); + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.2X",(Int64) MyNumber); #endif (*pMyDisasm).Instruction.Immediat = MyNumber; #ifndef BEA_LIGHT_DISASSEMBLY @@ -499,7 +510,7 @@ void __bea_callspec__ eAX_Iv(PDISASM pMyDisasm) (*pMyDisasm).Argument2.ArgSize = 32; MyNumber = *((UInt32*)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.8X",(Int64) MyNumber); + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument2.ArgMnemonic,"%.16llX",(Int64) MyNumber); #endif (*pMyDisasm).Instruction.Immediat = MyNumber; if (GV.REX.B_ == 1) { @@ -566,7 +577,7 @@ void __bea_callspec__ eAX_Iv(PDISASM pMyDisasm) * ==================================================================== */ int __bea_callspec__ Security(int len, PDISASM pMyDisasm) { - if ((GV.EndOfBlock != 0) && (GV.EIP_+(UInt64)len > GV.EndOfBlock)) { + if ((GV.EndOfBlock != 0) && (GV.EIP_+(UInt64)len >= GV.EndOfBlock)) { GV.OutOfBlock = 1; return 0; } @@ -601,6 +612,9 @@ void __bea_callspec__ CalculateRelativeAddress(UInt64 * pMyAddress, Int64 MyNumb size_t __bea_callspec__ CopyFormattedNumber(PDISASM pMyDisasm, char* pBuffer, const char* pFormat, Int64 MyNumber) { size_t i = 0; + if (!strcmp(pFormat,"%.2X")) MyNumber = MyNumber & 0xFF; + if (!strcmp(pFormat,"%.4X")) MyNumber = MyNumber & 0xFFFF; + if (!strcmp(pFormat,"%.8X")) MyNumber = MyNumber & 0xFFFFFFFF; if (GV.FORMATNUMBER == PrefixedNumeral) { (void) strcpy(pBuffer, "0x"); (void) sprintf (pBuffer+2, pFormat, MyNumber); @@ -621,14 +635,14 @@ size_t __bea_callspec__ CopyFormattedNumber(PDISASM pMyDisasm, char* pBuffer, co * ==================================================================== */ void __bea_callspec__ FillSegmentsRegisters(PDISASM pMyDisasm) { - if (((*pMyDisasm).Prefix.LockPrefix == InUsePrefix) && ((*pMyDisasm).Argument1.ArgType != MEMORY_TYPE)) { + if (((*pMyDisasm).Prefix.LockPrefix == InUsePrefix) && !((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE)) { (*pMyDisasm).Prefix.LockPrefix = InvalidPrefix; } if ((*pMyDisasm).Instruction.Category == GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION) { (*pMyDisasm).Argument1.SegmentReg = ESReg; (*pMyDisasm).Argument2.SegmentReg = DSReg; /* =============== override affects Arg2 */ - if ((*pMyDisasm).Argument2.ArgType == MEMORY_TYPE) { + if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) { if ((*pMyDisasm).Prefix.FSPrefix == InUsePrefix) { (*pMyDisasm).Argument2.SegmentReg = FSReg; } @@ -650,7 +664,7 @@ void __bea_callspec__ FillSegmentsRegisters(PDISASM pMyDisasm) } } else { - if ((*pMyDisasm).Argument1.ArgType == MEMORY_TYPE) { + if ((*pMyDisasm).Argument1.ArgType & MEMORY_TYPE) { if (((*pMyDisasm).Argument1.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument1.Memory.BaseRegister == REG5)) { (*pMyDisasm).Argument1.SegmentReg = SSReg; /* ========== override is invalid here */ @@ -702,7 +716,7 @@ void __bea_callspec__ FillSegmentsRegisters(PDISASM pMyDisasm) } } - if ((*pMyDisasm).Argument2.ArgType == MEMORY_TYPE) { + if ((*pMyDisasm).Argument2.ArgType & MEMORY_TYPE) { if (((*pMyDisasm).Argument2.Memory.BaseRegister == REG4) || ((*pMyDisasm).Argument2.Memory.BaseRegister == REG5)) { (*pMyDisasm).Argument2.SegmentReg = SSReg; /* ========== override is invalid here */ @@ -780,7 +794,7 @@ void __bea_callspec__ BuildCompleteInstruction(PDISASM pMyDisasm) /* =============== if TAB = 1, add tabulation */ if (GV.TAB_ == 1) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[10-i]); + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[i>10 ? 0 : 10-i]); i = strlen((char*) &(*pMyDisasm).CompleteInstr); } /* =============== if Arg1.IsMemoryType, add decoration-example == "dword ptr ds:[" */ @@ -853,8 +867,8 @@ void __bea_callspec__ BuildCompleteInstruction(PDISASM pMyDisasm) /* =============== if Arg2.Exists and Arg1.Exists , add"," */ if (((UInt8)*((UInt8*) &(*pMyDisasm).Argument1.ArgMnemonic) != 0) && ((UInt8)*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, " , "); - i += 3; + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); + i += 2; } /* =============== if Arg2.IsMemoryType, add decoration-example == "dword ptr ds:[" */ @@ -926,8 +940,8 @@ void __bea_callspec__ BuildCompleteInstruction(PDISASM pMyDisasm) /* =============== if Arg3.Exists */ if (GV.third_arg != 0) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, " , "); - i += 3; + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); + i += 2; (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, (char*) &(*pMyDisasm).Argument3.ArgMnemonic); } @@ -985,7 +999,7 @@ void __bea_callspec__ BuildCompleteInstructionATSyntax(PDISASM pMyDisasm) } /* =============== if TAB = 1, add tabulation */ if (GV.TAB_ == 1) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[10-i]); + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, space_tab[i>10 ? 0 : 10-i]); i = strlen((char*) &(*pMyDisasm).CompleteInstr); } @@ -1005,8 +1019,8 @@ void __bea_callspec__ BuildCompleteInstructionATSyntax(PDISASM pMyDisasm) /* =============== if Arg3.Exists and Arg2.Exists , display " , " */ if ((GV.third_arg != 0) && (*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, " , "); - i += 3; + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); + i += 2; } /* =============== if Arg2 exists, display it */ @@ -1048,8 +1062,8 @@ void __bea_callspec__ BuildCompleteInstructionATSyntax(PDISASM pMyDisasm) /* =============== if Arg2.Exists and Arg1.Exists , display " , " */ if (((UInt8)*((UInt8*) &(*pMyDisasm).Argument1.ArgMnemonic) != 0) && ((UInt8)*((UInt8*) &(*pMyDisasm).Argument2.ArgMnemonic) != 0)) { - (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, " , "); - i += 3; + (void) strcpy ((char*) &(*pMyDisasm).CompleteInstr+i, ", "); + i += 2; } /* =============== if Arg1 exists, display it */ diff --git a/beaengine/beaengineSources/Includes/Routines_ModRM.c b/beaengine/beaengineSources/Includes/Routines_ModRM.c index d58df51ef9f219a623a548214ac2d7b5309ae08a..f397543fc9f6a6d8ca2e31806e6b6f981f976024 100644 --- a/beaengine/beaengineSources/Includes/Routines_ModRM.c +++ b/beaengine/beaengineSources/Includes/Routines_ModRM.c @@ -189,6 +189,8 @@ void __bea_callspec__ Addr_EAX(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -247,6 +249,8 @@ void __bea_callspec__ Addr_ECX(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -304,6 +308,8 @@ void __bea_callspec__ Addr_EDX(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -361,6 +367,8 @@ void __bea_callspec__ Addr_EBX(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -429,8 +437,9 @@ void __bea_callspec__ Addr_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress, (Int64)MyNumber, pMyDisasm); (*pMyDisasm).Instruction.AddrValue = MyAddress; #ifndef BEA_LIGHT_DISASSEMBLY - i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%I64X", (Int64)MyAddress); + i+= CopyFormattedNumber(pMyDisasm, (char*) (*pMyArgument).ArgMnemonic+i,"%.16llX", (Int64)MyAddress); #endif + (*pMyArgument).ArgType |= RELATIVE_; } else { #ifndef BEA_LIGHT_DISASSEMBLY @@ -630,6 +639,8 @@ void __bea_callspec__ Addr_EAX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -728,6 +739,8 @@ void __bea_callspec__ Addr_ECX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -825,6 +838,8 @@ void __bea_callspec__ Addr_EDX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -922,6 +937,8 @@ void __bea_callspec__ Addr_EBX_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -1005,6 +1022,8 @@ void __bea_callspec__ Addr_SIB_disp8(ARGTYPE* pMyArgument, PDISASM pMyDisasm) (void) strcpy ((char*) (*pMyArgument).ArgMnemonic, Registers16Bits[6]); #endif i += strlen (Registers16Bits[6]); + (*pMyArgument).Memory.BaseRegister = REGS[6]; + } if (GV.SYNTAX_ == ATSyntax) { @@ -1399,6 +1418,8 @@ void __bea_callspec__ Addr_EAX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -1502,6 +1523,8 @@ void __bea_callspec__ Addr_ECX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BXDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[3]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -1604,6 +1627,8 @@ void __bea_callspec__ Addr_EDX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPSI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[6]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -1706,6 +1731,8 @@ void __bea_callspec__ Addr_EBX_disp32(ARGTYPE* pMyArgument, PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((char*) (*pMyArgument).ArgMnemonic+i, BPDI_); #endif + (*pMyArgument).Memory.BaseRegister = REGS[5]; + (*pMyArgument).Memory.IndexRegister = REGS[7]; } #ifndef BEA_LIGHT_DISASSEMBLY i = strlen ((char*) &(*pMyArgument).ArgMnemonic); @@ -3075,7 +3102,7 @@ size_t __bea_callspec__ SIB_0(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) /* ======================== Interpret Index */ - if (GV.INDEX_ != 4) { + if (GV.INDEX_ != 4 || GV.REX.X_) { if (GV.SYNTAX_ == ATSyntax) { if (GV.BASE_ == 5) { #ifndef BEA_LIGHT_DISASSEMBLY @@ -3131,7 +3158,7 @@ size_t __bea_callspec__ SIB_0(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } } (*pMyArgument).Memory.Scale = 1; - if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4))) { + if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_))) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")"); #endif @@ -3200,7 +3227,7 @@ size_t __bea_callspec__ SIB_1(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } /* ======================== Interpret Index */ - if (GV.INDEX_ != 4) { + if (GV.INDEX_ != 4 || GV.REX.X_) { if (GV.SYNTAX_ == ATSyntax) { if (GV.BASE_ == 5) { #ifndef BEA_LIGHT_DISASSEMBLY @@ -3256,7 +3283,7 @@ size_t __bea_callspec__ SIB_1(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } (*pMyArgument).Memory.Scale = 2; if (GV.SYNTAX_ == ATSyntax) { - if ((GV.BASE_ != 5) || (GV.INDEX_ != 4)) { + if ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_)) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ",2"); #endif @@ -3271,7 +3298,7 @@ size_t __bea_callspec__ SIB_1(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) i+=2; } } - if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4))) { + if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_))) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")"); #endif @@ -3396,7 +3423,7 @@ size_t __bea_callspec__ SIB_2(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } (*pMyArgument).Memory.Scale = 4; if (GV.SYNTAX_ == ATSyntax) { - if ((GV.BASE_ != 5) || (GV.INDEX_ != 4)) { + if ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_)) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ",4"); #endif @@ -3410,7 +3437,7 @@ size_t __bea_callspec__ SIB_2(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) i+=2; } } - if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4))) { + if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_))) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")"); #endif @@ -3479,7 +3506,7 @@ size_t __bea_callspec__ SIB_3(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } /* ======================== Interpret Index */ - if (GV.INDEX_ != 4) { + if (GV.INDEX_ != 4 || GV.REX.X_) { if (GV.SYNTAX_ == ATSyntax) { if (GV.BASE_ == 5) { #ifndef BEA_LIGHT_DISASSEMBLY @@ -3535,7 +3562,7 @@ size_t __bea_callspec__ SIB_3(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) } (*pMyArgument).Memory.Scale = 8; if (GV.SYNTAX_ == ATSyntax) { - if ((GV.BASE_ != 5) || (GV.INDEX_ != 4)) { + if ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_)) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ",8"); #endif @@ -3549,7 +3576,7 @@ size_t __bea_callspec__ SIB_3(ARGTYPE* pMyArgument, size_t i, PDISASM pMyDisasm) i+=2; } } - if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4))) { + if ((GV.SYNTAX_ == ATSyntax) && ((GV.BASE_ != 5) || (GV.INDEX_ != 4 || GV.REX.X_))) { #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy((char*) (*pMyArgument).ArgMnemonic+i, ")"); #endif diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c index 0c65b4a284fd653969d127d4a28c90515f252960..a128bfb067683e3d65d9059cb5ac8a7c060e384f 100644 --- a/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c +++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_A_M.c @@ -1060,7 +1060,7 @@ void __bea_callspec__ call_(PDISASM pMyDisasm) (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG4; if (MyAddress >= 0x80000000) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) &(*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -1094,6 +1094,7 @@ void __bea_callspec__ call_(PDISASM pMyDisasm) void __bea_callspec__ callf_(PDISASM pMyDisasm) { UInt32 MyNumber; + UInt64 MyAddress; size_t i = 0; if (GV.Architecture == 64) { FailDecode(pMyDisasm); @@ -1141,6 +1142,7 @@ void __bea_callspec__ callf_(PDISASM pMyDisasm) #endif i+=3; } + MyAddress = MyNumber*16; MyNumber = *((UInt32*)(UIntPtr) (GV.EIP_+1)); if (GV.OperandSize == 16) { MyNumber = MyNumber & 0xffff; @@ -1157,7 +1159,7 @@ void __bea_callspec__ callf_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+ABSOLUTE_; (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG4; - + (*pMyDisasm).Instruction.AddrValue = MyAddress + MyNumber; } } @@ -1167,7 +1169,8 @@ void __bea_callspec__ callf_(PDISASM pMyDisasm) void __bea_callspec__ cdq_(PDISASM pMyDisasm) { (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+DATA_TRANSFER; - (*pMyDisasm).Argument1.ArgType = REGISTER_TYPE+GENERAL_REG+REG0+REG3; + (*pMyDisasm).Argument1.ArgType = REGISTER_TYPE+GENERAL_REG+REG0+REG2; + (*pMyDisasm).Argument2.ArgType = REGISTER_TYPE+GENERAL_REG+REG0; if (GV.OperandSize == 64) { if (GV.SYNTAX_ == ATSyntax) { #ifndef BEA_LIGHT_DISASSEMBLY @@ -1576,6 +1579,16 @@ void __bea_callspec__ cmpsb_(PDISASM pMyDisasm) if ((*pMyDisasm).Prefix.RepPrefix == SuperfluousPrefix) { (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; } + + /* ========= 0xf3 */ + if (GV.PrefRepe == 1) { + (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; + } + /* ========= 0xf2 */ + if (GV.PrefRepne == 1) { + (*pMyDisasm).Prefix.RepnePrefix = InUsePrefix; + } + (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "cmpsb "); @@ -1602,6 +1615,14 @@ void __bea_callspec__ cmps_(PDISASM pMyDisasm) if ((*pMyDisasm).Prefix.RepPrefix == SuperfluousPrefix) { (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; } + /* ========= 0xf3 */ + if (GV.PrefRepe == 1) { + (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; + } + /* ========= 0xf2 */ + if (GV.PrefRepne == 1) { + (*pMyDisasm).Prefix.RepnePrefix = InUsePrefix; + } (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+STRING_INSTRUCTION; (*pMyDisasm).Argument1.ArgType = MEMORY_TYPE; (*pMyDisasm).Argument1.Memory.BaseRegister = REG7; @@ -2992,7 +3013,7 @@ void __bea_callspec__ jo_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3005,7 +3026,7 @@ void __bea_callspec__ jo_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } /* ======================================= @@ -3034,7 +3055,7 @@ void __bea_callspec__ jno_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3047,7 +3068,7 @@ void __bea_callspec__ jno_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } /* ======================================= @@ -3076,7 +3097,7 @@ void __bea_callspec__ jc_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3089,7 +3110,7 @@ void __bea_callspec__ jc_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } /* ======================================= @@ -3118,7 +3139,7 @@ void __bea_callspec__ jnc_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3131,7 +3152,7 @@ void __bea_callspec__ jnc_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } /* ======================================= * 74h @@ -3159,7 +3180,7 @@ void __bea_callspec__ je_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3172,7 +3193,7 @@ void __bea_callspec__ je_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,118); } /* ======================================= @@ -3201,7 +3222,7 @@ void __bea_callspec__ jne_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3243,7 +3264,7 @@ void __bea_callspec__ jbe_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3256,7 +3277,7 @@ void __bea_callspec__ jbe_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,119); } /* ======================================= @@ -3285,7 +3306,7 @@ void __bea_callspec__ jnbe_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3298,7 +3319,7 @@ void __bea_callspec__ jnbe_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,119); } /* ======================================= @@ -3327,7 +3348,7 @@ void __bea_callspec__ js_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3340,7 +3361,7 @@ void __bea_callspec__ js_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,120); } /* ======================================= @@ -3369,7 +3390,7 @@ void __bea_callspec__ jns_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3382,7 +3403,7 @@ void __bea_callspec__ jns_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,120); } /* ======================================= @@ -3411,7 +3432,7 @@ void __bea_callspec__ jp_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3424,7 +3445,7 @@ void __bea_callspec__ jp_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,121); } /* ======================================= @@ -3453,7 +3474,7 @@ void __bea_callspec__ jnp_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3466,7 +3487,7 @@ void __bea_callspec__ jnp_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,121); } /* ======================================= @@ -3495,7 +3516,7 @@ void __bea_callspec__ jl_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3508,7 +3529,7 @@ void __bea_callspec__ jl_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } /* ======================================= @@ -3537,7 +3558,7 @@ void __bea_callspec__ jnl_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3550,7 +3571,7 @@ void __bea_callspec__ jnl_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } /* ======================================= @@ -3579,7 +3600,7 @@ void __bea_callspec__ jle_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3592,7 +3613,7 @@ void __bea_callspec__ jle_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } /* ======================================= @@ -3621,7 +3642,7 @@ void __bea_callspec__ jnle_(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3634,7 +3655,7 @@ void __bea_callspec__ jnle_(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } @@ -3664,7 +3685,7 @@ void __bea_callspec__ jo_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3677,7 +3698,7 @@ void __bea_callspec__ jo_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } else { if (!Security(3, pMyDisasm)) return; @@ -3692,7 +3713,7 @@ void __bea_callspec__ jo_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } } @@ -3723,7 +3744,7 @@ void __bea_callspec__ jno_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3736,7 +3757,7 @@ void __bea_callspec__ jno_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } else { if (!Security(3, pMyDisasm)) return; @@ -3751,7 +3772,7 @@ void __bea_callspec__ jno_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,116); } } @@ -3782,7 +3803,7 @@ void __bea_callspec__ jc_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3794,7 +3815,7 @@ void __bea_callspec__ jc_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } else { if (!Security(3, pMyDisasm)) return; @@ -3808,7 +3829,7 @@ void __bea_callspec__ jc_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } } @@ -3839,7 +3860,7 @@ void __bea_callspec__ jnc_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3851,7 +3872,7 @@ void __bea_callspec__ jnc_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } else { if (!Security(3, pMyDisasm)) return; @@ -3865,7 +3886,7 @@ void __bea_callspec__ jnc_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,117); } } @@ -3896,7 +3917,7 @@ void __bea_callspec__ je_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -3908,7 +3929,7 @@ void __bea_callspec__ je_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,118); } else { if (!Security(3, pMyDisasm)) return; @@ -3953,7 +3974,7 @@ void __bea_callspec__ jne_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4009,7 +4030,7 @@ void __bea_callspec__ jbe_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4067,7 +4088,7 @@ void __bea_callspec__ ja_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4079,7 +4100,7 @@ void __bea_callspec__ ja_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,119); } else { if (!Security(3, pMyDisasm)) return; @@ -4093,7 +4114,7 @@ void __bea_callspec__ ja_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,119); } } @@ -4124,7 +4145,7 @@ void __bea_callspec__ js_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4136,7 +4157,7 @@ void __bea_callspec__ js_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,120); } else { if (!Security(3, pMyDisasm)) return; @@ -4181,7 +4202,7 @@ void __bea_callspec__ jns_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4193,7 +4214,7 @@ void __bea_callspec__ jns_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,120); } else { if (!Security(3, pMyDisasm)) return; @@ -4238,7 +4259,7 @@ void __bea_callspec__ jp_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4250,7 +4271,7 @@ void __bea_callspec__ jp_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,121); } else { if (!Security(3, pMyDisasm)) return; @@ -4295,7 +4316,7 @@ void __bea_callspec__ jnp_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4307,7 +4328,7 @@ void __bea_callspec__ jnp_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,121); } else { if (!Security(3, pMyDisasm)) return; @@ -4321,7 +4342,7 @@ void __bea_callspec__ jnp_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,121); } } @@ -4352,7 +4373,7 @@ void __bea_callspec__ jl_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4364,7 +4385,7 @@ void __bea_callspec__ jl_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } else { if (!Security(3, pMyDisasm)) return; @@ -4378,7 +4399,7 @@ void __bea_callspec__ jl_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } } @@ -4409,7 +4430,7 @@ void __bea_callspec__ jnl_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4421,7 +4442,7 @@ void __bea_callspec__ jnl_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } else { if (!Security(3, pMyDisasm)) return; @@ -4435,7 +4456,7 @@ void __bea_callspec__ jnl_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,122); } } @@ -4466,7 +4487,7 @@ void __bea_callspec__ jle_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4478,7 +4499,7 @@ void __bea_callspec__ jle_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } else { if (!Security(3, pMyDisasm)) return; @@ -4492,7 +4513,7 @@ void __bea_callspec__ jle_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } } @@ -4523,7 +4544,7 @@ void __bea_callspec__ jnle_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+6+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4535,7 +4556,7 @@ void __bea_callspec__ jnle_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } else { if (!Security(3, pMyDisasm)) return; @@ -4549,7 +4570,7 @@ void __bea_callspec__ jnle_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,115); } } @@ -4592,7 +4613,7 @@ void __bea_callspec__ jecxz_(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+2+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4642,7 +4663,7 @@ void __bea_callspec__ jmp_near(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+5+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4654,7 +4675,7 @@ void __bea_callspec__ jmp_near(PDISASM pMyDisasm) (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=5; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,51); } else { if (!Security(3, pMyDisasm)) return; @@ -4667,7 +4688,7 @@ void __bea_callspec__ jmp_near(PDISASM pMyDisasm) (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=3; - FillFlags(pMyDisasm,49); + FillFlags(pMyDisasm,51); } } @@ -4691,7 +4712,7 @@ void __bea_callspec__ jmp_short(PDISASM pMyDisasm) if (GV.OperandSize == 16) MyAddress = MyAddress & 0xffff; if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -4713,6 +4734,7 @@ void __bea_callspec__ jmp_short(PDISASM pMyDisasm) void __bea_callspec__ jmp_far(PDISASM pMyDisasm) { UInt32 MyNumber; + UInt64 MyAddress; size_t i = 0; if (GV.Architecture == 64) { FailDecode(pMyDisasm); @@ -4761,6 +4783,7 @@ void __bea_callspec__ jmp_far(PDISASM pMyDisasm) #endif i+=3; } + MyAddress = MyNumber*16; MyNumber = *((UInt32*)(UIntPtr) (GV.EIP_+1)); if (GV.OperandSize == 16) { MyNumber = MyNumber & 0xffff; @@ -4774,6 +4797,8 @@ void __bea_callspec__ jmp_far(PDISASM pMyDisasm) else { GV.EIP_+=5; } + (*pMyDisasm).Instruction.AddrValue = MyAddress + MyNumber; + FillFlags(pMyDisasm,51); } } @@ -4888,6 +4913,7 @@ void __bea_callspec__ lea_GvM(PDISASM pMyDisasm) if (GV.MOD_== 3) FailDecode(pMyDisasm); + (*pMyDisasm).Argument2.AccessMode = 0; } /* ======================================= @@ -5018,7 +5044,7 @@ void __bea_callspec__ loop_(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+2+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -5028,6 +5054,7 @@ void __bea_callspec__ loop_(PDISASM pMyDisasm) } (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; @@ -5042,11 +5069,11 @@ void __bea_callspec__ loop_(PDISASM pMyDisasm) #endif (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; FillFlags(pMyDisasm, 60); - } } @@ -5069,7 +5096,7 @@ void __bea_callspec__ loopne_(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+2+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -5079,6 +5106,7 @@ void __bea_callspec__ loopne_(PDISASM pMyDisasm) } (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; @@ -5093,6 +5121,7 @@ void __bea_callspec__ loopne_(PDISASM pMyDisasm) #endif (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; @@ -5120,7 +5149,7 @@ void __bea_callspec__ loope_(PDISASM pMyDisasm) CalculateRelativeAddress(&MyAddress,(Int64) GV.NB_PREFIX+2+MyNumber, pMyDisasm); if (MyAddress >= W64LIT (0x100000000)) { #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif } else { @@ -5130,6 +5159,7 @@ void __bea_callspec__ loope_(PDISASM pMyDisasm) } (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; @@ -5144,6 +5174,7 @@ void __bea_callspec__ loope_(PDISASM pMyDisasm) #endif (*pMyDisasm).Argument1.AccessMode = READ; (*pMyDisasm).Argument1.ArgSize = GV.OperandSize; + (*pMyDisasm).Argument1.ArgType = CONSTANT_TYPE+RELATIVE_; (*pMyDisasm).Instruction.ImplicitModifiedRegs = GENERAL_REG+REG1; (*pMyDisasm).Instruction.AddrValue = MyAddress; GV.EIP_+=2; @@ -5359,7 +5390,7 @@ void __bea_callspec__ mov_ALOb(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Argument2.Memory.Displacement = (Int64)MyAddress; @@ -5412,7 +5443,7 @@ void __bea_callspec__ mov_eAXOv(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Argument2.Memory.Displacement = (Int64)MyAddress; @@ -5514,7 +5545,7 @@ void __bea_callspec__ mov_ObAL(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Argument1.Memory.Displacement = (Int64)MyAddress; @@ -5567,7 +5598,7 @@ void __bea_callspec__ mov_OveAX(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument1.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Argument1.Memory.Displacement = (Int64)MyAddress; @@ -5634,15 +5665,15 @@ void __bea_callspec__ mov_OveAX(PDISASM pMyDisasm) (*pMyDisasm).Argument2.ArgType = REGISTER_TYPE+GENERAL_REG+REG0; (*pMyDisasm).Argument1.ArgType = MEMORY_TYPE ; - if (GV.MemDecoration == 104) { + if (GV.MemDecoration == Arg1qword) { (*pMyDisasm).Argument1.ArgSize = 64; (*pMyDisasm).Argument2.ArgSize = 64; } - else if (GV.MemDecoration == 103) { + else if (GV.MemDecoration == Arg1dword) { (*pMyDisasm).Argument1.ArgSize = 32; (*pMyDisasm).Argument2.ArgSize = 32; } - else if (GV.MemDecoration == 102) { + else if (GV.MemDecoration == Arg1word) { (*pMyDisasm).Argument1.ArgSize = 16; (*pMyDisasm).Argument2.ArgSize = 16; } @@ -6001,7 +6032,7 @@ void __bea_callspec__ mov_EAX(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6084,7 +6115,7 @@ void __bea_callspec__ mov_ECX(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6167,7 +6198,7 @@ void __bea_callspec__ mov_EDX(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6250,7 +6281,7 @@ void __bea_callspec__ mov_EBX(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6333,7 +6364,7 @@ void __bea_callspec__ mov_ESP(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6416,7 +6447,7 @@ void __bea_callspec__ mov_EBP(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6499,7 +6530,7 @@ void __bea_callspec__ mov_ESI(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; @@ -6582,7 +6613,7 @@ void __bea_callspec__ mov_EDI(PDISASM pMyDisasm) if (!Security(9, pMyDisasm)) return; MyAddress = *((UInt64 *)(UIntPtr) (GV.EIP_+1)); #ifndef BEA_LIGHT_DISASSEMBLY - (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%I64X",(Int64) MyAddress); + (void) CopyFormattedNumber(pMyDisasm, (char*) (*pMyDisasm).Argument2.ArgMnemonic, "%.16llX",(Int64) MyAddress); #endif GV.EIP_+=9; (*pMyDisasm).Instruction.Immediat = (Int64)MyAddress; diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_FPU.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_FPU.c index a95812f6a1aa2971f4d3b489a05a047c3ea41238..1896e97f4fe2f738fddb8c7386bda3bb4b2bf163 100644 --- a/beaengine/beaengineSources/Includes/instr_set/opcodes_FPU.c +++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_FPU.c @@ -1520,6 +1520,9 @@ void __bea_callspec__ DE_(PDISASM pMyDisasm) (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "fcompp "); #endif } + else { + FailDecode(pMyDisasm); + } } diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_N_Z.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_N_Z.c index e41557ee46646e6d54f112afb42c1b1571a68504..01cf3bf092e47f8bb6ebf7e8357010a29e69b620 100644 --- a/beaengine/beaengineSources/Includes/instr_set/opcodes_N_Z.c +++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_N_Z.c @@ -37,17 +37,49 @@ void __bea_callspec__ nop_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "xchg "); #endif - #ifndef BEA_LIGHT_DISASSEMBLY - (void) strcpy ((char*) (*pMyDisasm).Argument1.ArgMnemonic, Registers64Bits[0]); - #endif - (*pMyDisasm).Argument1.ArgType = REGISTER_TYPE+GENERAL_REG+REGS[0]; - (*pMyDisasm).Argument1.ArgSize = 64; - #ifndef BEA_LIGHT_DISASSEMBLY - (void) strcpy ((char*) (*pMyDisasm).Argument2.ArgMnemonic, Registers64Bits[0+8]); - #endif - (*pMyDisasm).Argument2.ArgType = REGISTER_TYPE+GENERAL_REG+REGS[0+8]; - (*pMyDisasm).Argument2.ArgSize = 64; - GV.EIP_++; + + if (GV.OperandSize == 64) { + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument1.ArgMnemonic, Registers64Bits[0]); + #endif + + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument2.ArgMnemonic, Registers64Bits[0+8]); + #endif + GV.EIP_++; + (*pMyDisasm).Argument2.AccessMode = WRITE; + (*pMyDisasm).Argument1.ArgSize = 64; + (*pMyDisasm).Argument2.ArgSize = 64; + } + else if (GV.OperandSize == 32) { + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument1.ArgMnemonic, Registers32Bits[0]); + #endif + + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument2.ArgMnemonic, Registers32Bits[0+8]); + #endif + + GV.EIP_++; + (*pMyDisasm).Argument2.AccessMode = WRITE; + (*pMyDisasm).Argument1.ArgSize = 32; + (*pMyDisasm).Argument2.ArgSize = 32; + } + else { + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument1.ArgMnemonic, Registers16Bits[0]); + #endif + + #ifndef BEA_LIGHT_DISASSEMBLY + (void) strcpy ((*pMyDisasm).Argument2.ArgMnemonic, Registers16Bits[0+8]); + #endif + + GV.EIP_++; + (*pMyDisasm).Argument2.AccessMode = WRITE; + (*pMyDisasm).Argument1.ArgSize = 16; + (*pMyDisasm).Argument2.ArgSize = 16; + } + } else { (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+MISCELLANEOUS_INSTRUCTION; @@ -79,6 +111,7 @@ void __bea_callspec__ nop_Ev(PDISASM pMyDisasm) } MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); GV.EIP_ += GV.DECALAGE_EIP+2; + (*pMyDisasm).Argument2.AccessMode = 0; } /* ======================================= @@ -1782,6 +1815,9 @@ void __bea_callspec__ retn_(PDISASM pMyDisasm) * ======================================= */ void __bea_callspec__ ret_(PDISASM pMyDisasm) { + if ((*pMyDisasm).Prefix.RepPrefix == SuperfluousPrefix) { + (*pMyDisasm).Prefix.RepPrefix = InUsePrefix; + } (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+CONTROL_TRANSFER; (*pMyDisasm).Instruction.BranchType = RetType; #ifndef BEA_LIGHT_DISASSEMBLY @@ -1833,10 +1869,6 @@ void __bea_callspec__ retf_Iw(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "lret "); #endif - #ifndef BEA_LIGHT_DISASSEMBLY - (void) strcpy ((*pMyDisasm).Argument1.ArgMnemonic,"\x24"); - #endif - i++; } else { #ifndef BEA_LIGHT_DISASSEMBLY @@ -2165,7 +2197,7 @@ void __bea_callspec__ stosw_(PDISASM pMyDisasm) void __bea_callspec__ syscall_(PDISASM pMyDisasm) { if (GV.Architecture == 64) { - (*pMyDisasm).Instruction.Category = SYSTEM_INSTRUCTION; + (*pMyDisasm).Instruction.Category = SYSTEM_INSTRUCTION+CONTROL_TRANSFER; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "syscall "); #endif @@ -2304,9 +2336,9 @@ void __bea_callspec__ seto_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "seto "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2321,9 +2353,9 @@ void __bea_callspec__ setno_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setno "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2338,9 +2370,9 @@ void __bea_callspec__ setb_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setb "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2355,9 +2387,9 @@ void __bea_callspec__ setnb_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setnb "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2372,9 +2404,9 @@ void __bea_callspec__ sete_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "sete "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2389,9 +2421,9 @@ void __bea_callspec__ setne_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setne "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2406,9 +2438,9 @@ void __bea_callspec__ setbe_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setbe "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2423,9 +2455,9 @@ void __bea_callspec__ setnbe_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setnbe "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2440,9 +2472,9 @@ void __bea_callspec__ sets_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "sets "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2457,9 +2489,9 @@ void __bea_callspec__ setns_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setns "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2474,9 +2506,9 @@ void __bea_callspec__ setp_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setp "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2491,9 +2523,9 @@ void __bea_callspec__ setnp_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setnp "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2508,9 +2540,9 @@ void __bea_callspec__ setge_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setnl "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2525,9 +2557,9 @@ void __bea_callspec__ setnge_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setl "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2542,9 +2574,9 @@ void __bea_callspec__ setle_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setle "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -2559,9 +2591,9 @@ void __bea_callspec__ setnle_(PDISASM pMyDisasm) #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "setnle "); #endif - GV.MemDecoration = Arg2byte; + GV.MemDecoration = Arg1byte; GV.OperandSize = 8; - MOD_RM(&(*pMyDisasm).Argument2, pMyDisasm); + MOD_RM(&(*pMyDisasm).Argument1, pMyDisasm); GV.OperandSize = 32; GV.EIP_+= GV.DECALAGE_EIP+2; FillFlags(pMyDisasm,95); @@ -3633,7 +3665,7 @@ void __bea_callspec__ xchg_EbGb(PDISASM pMyDisasm) if ((*pMyDisasm).Prefix.LockPrefix == InvalidPrefix) { (*pMyDisasm).Prefix.LockPrefix = InUsePrefix; } - (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+ARITHMETIC_INSTRUCTION; + (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+DATA_TRANSFER; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "xchg "); #endif @@ -3650,7 +3682,7 @@ void __bea_callspec__ xchg_EvGv(PDISASM pMyDisasm) if ((*pMyDisasm).Prefix.LockPrefix == InvalidPrefix) { (*pMyDisasm).Prefix.LockPrefix = InUsePrefix; } - (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+ARITHMETIC_INSTRUCTION; + (*pMyDisasm).Instruction.Category = GENERAL_PURPOSE_INSTRUCTION+DATA_TRANSFER; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "xchg "); #endif diff --git a/beaengine/beaengineSources/Includes/instr_set/opcodes_SSE.c b/beaengine/beaengineSources/Includes/instr_set/opcodes_SSE.c index 8576da29324786fad8eb4864fc26032905b80037..5acf2126ca81c88c30294a0f4704f51fdeb0b0b4 100644 --- a/beaengine/beaengineSources/Includes/instr_set/opcodes_SSE.c +++ b/beaengine/beaengineSources/Includes/instr_set/opcodes_SSE.c @@ -515,7 +515,7 @@ void __bea_callspec__ cvtps2pd_(PDISASM pMyDisasm) GV.SSE_ = 0; } else { - GV.MemDecoration = Arg2dqword; + GV.MemDecoration = Arg2qword; (*pMyDisasm).Instruction.Category = SSE2_INSTRUCTION+CONVERSION_INSTRUCTION; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "cvtps2pd "); @@ -841,7 +841,7 @@ void __bea_callspec__ cvtpd2dq_(PDISASM pMyDisasm) /* ========== 0xf3 */ else if (GV.PrefRepe == 1) { (*pMyDisasm).Prefix.RepPrefix = MandatoryPrefix; - GV.MemDecoration = Arg2dqword; + GV.MemDecoration = Arg2qword; (*pMyDisasm).Instruction.Category = SSE2_INSTRUCTION+CONVERSION_INSTRUCTION; #ifndef BEA_LIGHT_DISASSEMBLY (void) strcpy ((*pMyDisasm).Instruction.Mnemonic, "cvtdq2pd "); diff --git a/beaengine/beaengineSources/Includes/internal_datas.h b/beaengine/beaengineSources/Includes/internal_datas.h index e66b017f25b25036358ea8af229009255018950f..eb8f5acb693993b32adb25cf0418c6c51aa6aeaa 100644 --- a/beaengine/beaengineSources/Includes/internal_datas.h +++ b/beaengine/beaengineSources/Includes/internal_datas.h @@ -167,8 +167,17 @@ EFLStruct EFLAGS_TABLE[] = { {0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0}, /* 112-XLAT */ {RE_, MO_, MO_, UN_, MO_, RE_, 0 , 0 , 0 , 0 , 0, 0}, /* 113-XOR */ - {RE_, RE_, MO_, RE_, RE_, RE_, 0 , 0 , 0 , 0 , 0, 0} /* 114-POPCNT */ + {RE_, RE_, MO_, RE_, RE_, RE_, 0 , 0 , 0 , 0 , 0, 0}, /* 114-POPCNT */ + {TE_, TE_, TE_, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0}, /*115 -jg jnle jng jle http://ref.x86asm.net/coder.html */ + {TE_, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0}, /*116 -jo jno http://ref.x86asm.net/coder.html */ + {0 , 0 , 0 , 0 , 0 , TE_, 0 , 0 , 0 , 0 , 0, 0}, /*117 -jc jnc jb jnb jnae jae http://ref.x86asm.net/coder.html */ + {0 , 0 , TE_, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0}, /*118 -jz jnz je jne http://ref.x86asm.net/coder.html */ + {0 , 0 , TE_, 0 , 0 , TE_, 0 , 0 , 0 , 0 , 0, 0}, /*119 -jbe jnbe jna ja http://ref.x86asm.net/coder.html */ + + {0 , TE_, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0}, /* 120 - js jns http://ref.x86asm.net/coder.html */ + {0 , 0 , 0 , 0 , TE_, 0 , 0 , 0 , 0 , 0 , 0, 0}, /* 121 - jp jpe jnp jpo http://ref.x86asm.net/coder.html */ + {TE_, TE_, 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, 0} /* 122 - jl jnge jnl jge http://ref.x86asm.net/coder.html */ }; /* ===================================================== @@ -235,7 +244,7 @@ char MasmPrefixes[8][16] = { char NasmPrefixes[8][8] = { "byte ", /* GV.MemDecoration == 1 */ "word ", /* GV.MemDecoration == 2 */ - "dword ", /* GV.MemDecoration == 3 */ + " ", /* GV.MemDecoration == 3 */ "qword ", /* GV.MemDecoration == 4 */ " ", /* GV.MemDecoration == 5 (multibytes) */ "tword ", /* GV.MemDecoration == 6 */ diff --git a/beaengine/include/beaengine/BeaEngine.h b/beaengine/include/beaengine/BeaEngine.h index c755b9104b6aa4da6018bdc7e307fb520db2ee62..a9256d41139ff870b424b27d7a15001b6084b70f 100644 --- a/beaengine/include/beaengine/BeaEngine.h +++ b/beaengine/include/beaengine/BeaEngine.h @@ -1,5 +1,8 @@ #ifndef _BEA_ENGINE_ #define _BEA_ENGINE_ +#if defined(__cplusplus) && defined(__BORLANDC__) +namespace BeaEngine { +#endif #include <beaengine/macros.h> #include <beaengine/export.h> @@ -45,7 +48,8 @@ typedef struct { UInt8 DSPrefix; UInt8 BranchTaken; UInt8 BranchNotTaken; - REX_Struct REX; + REX_Struct REX; + char alignment[2]; } PREFIXINFO ; #pragma pack() @@ -91,7 +95,7 @@ typedef struct { #pragma pack(1) typedef struct { - char ArgMnemonic[32]; + char ArgMnemonic[64]; Int32 ArgType; Int32 ArgSize; Int32 ArgPosition; @@ -255,28 +259,28 @@ enum EFLAGS_STATES enum BRANCH_TYPE { - JO = 1, - JC, - JE, - JA, - JS, - JP, - JL, - JG, - JB, - JECXZ, - JmpType, - CallType, - RetType, - JNO = -1, - JNC = -2, - JNE = -3, - JNA = -4, - JNS = -5, - JNP = -6, - JNL = -7, - JNG = -8, - JNB = -9 + JO = 1, + JC = 2, + JE = 3, + JA = 4, + JS = 5, + JP = 6, + JL = 7, + JG = 8, + JB = 2, /* JC == JB */ + JECXZ = 10, + JmpType = 11, + CallType = 12, + RetType = 13, + JNO = -1, + JNC = -2, + JNE = -3, + JNA = -4, + JNS = -5, + JNP = -6, + JNL = -7, + JNG = -8, + JNB = -2 /* JNC == JNB */ }; enum ARGUMENTS_TYPE @@ -350,5 +354,9 @@ extern "C" BEA_API int __bea_callspec__ Disasm (LPDISASM pDisAsm); BEA_API const__ char* __bea_callspec__ BeaEngineVersion (void); -BEA_API const__ char* __bea_callspec__ BeaEngineRevision (void); +BEA_API const__ char* __bea_callspec__ BeaEngineRevision (void); +#if defined(__cplusplus) && defined(__BORLANDC__) +}; +using namespace BeaEngine; +#endif #endif diff --git a/beaengine/include/beaengine/basic_types.h b/beaengine/include/beaengine/basic_types.h index 732c18169abd49a4849f38aad1c9d1bf07eb2d2c..80e46f9157e6555a6548f829b0fbb4c279a300b2 100644 --- a/beaengine/include/beaengine/basic_types.h +++ b/beaengine/include/beaengine/basic_types.h @@ -29,7 +29,7 @@ #include <stdint.h> #endif -#if defined(_MSC_VER) +#if defined(_MSC_VER) && !defined(__BORLANDC__) /* * Windows/Visual C++ */ diff --git a/third_party/beaengine166.tar.gz.REMOVED.git-id b/third_party/beaengine166.tar.gz.REMOVED.git-id new file mode 100644 index 0000000000000000000000000000000000000000..688b9f161a2648b18a94a4c39aa56789e49fcb48 --- /dev/null +++ b/third_party/beaengine166.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +d0cbfd2a7d3f406741233cbdf808e5162c46376d \ No newline at end of file diff --git a/third_party/beaengine175.tar.gz.REMOVED.git-id b/third_party/beaengine175.tar.gz.REMOVED.git-id new file mode 100644 index 0000000000000000000000000000000000000000..48f96b28c4f54f68d8b6a36c1faf278d074074e3 --- /dev/null +++ b/third_party/beaengine175.tar.gz.REMOVED.git-id @@ -0,0 +1 @@ +2e7118f7671436b35874cbb32ecf32cc3ee32e29 \ No newline at end of file diff --git a/third_party/do_bea_update.sh b/third_party/do_bea_update.sh new file mode 100755 index 0000000000000000000000000000000000000000..0eb716545db0c39f8a0c17097c254be3ce525ef4 --- /dev/null +++ b/third_party/do_bea_update.sh @@ -0,0 +1,46 @@ +#!/bin/sh + + +# uva's svn version. this sshould be "old" with uva's edits. +update_dir=/home/jdh8d/64bit_port/uvadev.peasoup/security_transforms/beaengine/ + +# output location -- should be a copy of uva's svn version. +new_dir=/home/jdh8d/64bit_port/uvadev.peasoup/security_transforms/beaengine2/ + +# update_dir as a sed pattern. +sed_update_dir=".home.jdh8d.64bit_port.uvadev.peasoup.security_transforms.beaengine." + +# +# path to the "old" version of bea engine. +# +old=beaengine166 + +# +# path to the "new" version of bea engine. +# +new=beaengine175 + +for i in `find $update_dir -print |egrep -v \.svn`; +do + bn=`echo $i |sed "s/$sed_update_dir//"` + + if [ -f $update_dir/$bn -a -f $old/$bn -a -f $new/$bn ]; then + diff $old/$bn $new/$bn > /dev/null + + if [ $? != 0 ]; then + echo Found $bn with possible patches + # this command auto-patches the difs between old/new into update_dir + #diff3 -m $i $old/$bn $new/$bn > $new_dir/$bn + fi + elif [ -f $old/$bn -a ! -f $new/$bn ]; then + echo $bn is removed in $new + elif [ ! -f $old/$bn -a -f $new/$bn ]; then + echo $bn is added in $new + elif [ -d $i ]; then + # empty, this is a dir + echo -n + else + + echo skipping $bn + fi +done diff --git a/tools/meds2pdb/meds2pdb.cpp b/tools/meds2pdb/meds2pdb.cpp index e7c95ff1605a09d4dcf174ba29db378ca531022c..79ded4beba653e5f7b65da5b44d2817b7c3078ae 100644 --- a/tools/meds2pdb/meds2pdb.cpp +++ b/tools/meds2pdb/meds2pdb.cpp @@ -35,6 +35,7 @@ int get_file_id(char *progName, char *md5hash) { connection conn; work txn(conn); + txn.exec("SET client_encoding='LATIN1';"); string query = "SELECT file_id FROM file_info WHERE hash="; query += txn.quote(string(md5hash)); @@ -59,6 +60,7 @@ void insert_instructions(int fileID, vector<wahoo::Instruction*> instructions, v cerr << "Inserting instructions in the DB"<<endl; connection conn; work txn(conn); + txn.exec("SET client_encoding='LATIN1';"); // for each instruction: // (1) get address, insert into address table // (2) populate instruction table @@ -148,6 +150,7 @@ void insert_functions(int fileID, const vector<wahoo::Function*> &functions ) { connection conn; work txn(conn); + txn.exec("SET client_encoding='LATIN1';"); // bulk insert of function information into the DB const int STRIDE = 25; @@ -192,6 +195,7 @@ void update_functions(int fileID, const vector<wahoo::Function*> &functions ) { connection conn; work txn(conn); + txn.exec("SET client_encoding='LATIN1';"); // bulk insert of function information into the DB int count = 0; diff --git a/xform/rewriter.cpp b/xform/rewriter.cpp index 79cf4139dec4c3082a799ea58768053f891e1285..eb996a4de73dc16fe45a416f8a4b9513ff7ce4bd 100644 --- a/xform/rewriter.cpp +++ b/xform/rewriter.cpp @@ -618,7 +618,9 @@ void Rewriter::dissassemble() { /* bogus intruction, remove it */ m_instructions[instr->getAddress()]=NULL; - delete instr; + + if(instr) + delete instr; } } }