@Override public void setParentInsn(InsnNode parentInsn) { if (parentInsn == wrappedInsn) { throw new JadxRuntimeException("Can't wrap instruction info itself: " + parentInsn); } this.parentInsn = parentInsn; }
@Override public void setArg(int n, InsnArg arg) { throw new JadxRuntimeException("Unsupported operation for PHI node"); }
private static BlockNode getBlock(int offset, Map<Integer, BlockNode> blocksMap) { BlockNode block = blocksMap.get(offset); if (block == null) { throw new JadxRuntimeException("Missing block: " + offset); } return block; }
private String processVar(String varName) { String str = values.get(varName); if (str == null) { throw new JadxRuntimeException("Unknown variable: '" + varName + "' in template: " + templateName); } return str; } }
public static ImageIcon openIcon(String name) { String iconPath = "/icons-16/" + name + ".png"; URL resource = Utils.class.getResource(iconPath); if (resource == null) { throw new JadxRuntimeException("Icon not found: " + iconPath); } return new ImageIcon(resource); }
public static File createTempFile(String suffix) { File temp; try { temp = File.createTempFile("jadx-tmp-", System.nanoTime() + "-" + suffix); temp.deleteOnExit(); } catch (IOException e) { throw new JadxRuntimeException("Failed to create temp file with suffix: " + suffix); } return temp; }
public static void makeDirs(@Nullable File dir) { if (dir != null) { synchronized (MKDIR_SYNC) { if (!dir.mkdirs() && !dir.isDirectory()) { throw new JadxRuntimeException("Can't create directory " + dir); } } } }
public static Image openImage(String path) { URL resource = Utils.class.getResource(path); if (resource == null) { throw new JadxRuntimeException("Image not found: " + path); } return Toolkit.getDefaultToolkit().createImage(resource); }
/** * Add exception type to catch block * @param type - null for 'all' or 'Throwable' handler */ public void addCatchType(@Nullable ClassInfo type) { if (type != null) { this.catchTypes.add(type); } else { if (!this.catchTypes.isEmpty()) { throw new JadxRuntimeException("Null type added to not empty exception handler: " + this); } } }
public static File createTempDir(String suffix) { try { Path path = Files.createTempDirectory("jadx-tmp-" + System.nanoTime() + "-" + suffix); path.toFile().deleteOnExit(); return path.toFile(); } catch (IOException e) { throw new JadxRuntimeException("Failed to create temp directory with suffix: " + suffix); } }
private Document loadXML(String xml) { Document doc; try (InputStream xmlStream = ManifestAttributes.class.getResourceAsStream(xml)) { if (xmlStream == null) { throw new JadxRuntimeException(xml + " not found in classpath"); } DocumentBuilder dBuilder = XmlSecurity.getSecureDbf().newDocumentBuilder(); doc = dBuilder.parse(xmlStream); } catch (Exception e) { throw new JadxRuntimeException("Xml load error, file: " + xml, e); } return doc; }
public void load() throws IOException, DecodeException { try (InputStream input = getClass().getResourceAsStream(CLST_FILENAME)) { if (input == null) { throw new JadxRuntimeException("Can't load classpath file: " + CLST_FILENAME); } load(input); } }
private void saveResourceFile(ResourceFile resFile, File outFile) throws JadxException { ResourcesLoader.decodeStream(resFile, (size, is) -> { try (FileOutputStream fileStream = new FileOutputStream(outFile)) { IOUtils.copy(is, fileStream); } catch (Exception e) { throw new JadxRuntimeException("Resource file save error", e); } return null; }); } }
public void bindArg(RegisterArg arg, BlockNode pred) { if (blockBinds.containsValue(pred)) { throw new JadxRuntimeException("Duplicate predecessors in PHI insn: " + pred + ", " + this); } addArg(arg); blockBinds.put(arg, pred); }
private static void load(LangLocale locale) { ResourceBundle bundle; ClassLoader classLoader = ClassLoader.getSystemClassLoader(); String resName = String.format("i18n/Messages_%s.properties", locale.get()); URL bundleUrl = classLoader.getResource(resName); if (bundleUrl == null) { throw new JadxRuntimeException("Locale resource not found: " + resName); } try (Reader reader = new InputStreamReader(bundleUrl.openStream(), StandardCharsets.UTF_8)) { bundle = new PropertyResourceBundle(reader); } catch (IOException e) { throw new JadxRuntimeException("Failed to load " + resName, e); } i18nMessagesMap.put(locale, bundle); }
private void loadFiles(List<File> files) { if (files.isEmpty()) { throw new JadxRuntimeException("Empty file list"); } inputFiles.clear(); for (File file : files) { try { InputFile.addFilesFrom(file, inputFiles, args.isSkipSources()); } catch (Exception e) { throw new JadxRuntimeException("Error load file: " + file, e); } } }
public static BlockNode selectOther(BlockNode node, List<BlockNode> blocks) { List<BlockNode> list = blocks; if (list.size() > 2) { list = cleanBlockList(list); } if (list.size() != 2) { throw new JadxRuntimeException("Incorrect nodes count for selectOther: " + node + " in " + list); } BlockNode first = list.get(0); if (first != node) { return first; } else { return list.get(1); } }
public IfRegion(IRegion parent, BlockNode header) { super(parent); if (header.getInstructions().size() != 1) { throw new JadxRuntimeException("Expected only one instruction in 'if' header"); } this.header = header; this.condition = IfCondition.fromIfBlock(header); }
public void addClasspath(ClsSet set) { if (nameMap == null) { nameMap = new HashMap<>(set.getClassesCount()); set.addToMap(nameMap); } else { throw new JadxRuntimeException("Classpath already loaded"); } }
public static boolean hasBreakInsn(IContainer container) { if (container instanceof IBlock) { return BlockUtils.checkLastInsnType((IBlock) container, InsnType.BREAK); } else if (container instanceof IRegion) { List<IContainer> blocks = ((IRegion) container).getSubBlocks(); return !blocks.isEmpty() && hasBreakInsn(blocks.get(blocks.size() - 1)); } else { throw new JadxRuntimeException("Unknown container type: " + container); } }