use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.
the class CViewTest method testConstructor3.
@Test
public void testConstructor3() {
try {
new CView(new BigInteger(31, random).intValue(), (INaviProject) null, "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
fail();
} catch (final NullPointerException e) {
}
final int viewId = new BigInteger(31, random).intValue();
final CView view = new CView(viewId, new MockProject(), "Blub", "Bla", ViewType.Native, GraphType.FLOWGRAPH, new Date(1234), new Date(12345), 123, 700, new HashSet<CTag>(), new HashSet<CTag>(), false, new MockSqlProvider());
assertEquals(viewId, view.getConfiguration().getId());
}
use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.
the class SectionContainerBackendTest method setUp.
@Before
public void setUp() {
provider = new MockSqlProvider();
module = new MockModule(provider);
}
use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.
the class CCodeNodeParserTest method testEmpty.
@Test
public void testEmpty() throws ParserException, CPartialLoadException {
final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
final MockSqlProvider provider = new MockSqlProvider();
final CCodeNodeParser p = new CCodeNodeParser(cnProvider, Lists.newArrayList(new MockModule()), provider);
final List<CCodeNode> result = p.parse();
assertEquals(0, result.size());
}
use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.
the class CCodeNodeParserTest method testAddZero.
@Test
public void testAddZero() throws ParserException, CPartialLoadException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
// 00000000: mov eax, [esp+0]
final MockCodeNodeProvider cnProvider = new MockCodeNodeProvider();
final MockCodeNodeData instruction2 = new MockCodeNodeData();
instruction2.nodeId = 5193;
instruction2.address = new CAddress(0x4180dd);
instruction2.mnemonic = "mov";
instruction2.operandPosition = 0;
instruction2.expressionId = 1;
instruction2.expressionType = 6;
instruction2.symbol = "b4";
instruction2.immediate = null;
instruction2.parentId = 0;
instruction2.replacement = null;
final MockCodeNodeData instruction3 = new MockCodeNodeData();
instruction3.nodeId = 5193;
instruction3.address = new CAddress(0x4180dd);
instruction3.mnemonic = "mov";
instruction3.operandPosition = 0;
instruction3.expressionId = 29;
instruction3.expressionType = 4;
instruction3.symbol = "ss:";
instruction3.immediate = null;
instruction3.parentId = 1;
instruction3.replacement = null;
final MockCodeNodeData instruction4 = new MockCodeNodeData();
instruction4.nodeId = 5193;
instruction4.address = new CAddress(0x4180dd);
instruction4.mnemonic = "mov";
instruction4.operandPosition = 0;
instruction4.expressionId = 30;
instruction4.expressionType = 7;
instruction4.symbol = "[";
instruction4.immediate = null;
instruction4.parentId = 29;
instruction4.replacement = null;
final MockCodeNodeData instruction5 = new MockCodeNodeData();
instruction5.nodeId = 5193;
instruction5.address = new CAddress(0x4180dd);
instruction5.mnemonic = "mov";
instruction5.operandPosition = 0;
instruction5.expressionId = 31;
instruction5.expressionType = 4;
instruction5.symbol = "+";
instruction5.immediate = null;
instruction5.parentId = 30;
instruction5.replacement = null;
final MockCodeNodeData instruction6 = new MockCodeNodeData();
instruction6.nodeId = 5193;
instruction6.address = new CAddress(0x4180dd);
instruction6.mnemonic = "mov";
instruction6.operandPosition = 0;
instruction6.expressionId = 32;
instruction6.expressionType = 5;
instruction6.symbol = "esp";
instruction6.immediate = null;
instruction6.parentId = 31;
instruction6.replacement = null;
final MockCodeNodeData instruction7 = new MockCodeNodeData();
instruction7.nodeId = 5193;
instruction7.address = new CAddress(0x4180dd);
instruction7.mnemonic = "mov";
instruction7.operandPosition = 0;
instruction7.expressionId = 498;
instruction7.expressionType = 2;
instruction7.symbol = null;
instruction7.immediate = "0";
instruction7.parentId = 31;
instruction7.replacement = "134h+var_134";
final MockCodeNodeData instruction1 = new MockCodeNodeData();
instruction1.nodeId = 5193;
instruction1.address = new CAddress(0x4180dd);
instruction1.mnemonic = "mov";
instruction1.operandPosition = 1;
instruction1.expressionId = 1594;
instruction1.expressionType = 2;
instruction1.symbol = null;
instruction1.immediate = "4561216";
instruction1.parentId = 0;
instruction1.replacement = null;
cnProvider.data.add(instruction2);
cnProvider.data.add(instruction3);
cnProvider.data.add(instruction4);
cnProvider.data.add(instruction5);
cnProvider.data.add(instruction6);
cnProvider.data.add(instruction7);
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()));
final ReilTranslator<INaviInstruction> translator = new ReilTranslator<INaviInstruction>();
try {
translator.translate(new StandardEnvironment(), Iterables.get(result.get(0).getInstructions(), 0));
} catch (final InternalTranslationException exception) {
CUtilityFunctions.logException(exception);
}
}
use of com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider in project binnavi by google.
the class ViewGraphHelpersTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, LoadCancelledException, com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException, PartialLoadException {
final MockSqlProvider provider = new MockSqlProvider();
final TagManager tagManager = new TagManager(new MockTagManager(TagType.NODE_TAG));
final TagManager viewTagManager = new TagManager(new CTagManager(new Tree<CTag>(new TreeNode<CTag>(new CTag(1, "", "", TagType.VIEW_TAG, provider))), TagType.VIEW_TAG, provider));
final Database database = new Database(new MockDatabase());
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
internalModule.load();
final Module module = new Module(database, internalModule, tagManager, viewTagManager);
final CModuleViewGenerator generator = new CModuleViewGenerator(provider, internalModule);
final INaviView internalView = generator.generate(1, "My View", "My View Description", com.google.security.zynamics.zylib.disassembly.ViewType.NonNative, GraphType.MIXED_GRAPH, new Date(), new Date(), 1, 2, new HashSet<CTag>(), new HashSet<CTag>(), false);
m_view = new View(module, internalView, tagManager, viewTagManager);
m_view.load();
final List<INaviInstruction> instructions = new ArrayList<INaviInstruction>();
instructions.add(new CInstruction(false, internalModule, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
instructions.add(new CInstruction(false, internalModule, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
instructions.add(new CInstruction(false, internalModule, new CAddress(0x125), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", provider));
final INaviCodeNode codeNode = internalView.getContent().createCodeNode(null, instructions);
final List<INaviViewNode> nodes1 = new ArrayList<INaviViewNode>();
nodes1.add(codeNode);
final List<INaviEdge> edges1 = new ArrayList<INaviEdge>();
final CFunction internalFunction = new CFunction(internalModule, new MockView(nodes1, edges1, provider), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
internalFunction.load();
final Function function = new Function(module, internalFunction);
final CFunctionNode functionNode = new CFunctionNode(0, internalFunction, 0, 0, 0, 0, Color.RED, false, false, null, new HashSet<CTag>(), provider);
m_codeNode = new CodeNode(m_view, codeNode, tagManager);
m_functionNode = new FunctionNode(m_view, functionNode, function, tagManager);
m_textNode = new TextNode(m_view, new MockTextNode(), tagManager);
final List<ViewNode> nodes = Lists.newArrayList(m_codeNode, m_functionNode, m_textNode);
final List<ViewEdge> edges = Lists.newArrayList(new ViewEdge(new MockEdge(1, provider), nodes.get(0), nodes.get(0)));
m_graph = new ViewGraph(nodes, edges);
}
Aggregations