Search in sources :

Example 6 with Module

use of com.google.security.zynamics.binnavi.API.disassembly.Module in project binnavi by google.

the class BreakpointHelpersTest method setUp.

@Before
public void setUp() throws DebugExceptionWrapper, CouldntLoadDataException, LoadCancelledException, FileReadException {
    ConfigManager.instance().read();
    final CDatabase database = new CDatabase("", "", "", "", "", "", "", false, false);
    final Database apiDatabase = new Database(database);
    final SQLProvider mockProvider = new MockSqlProvider();
    final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
    final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
    final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
    final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
    final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
    final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
    m_module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, mockProvider);
    m_module.load();
    m_mockDebugger = new MockDebugger(m_moduleDebugSettings);
    m_mockDebugger.connect();
    m_debugger = new Debugger(m_mockDebugger);
    final INaviFunction parentFunction = m_module.getContent().getFunctionContainer().getFunctions().get(0);
    m_mockDebugger.setAddressTranslator(m_module, new CAddress(0), new CAddress(0x1000));
    final ViewContainer viewContainer = new Module(apiDatabase, m_module, nodeTagManager, viewTagManager);
    final INaviView naviView = new MockView(mockProvider);
    final Function apiFunction = new Function(ModuleFactory.get(), parentFunction);
    final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
    final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
    final COperandTree operand1 = new COperandTree(rootNode1, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
    final COperandTree operand2 = new COperandTree(rootNode2, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
    final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
    final CInstruction internalInstruction = new CInstruction(true, m_module, new CAddress(0x1234), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", mockProvider);
    m_view = new View(viewContainer, naviView, nodeTagManager, viewTagManager);
    m_node = m_view.createCodeNode(apiFunction, Lists.newArrayList(new Instruction(internalInstruction)));
    setM_functionNode(m_view.createFunctionNode(apiFunction));
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) Instruction(com.google.security.zynamics.binnavi.API.disassembly.Instruction) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) ViewContainer(com.google.security.zynamics.binnavi.API.disassembly.ViewContainer) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Function(com.google.security.zynamics.binnavi.API.disassembly.Function) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) COperandTreeNode(com.google.security.zynamics.binnavi.disassembly.COperandTreeNode) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IOperandTree(com.google.security.zynamics.zylib.disassembly.IOperandTree) COperandTree(com.google.security.zynamics.binnavi.disassembly.COperandTree) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) CInstruction(com.google.security.zynamics.binnavi.disassembly.CInstruction) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) View(com.google.security.zynamics.binnavi.API.disassembly.View) MockView(com.google.security.zynamics.binnavi.disassembly.MockView) Date(java.util.Date) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CDatabase(com.google.security.zynamics.binnavi.Database.CDatabase) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) INaviView(com.google.security.zynamics.binnavi.disassembly.views.INaviView) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) IReference(com.google.security.zynamics.zylib.disassembly.IReference) CModule(com.google.security.zynamics.binnavi.disassembly.Modules.CModule) INaviFunction(com.google.security.zynamics.binnavi.disassembly.INaviFunction) Before(org.junit.Before)

Example 7 with Module

use of com.google.security.zynamics.binnavi.API.disassembly.Module in project binnavi by google.

the class CallResolver method resolveFunction.

private ResolvedFunction resolveFunction(final Address address) {
    for (final Module module : target.getModules()) {
        if (!resolvedFunctions.containsKey(module)) {
            resolveFunctions(module);
            if (!resolvedFunctions.containsKey(module)) {
                continue;
            }
        }
        final Map<Address, Function> functionMap = resolvedFunctions.get(module);
        final Function function = functionMap.get(address);
        if (function != null) {
            return new ResolvedFunction(function);
        }
    }
    for (final MemoryModule memoryModule : target.getDebugger().getProcess().getModules()) {
        if ((address.toLong() >= memoryModule.getBaseAddress().toLong()) && (address.toLong() < (memoryModule.getBaseAddress().toLong() + memoryModule.getSize()))) {
            return new ResolvedFunction(memoryModule, address);
        }
    }
    return new ResolvedFunction(address);
}
Also used : Function(com.google.security.zynamics.binnavi.API.disassembly.Function) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) MemoryModule(com.google.security.zynamics.binnavi.API.debug.MemoryModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) MemoryModule(com.google.security.zynamics.binnavi.API.debug.MemoryModule)

