use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.
the class PathFinderTest method testRegularFunction.
@Test
public void testRegularFunction() throws CouldntLoadDataException, PartialLoadException {
// Tests pathfinding between two simple functions
// 0x1004565
// 0x1003CD7
final Function startFunction = findFunction(m_notepad, 0x1004565);
final BasicBlock startBlock = findBlock(startFunction, 0x1004629);
final Function endFunction = findFunction(m_notepad, 0x1003C92);
final BasicBlock endBlock = findBlock(endFunction, 0x1003CD7);
final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
assertEquals(7, view.getGraph().nodeCount());
assertEquals(8, view.getGraph().edgeCount());
}
use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.
the class PathFinderTest method testInsideFunctionPartial.
@Test
public void testInsideFunctionPartial() throws CouldntLoadDataException, PartialLoadException {
// Tests path finding somewhere inside a function
final Function startFunction = findFunction(m_notepad, 0x01002452);
final BasicBlock startBlock = findBlock(startFunction, 0x10024C2);
final BasicBlock endBlock = findBlock(startFunction, 0x10026FB);
final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
assertEquals(9, view.getGraph().nodeCount());
assertEquals(11, view.getGraph().edgeCount());
final List<ViewEdge> edges = view.getGraph().getEdges();
final List<ViewNode> nodes = view.getGraph().getNodes();
assertEquals(EdgeType.JumpConditionalFalse, findEdge(edges, 0x10024C2, 0x1002523).getType());
assertEquals(EdgeType.JumpConditionalTrue, findEdge(edges, 0x10024C2, 0x1002539).getType());
assertEquals(EdgeType.JumpUnconditional, findEdge(edges, 0x100253F, 0x10026F9).getType());
assertEquals(Color.GREEN, findNode(nodes, 0x10024C2).getColor());
assertEquals(Color.YELLOW, findNode(nodes, 0x10026FB).getColor());
}
use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.
the class View2D method findView.
/**
* Searches for the API view that wraps a given internal view.
*
* @param database Database to search for.
* @param internalView Internal view to search for.
* @param databases Databases to search through.
*
* @return The API view that wraps the given internal view.
*/
private static View findView(final IDatabase database, final INaviView internalView, final List<Database> databases) {
final Database apiDatabase = ObjectFinders.getObject(database, databases);
View view = null;
for (final Module m : apiDatabase.getModules()) {
if (!m.isLoaded()) {
continue;
}
view = ObjectFinders.getObject(internalView, m.getViews());
if (view != null) {
return view;
}
}
for (final Project project : apiDatabase.getProjects()) {
if (!project.isLoaded()) {
continue;
}
view = ObjectFinders.getObject(internalView, project.getViews());
if (view != null) {
return view;
}
}
throw new IllegalStateException("Error: Unknown view");
}
use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.
the class PathFinderTest method testRecursivePath.
@Test
public void testRecursivePath() throws CouldntLoadDataException, PartialLoadException {
// Tests pathfinding from a simple function to a simple function through
// a recursive path
// GetVolumePathNameA
final Function startFunction = findFunction(m_kernel32, 0x7C82E8B2);
final BasicBlock startBlock = findBlock(startFunction, 0x7C82E8B2);
final Function endFunction = findFunction(m_kernel32, 0x7C8092B0);
final BasicBlock endBlock = findBlock(endFunction, 0x7C8092B0);
final View view = PathFinder.createPath(m_kernel32, startBlock, endBlock, null, null);
assertEquals(1247, view.getGraph().nodeCount());
assertEquals(1988, view.getGraph().edgeCount());
}
use of com.google.security.zynamics.binnavi.API.disassembly.View in project binnavi by google.
the class PathFinderTest method testRecursiveTarget.
@Test
public void testRecursiveTarget() throws CouldntLoadDataException, PartialLoadException {
// Tests pathfinding from a simple function to a self-recursive function
// SetCommConfig
final Function startFunction = findFunction(m_kernel32, 0x7C866E7B);
final BasicBlock startBlock = findBlock(startFunction, 0x7C866EF3);
// SetCommState
final Function endFunction = findFunction(m_kernel32, 0x7C865E16);
final BasicBlock endBlock = findBlock(endFunction, 0x7C866106);
final View view = PathFinder.createPath(m_kernel32, startBlock, endBlock, null, null);
assertEquals(2 + /** calling function **/
66 + /** called function **/
3, /** split blocks **/
view.getGraph().nodeCount());
assertEquals(99 + /** called function **/
1 + /** calling target function **/
3 + 3, /** recursive calls and returns **/
view.getGraph().edgeCount());
}
Aggregations