bool.java
来自「一个用于对.class文件进行插桩的开源工具」· Java 代码 · 共 25 行
JAVA
25 行
InstructionList il = new InstructionList(); ... CodeConstraint constraint = new CodeConstraint() { public boolean checkCode(InstructionHandle[] match) { IfInstruction if1 = (IfInstruction)match[0].getInstruction(); GOTO g = (GOTO)match[2].getInstruction(); return (if1.getTarget() == match[3]) && (g.getTarget() == match[4]); } }; FindPattern f = new FindPattern(il); String pat = "`IfInstruction'`ICONST_0'`GOTO'`ICONST_1'" + "`NOP'(`IFEQ'|`IFNE')"; InstructionHandle[] match; for(InstructionHandle ih = f.search(pat, constraint); ih != null; ih = f.search(pat, match[0], constraint)) { match = f.getMatch(); // Constraint already checked ... match[0].setTarget(match[5].getTarget()); // Update target ... try { il.delete(match[1], match[5]); } catch(TargetLostException e) { ... } }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?