use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLVerifyNotepadTest method verifyViews.
@Test
public void verifyViews() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException, IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final SQLProvider provider = (SQLProvider) ReflectionHelpers.getField(m_database, "provider");
final INaviModule module = m_database.getContent().getModules().get(0);
module.load();
final List<INaviView> views = module.getContent().getViewContainer().getViews();
final INaviView callgraph = views.get(0);
assertEquals(null, module.getContent().getViewContainer().getFunction(callgraph));
assertEquals(ViewType.Native, callgraph.getType());
assertEquals(GraphType.CALLGRAPH, callgraph.getGraphType());
assertEquals(287, callgraph.getNodeCount());
assertEquals(848, callgraph.getEdgeCount());
callgraph.load();
assertEquals(287, callgraph.getNodeCount());
assertEquals(848, callgraph.getEdgeCount());
callgraph.close();
final LinkedHashSet<?> cgListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(CommentManager.get(provider), "listeners"), "m_listeners");
assertEquals(module.getContent().getFunctionContainer().getFunctions().size() + 1, // the +1 here is the listener in the type instance container.
cgListeners.size());
for (int i = 1; i < views.size(); i++) {
final INaviView view = views.get(i);
final INaviFunction function = module.getContent().getViewContainer().getFunction(view);
assertEquals(view.getName(), function.getName());
assertEquals(ViewType.Native, view.getType());
assertEquals(GraphType.FLOWGRAPH, view.getGraphType());
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
view.load();
function.load();
assertEquals(view.getNodeCount(), function.getBasicBlockCount());
assertEquals(view.getEdgeCount(), function.getEdgeCount());
if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(0x1001929))) {
assertEquals(view.getNodeCount(), 5);
assertEquals(view.getEdgeCount(), 6);
} else if (function.getAddress().toBigInteger().equals(BigInteger.valueOf(16790571))) {
assertEquals(view.getNodeCount(), 92);
assertEquals(view.getEdgeCount(), 144);
} else if (i == 1) {
assertEquals(view.getNodeCount(), 0);
assertEquals(view.getEdgeCount(), 0);
}
view.close();
function.close();
}
module.close();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLVerifyNotepadTest method verifyReferences.
@Test
public void verifyReferences() throws CouldntLoadDataException, LoadCancelledException {
final INaviModule module = m_database.getContent().getModules().get(0);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction(new CAddress(BigInteger.valueOf(0x01006F10)));
function.load();
final List<IBlockNode> blocks = function.getBasicBlocks();
final IBlockNode block = blocks.get(12);
assertEquals(BigInteger.valueOf(0x100702B), block.getAddress().toBigInteger());
final Iterable<INaviInstruction> instructions = block.getInstructions();
assertEquals(1, Iterables.get(instructions, 10).getOperands().get(0).getRootNode().getChildren().get(0).getReferences().size());
module.close();
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsDeleteReference4.
@Test
public void testInstructionFunctionsDeleteReference4() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException, CouldntDeleteException, MaybeNullException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
final IAddress address = instruction.getAddress();
final ReferenceType type = ReferenceType.DATA;
final int references = node.getReferences().size();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
final INaviModule module2 = getProvider().loadModules().get(1);
module2.load();
final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function2.load();
final IBlockNode basicBlock2 = function2.getBasicBlocks().get(0);
final INaviInstruction instruction2 = Iterables.get(basicBlock2.getInstructions(), 1);
final COperandTree tree2 = instruction2.getOperands().get(0);
final INaviOperandTreeNode node2 = tree2.getRootNode();
assertEquals(references + 1, node2.getReferences().size());
PostgreSQLInstructionFunctions.deleteReference(getProvider(), node2, address, type);
final INaviModule module3 = getProvider().loadModules().get(1);
module3.load();
final INaviFunction function3 = module3.getContent().getFunctionContainer().getFunction("DelayLoadFailureHook");
function3.load();
final IBlockNode basicBlock3 = function3.getBasicBlocks().get(0);
final INaviInstruction instruction3 = Iterables.get(basicBlock3.getInstructions(), 1);
final COperandTree tree3 = instruction3.getOperands().get(0);
final INaviOperandTreeNode node3 = tree3.getRootNode();
assertEquals(references, node3.getReferences().size());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsAddReference4.
@Test(expected = NullPointerException.class)
public void testInstructionFunctionsAddReference4() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, null, null);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviFunction in project binnavi by google.
the class CModuleTest method test_C_getFunction2.
@Test
public void test_C_getFunction2() throws CouldntLoadDataException, LoadCancelledException {
try {
m_module.getContent().getViewContainer().getFunction((INaviView) null);
fail();
} catch (final NullPointerException exception) {
}
m_module.load();
int counter = 0;
final List<INaviFunction> functions = m_module.getContent().getFunctionContainer().getFunctions();
for (final INaviView view : m_module.getContent().getViewContainer().getNativeFlowgraphViews()) {
assertEquals(functions.get(counter), m_module.getContent().getViewContainer().getFunction(view));
counter++;
}
}
Aggregations