Package org.jakstab

Examples of org.jakstab.Program


  @Override
  public Precision initPrecision(Location location, StateTransformer transformer) {
    ExplicitPrecision p = new ExplicitPrecision(varThreshold.getValue());
   
    // Increase precision of ecx, esi, edi for REP prefixed instructions
    Program program = Program.getProgram();
    if (BoundedAddressTracking.repPrecBoost.getValue()) {
      AbsoluteAddress addr = location.getAddress();
      X86Instruction instr = (X86Instruction)program.getInstruction(addr);
      if (instr != null && (instr.hasPrefixREPZ() || instr.hasPrefixREPNZ())) {
        logger.debug("boost-rep: REP instruction at " + location + ", increasing precision of loop registers.");
        p.setThreshold(ExpressionFactory.createVariable("%ecx"), 1000);
        p.setThreshold(ExpressionFactory.createVariable("%esi"), 1000);
        p.setThreshold(ExpressionFactory.createVariable("%edi"), 1000);
View Full Code Here


  @SuppressWarnings("unused")
  private static final Logger logger = Logger.getLogger(PessimisticBasicBlockFactory.class);

  @Override
  public Set<CFAEdge> getTransformers(final AbstractState a) {
    Program program = Program.getProgram();
    // First statement
    RTLStatement firstStmt = program.getStatement(a.getLocation());

    Set<RTLStatement> blockHeads = new FastSet<RTLStatement>();
    if (firstStmt instanceof RTLGoto) {
      // Multiple blocks
      blockHeads = gotoToAssumes(a, (RTLGoto)firstStmt);
    } else if (firstStmt instanceof RTLHalt) {
      // Nothing
      blockHeads = Collections.emptySet();
    } else {
      // Single Block
      blockHeads = new FastSet<RTLStatement>(firstStmt);
    }

    Set<CFAEdge> transformers = new FastSet<CFAEdge>();

    for (RTLStatement head : blockHeads) {

      BasicBlock block = new BasicBlock();
      RTLStatement stmt = head;

      while (true) {
        if (stmt instanceof RTLGoto || stmt instanceof RTLHalt) {
          break;
        } else {
          block.add(stmt);
          stmt = program.getStatement(stmt.getNextLabel());
        }
      }
      transformers.add(new CFAEdge(head.getLabel(), stmt.getLabel(), block));
    }
View Full Code Here

  private List<AbsoluteAddress> entryPoints;
 
  public HeuristicHarness() {
    entryPoints = new LinkedList<AbsoluteAddress>();
   
    Program program = Program.getProgram();
   
    if (program.getMainModule() instanceof AbstractCOFFModule) {
    byte[] data = ((AbstractCOFFModule)program.getMainModule()).getByteArray();
    for (int filePtr=0; filePtr<data.length; filePtr++) {
      patternLoop: for (int patternIdx = 0; patternIdx < procedureHeads.length; patternIdx++) {
        for (int i = 0; i < procedureHeads[patternIdx].length; i++) {
          if (data[filePtr + i] != procedureHeads[patternIdx][i])
            continue patternLoop;
        }
        // Pattern matched!
        AbsoluteAddress newEntryPoint = program.getMainModule().getVirtualAddress(filePtr);
        entryPoints.add(newEntryPoint);
        logger.verbose("Found possible procedure entry at " + newEntryPoint);
        filePtr += procedureHeads[patternIdx].length;
        break;
      }
View Full Code Here

   
    File peFile = new File(Options.jakstabHome + "/input/bin/" + file);
    logger.info("----------");
    logger.info("Testing " + peFile);
   
    Program program = Program.createProgram(arch);
    program.loadMainModule(peFile);
    program.installHarness(new DefaultHarness());
    ControlFlowReconstruction cfr = new ControlFlowReconstruction(program);
    cfr.run();

    assertEquals(numInstructions, program.getAssemblyMap().size());
    assertEquals(numStatements, program.getStatements().size());
    assertTrue("Not enough edges!", numEdges <= program.getCFA().size());
    if (checkCompleteness)
      assertTrue("Analysis timed out when it should not!", cfr.isCompleted());
  }
View Full Code Here

TOP

Related Classes of org.jakstab.Program

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.