internal X86OpCode(X86Mnemonic mnemonic, uint opcodeValue, uint operandsValue, bool hasRegisterToken) : this(new X86Mnemonic[] { mnemonic }, opcodeValue, operandsValue, hasRegisterToken, false) { }
private static IEnumerable<X86Instruction> CreateRegOrMemSibTestInstructions(X86OpCode opcode, X86Mnemonic mnemonic) { for (int operandType = 0; operandType < 3; operandType++) { for (int multiplier = 1; multiplier < 16; multiplier*=2) { for (int scaledRegIndex = 0; scaledRegIndex < 8; scaledRegIndex++) { if (scaledRegIndex == 4) continue; var operand1 = new X86Operand(X86OperandUsage.BytePointer, X86Register.Eax, new X86ScaledIndex((X86Register)scaledRegIndex | X86Register.Eax, multiplier)); var operand2 = new X86Operand(X86OperandUsage.Normal, X86Register.Al); var instruction = new X86Instruction() { OpCode = opcode, Mnemonic = mnemonic, Operand1 = operand1, Operand2 = operand2, }; switch (operandType) { case 1: operand1.Offset = 1; operand1.OffsetType = X86OffsetType.Short; break; case 2: operand1.Offset = 0x1337; operand1.OffsetType = X86OffsetType.Long; break; } yield return instruction; } } } }
internal X86OpCode(X86Mnemonic mnemonic, byte opcode, uint operandsValue, bool hasRegisterToken) : this(mnemonic, (uint)(opcode << 8), operandsValue, hasRegisterToken) { }
private static IEnumerable <X86Instruction> CreateRegOrMemTestInstructions(X86OpCode opcode, X86Mnemonic mnemonic, bool flippedOperands, bool threeOperands) { for (int operandType = 0; operandType < 3; operandType++) { for (int register2Index = 0; register2Index < 8; register2Index++) { for (int register1Index = 0; register1Index < 8; register1Index++) { var operand1 = new X86Operand(X86OperandUsage.BytePointer, (X86Register)register1Index | X86Register.Eax); var operand2 = new X86Operand(X86OperandUsage.Normal, (X86Register)register2Index); var instruction = new X86Instruction() { OpCode = opcode, Mnemonic = mnemonic, }; if (flippedOperands) { instruction.Operand2 = operand1; instruction.Operand1 = operand2; } else { instruction.Operand1 = operand1; instruction.Operand2 = operand2; } switch (register1Index) { case 4: // esp continue; case 5: // ebp if (operandType != 0) { continue; } operand1.Value = 0x1337u; break; } switch (operandType) { case 1: operand1.Offset = 1; operand1.OffsetType = X86OffsetType.Short; break; case 2: operand1.Offset = 0x1337; operand1.OffsetType = X86OffsetType.Long; break; } if (threeOperands) { switch (opcode.OperandSize3) { case X86OperandSize.Byte: instruction.Operand3 = new X86Operand((byte)0x12); break; case X86OperandSize.WordOrDword: instruction.Operand3 = new X86Operand(0x1337u); break; } } yield return(instruction); } } } }
private static IEnumerable <X86Instruction> CreateRegOrMemSibTestInstructions(X86OpCode opcode, X86Mnemonic mnemonic) { for (int operandType = 0; operandType < 3; operandType++) { for (int multiplier = 1; multiplier < 16; multiplier *= 2) { for (int scaledRegIndex = 0; scaledRegIndex < 8; scaledRegIndex++) { if (scaledRegIndex == 4) { continue; } var operand1 = new X86Operand(X86OperandUsage.BytePointer, X86Register.Eax, new X86ScaledIndex((X86Register)scaledRegIndex | X86Register.Eax, multiplier)); var operand2 = new X86Operand(X86OperandUsage.Normal, X86Register.Al); var instruction = new X86Instruction() { OpCode = opcode, Mnemonic = mnemonic, Operand1 = operand1, Operand2 = operand2, }; switch (operandType) { case 1: operand1.Offset = 1; operand1.OffsetType = X86OffsetType.Short; break; case 2: operand1.Offset = 0x1337; operand1.OffsetType = X86OffsetType.Long; break; } yield return(instruction); } } } }
public virtual string FormatMnemonic(X86Mnemonic mnemonic) { return(mnemonic.ToString().ToLowerInvariant().Replace('_', ' ')); }
private static IEnumerable<X86Instruction> CreateRegOrMemTestInstructions(X86OpCode opcode, X86Mnemonic mnemonic, bool flippedOperands) { for (int operandType = 0; operandType < 3; operandType++) { for (int register2Index = 0; register2Index < 8; register2Index++) { for (int register1Index = 0; register1Index < 8; register1Index++) { var operand1 = new X86Operand(X86OperandUsage.BytePointer, (X86Register)register1Index | X86Register.Eax); var operand2 = new X86Operand(X86OperandUsage.Normal, (X86Register)register2Index); var instruction = new X86Instruction() { OpCode = opcode, Mnemonic = mnemonic, }; if (flippedOperands) { instruction.Operand2 = operand1; instruction.Operand1 = operand2; } else { instruction.Operand1 = operand1; instruction.Operand2 = operand2; } switch (register1Index) { case 4: // esp continue; case 5: // ebp if (operandType != 0) continue; operand1.Value = 0x1337u; break; } switch (operandType) { case 1: operand1.Offset = 1; operand1.OffsetType = X86OffsetType.Short; break; case 2: operand1.Offset = 0x1337; operand1.OffsetType = X86OffsetType.Long; break; } yield return instruction; } } } }
public virtual string FormatMnemonic(X86Mnemonic mnemonic) { return mnemonic.ToString().ToLowerInvariant().Replace('_', ' '); }