use of com.google.security.zynamics.binnavi.API.disassembly.BasicBlock in project binnavi by google.
the class PathFinderTest method testPassingFunctionContinue.
@Test
public void testPassingFunctionContinue() throws CouldntLoadDataException, PartialLoadException {
// Tests pathfinding from one function to another function while passing one function
// and having a target block that is NOT a RETURN block.
//
// What should happen here is that multiple paths are generated because the target
// block is not necessarily hit the first time the function is entered.
// 0x1004565 -> 0x1003C92 -> 0x100398D
final Function startFunction = findFunction(m_notepad, 0x1004565);
final BasicBlock startBlock = findBlock(startFunction, 0x1004629);
final Function endFunction = findFunction(m_notepad, 0x100398D);
final BasicBlock endBlock = findBlock(endFunction, 0x10039D1);
final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
assertEquals(37, view.getGraph().nodeCount());
assertEquals(64, view.getGraph().edgeCount());
}
use of com.google.security.zynamics.binnavi.API.disassembly.BasicBlock 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());
}
use of com.google.security.zynamics.binnavi.API.disassembly.BasicBlock in project binnavi by google.
the class PathFinderTest method testInsideFunction.
// @Test
// public void testFoo() throws CouldntLoadDataException, CouldntSaveDataException
// {
// // TODO: Bring this test back in msw3prt.idb
//
// final Function startFunction = findFunction(m_foo, 0x5FEF8426);
// final BasicBlock startBlock = findBlock(startFunction, 0x5FEF8426);
//
// final Function endFunction = findFunction(m_foo, 0x5FEFF06D);
// final BasicBlock endBlock = findBlock(endFunction, 0x5FEFF0DB);
//
// final View view = PathFinder.createPath(m_foo, startBlock, endBlock, null, null);
//
// assertEquals(46, view.getGraph().nodeCount());
// assertEquals(49, view.getGraph().edgeCount());
// }
@Test
public void testInsideFunction() throws CouldntLoadDataException, PartialLoadException {
// Tests path finding from the beginning to the end of a single function
final Function startFunction = findFunction(m_notepad, 0x01002B87);
final BasicBlock startBlock = findBlock(startFunction, 0x1002B87);
final BasicBlock endBlock = findBlock(startFunction, 0x100336A);
final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
assertEquals(96, view.getGraph().nodeCount());
assertEquals(150, view.getGraph().edgeCount());
}
use of com.google.security.zynamics.binnavi.API.disassembly.BasicBlock in project binnavi by google.
the class PathFinderTest method testToImportedFunction.
@Test
public void testToImportedFunction() throws CouldntLoadDataException, PartialLoadException {
// Tests from the beginning of a function to an imported function
final Function startFunction = findFunction(m_notepad, 0x0100398D);
final BasicBlock startBlock = findBlock(startFunction, 0x100398D);
final Function endFunction = findFunction(m_notepad, 0x1001000);
endFunction.load();
final View view = PathFinder.createPath(m_notepad, startBlock, null, null, endFunction);
assertEquals(3, view.getGraph().nodeCount());
assertEquals(2, view.getGraph().edgeCount());
}
use of com.google.security.zynamics.binnavi.API.disassembly.BasicBlock in project binnavi by google.
the class PathFinderTest method testPassingFunctionReturn.
@Test
public void testPassingFunctionReturn() throws CouldntLoadDataException, PartialLoadException {
// Tests pathfinding from one function to another function while passing one function
// and having a target block that is a RETURN block.
//
// What should happen here is that the pathfinding algorithm stops when it reaches
// the RETURN node. That is consecutive calls to the target function should not
// be part of the pathfinding result.
// 0x1004565 -> 0x1003C92 -> 0x100398D
final Function startFunction = findFunction(m_notepad, 0x1004565);
final BasicBlock startBlock = findBlock(startFunction, 0x1004629);
final Function endFunction = findFunction(m_notepad, 0x100398D);
final BasicBlock endBlock = findBlock(endFunction, 0x10039D9);
final View view = PathFinder.createPath(m_notepad, startBlock, endBlock, null, null);
assertEquals(14, view.getGraph().nodeCount());
assertEquals(19, view.getGraph().edgeCount());
}
Aggregations