Search in sources :

Example 36 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class CCodeNodeParserTest method testSameOperandTwice.

@Test
public void testSameOperandTwice() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // 00000000: jz eax
    // 00000001: jg eax
    final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
    final MockCodeNodeData instruction1 = new MockCodeNodeData();
    instruction1.nodeId = 0;
    instruction1.expressionId = 0;
    instruction1.expressionType = 5;
    instruction1.operandPosition = 0;
    instruction1.symbol = "eax";
    final MockCodeNodeData instruction2 = new MockCodeNodeData();
    instruction2.address = new CAddress(BigInteger.ONE);
    instruction2.nodeId = 1;
    instruction2.expressionId = 0;
    instruction2.expressionType = 5;
    instruction2.operandPosition = 0;
    instruction2.symbol = "eax";
    cnProvider.data.add(instruction1);
    cnProvider.data.add(instruction2);
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
    final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
    final List<CCodeNode> result = p.parse();
    assertEquals(2, result.size());
    assertEquals(1, Iterables.size(result.get(0).getInstructions()));
    assertEquals(1, Iterables.size(result.get(1).getInstructions()));
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 37 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class CCodeNodeParserTest method testSingleInstruction.

@Test
public void testSingleInstruction() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // nop
    final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
    cnProvider.data.add(new MockCodeNodeData());
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
    final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
    final List<CCodeNode> result = p.parse();
    assertEquals(1, result.size());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) Test(org.junit.Test)

Example 38 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class CCodeNodeParserTest method testMultipleOperands.

@Test
public void testMultipleOperands() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // 00000000: mov eax, ebx
    final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
    final MockCodeNodeData instruction1a = new MockCodeNodeData();
    instruction1a.mnemonic = "mov";
    instruction1a.nodeId = 0;
    instruction1a.expressionId = 0;
    instruction1a.expressionType = 5;
    instruction1a.operandPosition = 0;
    instruction1a.symbol = "eax";
    final MockCodeNodeData instruction1b = new MockCodeNodeData();
    instruction1b.mnemonic = "mov";
    instruction1b.nodeId = 0;
    instruction1b.expressionId = 1;
    instruction1b.expressionType = 5;
    instruction1b.operandPosition = 1;
    instruction1b.symbol = "ebx";
    cnProvider.data.add(instruction1a);
    cnProvider.data.add(instruction1b);
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
    final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
    final List<CCodeNode> result = p.parse();
    assertEquals(1, result.size());
    assertEquals(1, Iterables.size(result.get(0).getInstructions()));
    final INaviInstruction instruction = Iterables.getFirst(result.get(0).getInstructions(), null);
    assertEquals("mov", instruction.getMnemonic());
    assertEquals("dword", instruction.getOperands().get(0).getRootNode().getValue());
    assertEquals("eax", instruction.getOperands().get(0).getRootNode().getChildren().get(0).getValue());
    assertEquals("dword", instruction.getOperands().get(1).getRootNode().getValue());
    assertEquals("ebx", instruction.getOperands().get(1).getRootNode().getChildren().get(0).getValue());
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction) Test(org.junit.Test)

Example 39 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class CCodeNodeParserTest method testReference.

@Test
public void testReference() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
    // 00000000: jz 123
    final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
    final MockCodeNodeData instruction1 = new MockCodeNodeData();
    instruction1.reference = new CReference(new CAddress(BigInteger.valueOf(123)), ReferenceType.CONDITIONAL_TRUE);
    instruction1.nodeId = 0;
    instruction1.expressionId = 0;
    instruction1.expressionType = 2;
    instruction1.operandPosition = 0;
    instruction1.immediate = "123";
    cnProvider.data.add(instruction1);
    final MockSqlProvider provider = new MockSqlProvider();
    final MockModule module = new MockModule();
    CFunctionContainerHelper.addFunction(module.getContent().getFunctionContainer(), new MockFunction(0));
    final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(module), provider);
    final List<CCodeNode> result = p.parse();
    assertEquals(1, result.size());
    assertEquals(1, Iterables.size(result.get(0).getInstructions()));
}
Also used : MockFunction(com.google.security.zynamics.binnavi.disassembly.MockFunction) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) MockCodeNodeData(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeData) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) CCodeNode(com.google.security.zynamics.binnavi.disassembly.CCodeNode) CReference(com.google.security.zynamics.binnavi.disassembly.CReference) MockCodeNodeProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockCodeNodeProvider) CCodeNodeParser(com.google.security.zynamics.binnavi.Database.NodeParser.CCodeNodeParser) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 40 with MockSqlProvider

use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.

the class TraceTest method testConstructor.

@Test
public void testConstructor() {
    final Trace trace = new Trace(new TraceList(1, "Name", "Description", new MockSqlProvider()));
    assertEquals("Name", trace.getName());
    assertEquals("Description", trace.getDescription());
    assertEquals("Trace 'Name' [0 events]", trace.toString());
    assertEquals(0, trace.getEvents().size());
}
Also used : Trace(com.google.security.zynamics.binnavi.API.disassembly.Trace) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TraceList(com.google.security.zynamics.binnavi.debug.models.trace.TraceList) Test(org.junit.Test)

Aggregations

MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)111 Test (org.junit.Test)82 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)55 Date (java.util.Date)47 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)44 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)42 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)32 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)29 MockView (com.google.security.zynamics.binnavi.disassembly.MockView)25 CFunction (com.google.security.zynamics.binnavi.disassembly.CFunction)24 Before (org.junit.Before)23 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)17 MockTagManager (com.google.security.zynamics.binnavi.Tagging.MockTagManager)17 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)14 CInstruction (com.google.security.zynamics.binnavi.disassembly.CInstruction)13 CView (com.google.security.zynamics.binnavi.disassembly.views.CView)13 DebuggerTemplate (com.google.security.zynamics.binnavi.debug.debugger.DebuggerTemplate)12 INaviView (com.google.security.zynamics.binnavi.disassembly.views.INaviView)12 Tree (com.google.security.zynamics.zylib.types.trees.Tree)12 ArrayList (java.util.ArrayList)12