use of jadx.core.utils.exceptions.JadxException in project jadx by skylot.
the class JavaToDex method resetOutDexVar.
private void resetOutDexVar() throws JadxException {
try {
Field outputDex = Main.class.getDeclaredField("outputDex");
outputDex.setAccessible(true);
outputDex.set(null, null);
} catch (Exception e) {
throw new JadxException("Failed to reset outputDex field", e);
}
}
use of jadx.core.utils.exceptions.JadxException in project jadx by skylot.
the class ManifestAttributes method loadXML.
private Document loadXML(String xml) throws JadxException, ParserConfigurationException, SAXException, IOException {
Document doc;
InputStream xmlStream = null;
try {
xmlStream = ManifestAttributes.class.getResourceAsStream(xml);
if (xmlStream == null) {
throw new JadxException(xml + " not found in classpath");
}
DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
doc = dBuilder.parse(xmlStream);
} finally {
close(xmlStream);
}
return doc;
}
use of jadx.core.utils.exceptions.JadxException in project jadx by skylot.
the class JadxDecompiler method loadFiles.
public void loadFiles(List<File> files) throws JadxException {
if (files.isEmpty()) {
throw new JadxException("Empty file list");
}
inputFiles.clear();
for (File file : files) {
try {
InputFile.addFilesFrom(file, inputFiles);
} catch (IOException e) {
throw new JadxException("Error load file: " + file, e);
}
}
parse();
}
use of jadx.core.utils.exceptions.JadxException in project jadx by skylot.
the class ResourcesLoader method decodeStream.
public static ResContainer decodeStream(ResourceFile rf, ResourceDecoder decoder) throws JadxException {
ZipRef zipRef = rf.getZipRef();
if (zipRef == null) {
return null;
}
ZipFile zipFile = null;
InputStream inputStream = null;
ResContainer result = null;
try {
zipFile = new ZipFile(zipRef.getZipFile());
ZipEntry entry = zipFile.getEntry(zipRef.getEntryName());
if (entry == null) {
throw new IOException("Zip entry not found: " + zipRef);
}
inputStream = new BufferedInputStream(zipFile.getInputStream(entry));
result = decoder.decode(entry.getSize(), inputStream);
} catch (Exception e) {
throw new JadxException("Error decode: " + zipRef.getEntryName(), e);
} finally {
try {
if (zipFile != null) {
zipFile.close();
}
} catch (Exception e) {
LOG.error("Error close zip file: {}", zipRef, e);
}
close(inputStream);
}
return result;
}
use of jadx.core.utils.exceptions.JadxException in project jadx by skylot.
the class JadxCLI method processArgs.
static boolean processArgs(JadxCLIArgs jadxArgs, String[] args) throws JadxException {
if (!jadxArgs.processArgs(args)) {
return false;
}
if (jadxArgs.getInput().isEmpty()) {
LOG.error("Please specify input file");
jadxArgs.printUsage();
return false;
}
File outputDir = jadxArgs.getOutDir();
if (outputDir == null) {
String outDirName;
File file = jadxArgs.getInput().get(0);
String name = file.getName();
int pos = name.lastIndexOf('.');
if (pos != -1) {
outDirName = name.substring(0, pos);
} else {
outDirName = name + "-jadx-out";
}
LOG.info("output directory: {}", outDirName);
outputDir = new File(outDirName);
jadxArgs.setOutputDir(outputDir);
}
if (outputDir.exists() && !outputDir.isDirectory()) {
throw new JadxException("Output directory exists as file " + outputDir);
}
return true;
}
Aggregations