예제 #1
0
  @Test
  public void testPushL16() throws InternalTranslationException, InterpreterException {
    final MockOperandTree operandTree = new MockOperandTree();
    operandTree.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "word");
    operandTree.root.m_children.add(
        new MockOperandTreeNode(ExpressionType.IMMEDIATE_INTEGER, "1234"));

    final List<MockOperandTree> operands = Lists.newArrayList(operandTree);

    final IInstruction instruction = new MockInstruction("push", operands);

    translator.translate(environment, instruction, instructions);

    interpreter.interpret(TestHelpers.createMapping(instructions), BigInteger.valueOf(0x100));

    assertEquals(BigInteger.valueOf(0x1FFE), interpreter.getVariableValue("esp"));

    assertEquals(BigInteger.valueOf(2L), BigInteger.valueOf(interpreter.getMemorySize()));
    assertEquals(1234, interpreter.readMemoryWord(0x1FFE));
    assertEquals(2, TestHelpers.filterNativeRegisters(interpreter.getDefinedRegisters()).size());
  }
예제 #2
0
  @Test
  public void testPushR16() throws InternalTranslationException, InterpreterException {
    interpreter.setRegister(
        "eax", BigInteger.valueOf(0x12345678), OperandSize.DWORD, ReilRegisterStatus.DEFINED);

    final MockOperandTree operandTree = new MockOperandTree();
    operandTree.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "word");
    operandTree.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "ax"));

    final List<MockOperandTree> operands = Lists.newArrayList(operandTree);

    final IInstruction instruction = new MockInstruction("push", operands);

    translator.translate(environment, instruction, instructions);

    interpreter.interpret(TestHelpers.createMapping(instructions), BigInteger.valueOf(0x100));

    assertEquals(BigInteger.valueOf(0x1FFE), interpreter.getVariableValue("esp"));

    assertEquals(BigInteger.valueOf(2L), BigInteger.valueOf(interpreter.getMemorySize()));
    assertEquals(0x5678, interpreter.readMemoryWord(0x1FFE));
    assertEquals(3, TestHelpers.filterNativeRegisters(interpreter.getDefinedRegisters()).size());
  }