Example 8 with Module

use of com.google.security.zynamics.binnavi.API.disassembly.Module in project binnavi by google.

the class CallResolver method stopResolving.

private void stopResolving() {
    for (final Module module : modules) {
        module.removeListener(moduleKeeperListener);
    }
    modules.clear();
    if ((debugger != null) && debugger.isConnected()) {
        try {
            debugger.terminate();
        } catch (final DebugException e) {
            e.printStackTrace();
        }
    }
    if ((step == 3) || (step == 4) || (step == 5)) {
        debugger.removeListener(debuggerListener);
        removeBreakpoints();
    }
    step++;
}
Also used : MemoryModule(com.google.security.zynamics.binnavi.API.debug.MemoryModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) DebugException(com.google.security.zynamics.binnavi.API.debug.DebugException)

Example 9 with Module

use of com.google.security.zynamics.binnavi.API.disassembly.Module in project binnavi by google.

the class CallResolver method removeBreakpoint.

/**
   * Removes a breakpoint from an indirect call.
   *
   * @param indirectCall The indirect call from which the breakpoint is removed.
   */
private void removeBreakpoint(final IndirectCall indirectCall) {
    final Module module = indirectCall.getModule();
    final Address address = indirectCall.getAddress();
    final BreakpointManager breakpointManager = debugger.getBreakpointManager();
    if (breakpointManager.hasBreakpoint(module, address)) {
        debugger.getBreakpointManager().removeBreakpoint(indirectCall.getModule(), indirectCall.getAddress());
    }
}
Also used : Address(com.google.security.zynamics.binnavi.API.disassembly.Address) MemoryModule(com.google.security.zynamics.binnavi.API.debug.MemoryModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) BreakpointManager(com.google.security.zynamics.binnavi.API.debug.BreakpointManager)

Example 10 with Module

use of com.google.security.zynamics.binnavi.API.disassembly.Module in project binnavi by google.

the class CallResolver method loadTargetModules.

/**
   * Loads the modules that belong to the target.
   */
private void loadTargetModules() {
    for (final Module module : target.getModules()) {
        module.addListener(moduleKeeperListener);
        modules.add(module);
        if (!module.isLoaded()) {
            try {
                module.load();
            } catch (final CouldntLoadDataException e) {
                // If we can't load any of the involved modules, we can
                // not proceed to the next step.
                errorLoadingModule(module, e);
                return;
            }
        }
    }
    step++;
}
Also used : CouldntLoadDataException(com.google.security.zynamics.binnavi.API.disassembly.CouldntLoadDataException) MemoryModule(com.google.security.zynamics.binnavi.API.debug.MemoryModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module)

Aggregations

Module (com.google.security.zynamics.binnavi.API.disassembly.Module)25 Database (com.google.security.zynamics.binnavi.API.disassembly.Database)8 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)7 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)7 MemoryModule (com.google.security.zynamics.binnavi.API.debug.MemoryModule)6 TagManager (com.google.security.zynamics.binnavi.API.disassembly.TagManager)6 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)6 CTag (com.google.security.zynamics.binnavi.Tagging.CTag)6 CTagManager (com.google.security.zynamics.binnavi.Tagging.CTagManager)6 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)6 Tree (com.google.security.zynamics.zylib.types.trees.Tree)6 Test (org.junit.Test)6 Project (com.google.security.zynamics.binnavi.API.disassembly.Project)5 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)5 Function (com.google.security.zynamics.binnavi.API.disassembly.Function)4 View (com.google.security.zynamics.binnavi.API.disassembly.View)4 ViewContainer (com.google.security.zynamics.binnavi.API.disassembly.ViewContainer)4 MockDatabase (com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase)4 CModule (com.google.security.zynamics.binnavi.disassembly.Modules.CModule)4 IDatabase (com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase)3