dest = isExitEdge(ifedge); if (dest != null) { BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); ifst.setIfstat(bstat); ifst.getStats().addWithKey(bstat, bstat.id); bstat.setParent(ifst); bstat.addSuccessor(newexitedge); oldexitedge.closure.addLabeledEdge(newexitedge); ret = 1; stat.removeSuccessor(destedge); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); bstat.addSuccessor(newexitedge); oldexitedge.closure.addLabeledEdge(newexitedge); bstat.addPredecessor(edge);
public BasicBlockStatement(BasicBlock block) { type = Statement.TYPE_BASICBLOCK; this.block = block; id = block.id; CounterContainer coun = DecompilerContext.getCounterContainer(); if (id >= coun.getCounter(CounterContainer.STATEMENT_COUNTER)) { coun.setCounter(CounterContainer.STATEMENT_COUNTER, id + 1); } Instruction instr = block.getLastInstruction(); if (instr != null) { if (instr.group == CodeConstants.GROUP_JUMP && instr.opcode != CodeConstants.opc_goto) { lastBasicType = LASTBASICTYPE_IF; } else if (instr.group == CodeConstants.GROUP_SWITCH) { lastBasicType = LASTBASICTYPE_SWITCH; } } // monitorenter and monitorexits buildMonitorFlags(); }
int[] values = ((SwitchInstruction)bbstat.getBlock().getLastInstruction()).getValues(); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.addSuccessor(new StatEdge(sample_edge.getType(), bstat, sample_edge.getDestination(), sample_edge.closure)); bstat.addPredecessor(edge); bstat.setParent(this);
public static void destroyAndFlattenStatement(Statement stat) { destroyStatementContent(stat, false); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); if (stat.getExprents() == null) { bstat.setExprents(new ArrayList<>()); } else { bstat.setExprents(DecHelper.copyExprentList(stat.getExprents())); } stat.getParent().replaceStatement(stat, bstat); }
BasicBlock firstBasicBlock = firstBlockStatement.getBlock(); Instruction instrFirst = firstBasicBlock.getInstruction(0); ssa.splitVariables(root, mt); List<Exprent> lstExprents = firstBlockStatement.getExprents(); if (blockStatement != null && blockStatement.getBlock() != null) { Statement handler = fstat.getHandler(); for (StatEdge edge : blockStatement.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL)) { if (edge.getType() != StatEdge.TYPE_REGULAR && handler.containsStatement(blockStatement) && !handler.containsStatement(edge.getDestination())) { Boolean existingFlag = mapLast.get(blockStatement.getBlock()); mapLast.put(blockStatement.getBlock(), isTrueExit); break;
private static Set<BasicBlock> getAllBasicBlocks(Statement stat) { List<Statement> lst = new LinkedList<>(); lst.add(stat); int index = 0; do { Statement st = lst.get(index); if (st.type == Statement.TYPE_BASICBLOCK) { index++; } else { lst.addAll(st.getStats()); lst.remove(index); } } while (index < lst.size()); Set<BasicBlock> res = new HashSet<>(); for (Statement st : lst) { res.add(((BasicBlockStatement)st).getBlock()); } return res; }
BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(new ArrayList<>()); stat.replaceStatement(firstif, bstat); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(new ArrayList<>()); bstat.addSuccessor(ifedge);
@Override public Statement getSimpleCopy() { BasicBlock newblock = new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER)); SimpleInstructionSequence seq = new SimpleInstructionSequence(); for (int i = 0; i < block.getSeq().length(); i++) { seq.addInstruction(block.getSeq().getInstr(i).clone(), -1); } newblock.setSeq(seq); return new BasicBlockStatement(newblock); }
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1); if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) { if (BODY_EXPR.equals(body.getExprents().get(0)) && HANDLER_EXPR.equals(handler.getExprents().get(0))) { map.put(wrapper, method); break;
if (block != null) { processBlock(block, data, cl); block.setExprents(data.getLstExprents());
private static void addDeletedGotoInstructionMapping(Statement stat, BytecodeMappingTracer tracer) { if (stat instanceof BasicBlockStatement) { BasicBlock block = ((BasicBlockStatement)stat).getBlock(); List<Integer> offsets = block.getInstrOldOffsets(); if (!offsets.isEmpty() && offsets.size() > block.getSeq().length()) { // some instructions have been deleted, but we still have offsets tracer.addMapping(offsets.get(offsets.size() - 1)); // add the last offset } } }
BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(new ArrayList<>()); stat.replaceStatement(firstif, bstat); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(new ArrayList<>()); bstat.addSuccessor(ifedge);
BasicBlock firstBasicBlock = firstBlockStatement.getBlock(); Instruction instrFirst = firstBasicBlock.getInstruction(0); ssa.splitVariables(root, mt); List<Exprent> lstExprents = firstBlockStatement.getExprents(); if (blockStatement != null && blockStatement.getBlock() != null) { Statement handler = fstat.getHandler(); for (StatEdge edge : blockStatement.getSuccessorEdges(Statement.STATEDGE_DIRECT_ALL)) { if (edge.getType() != StatEdge.TYPE_REGULAR && handler.containsStatement(blockStatement) && !handler.containsStatement(edge.getDestination())) { Boolean existingFlag = mapLast.get(blockStatement.getBlock()); mapLast.put(blockStatement.getBlock(), isTrueExit); break;
private static void removeLastEmptyStatement(DoStatement dostat, Statement stat) { if (stat == dostat.getFirst()) { BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(new ArrayList<>()); dostat.replaceStatement(stat, bstat); } else { for (StatEdge edge : stat.getAllPredecessorEdges()) { edge.getSource().changeEdgeType(Statement.DIRECTION_FORWARD, edge, StatEdge.TYPE_CONTINUE); stat.removePredecessor(edge); edge.getSource().changeEdgeNode(Statement.DIRECTION_FORWARD, edge, dostat); dostat.addPredecessor(edge); dostat.addLabeledEdge(edge); } // parent is a sequence statement stat.getParent().getStats().removeWithKey(stat.id); } }
Statement newstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); newstat.setExprents(Arrays.asList(new Exprent[]{asexpr}));
BasicBlockStatement handler = (BasicBlockStatement)cst.getStats().get(1); if (body.getExprents().size() == 1 && handler.getExprents().size() == 1) { if (BODY_EXPR.equals(body.getExprents().get(0)) && HANDLER_EXPR.equals(handler.getExprents().get(0))) { map.put(wrapper, method); break;
if (block != null) { processBlock(block, data, cl); block.setExprents(data.getLstExprents());
dest = isExitEdge(ifedge); if (dest != null) { BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); ifst.setIfstat(bstat); ifst.getStats().addWithKey(bstat, bstat.id); bstat.setParent(ifst); bstat.addSuccessor(newexitedge); oldexitedge.closure.addLabeledEdge(newexitedge); ret = 1; stat.removeSuccessor(destedge); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.setExprents(DecHelper.copyExprentList(dest.getExprents())); bstat.addSuccessor(newexitedge); oldexitedge.closure.addLabeledEdge(newexitedge); bstat.addPredecessor(edge);
int[] values = ((SwitchInstruction)bbstat.getBlock().getLastInstruction()).getValues(); BasicBlockStatement bstat = new BasicBlockStatement(new BasicBlock( DecompilerContext.getCounterContainer().getCounterAndIncrement(CounterContainer.STATEMENT_COUNTER))); bstat.addSuccessor(new StatEdge(sample_edge.getType(), bstat, sample_edge.getDestination(), sample_edge.closure)); bstat.addPredecessor(edge); bstat.setParent(this);
private static int getStatementSize(Statement statement) { int res; if (statement.type == Statement.TYPE_BASICBLOCK) { res = ((BasicBlockStatement)statement).getBlock().getSeq().length(); } else { res = statement.getStats().stream().mapToInt(IrreducibleCFGDeobfuscator::getStatementSize).sum(); } return res; }