Search in sources :

Example 6 with JadxException

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);
    }
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) Field(java.lang.reflect.Field) JadxException(jadx.core.utils.exceptions.JadxException) UnsupportedEncodingException(java.io.UnsupportedEncodingException)

Example 7 with JadxException

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;
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) DocumentBuilder(javax.xml.parsers.DocumentBuilder) InputStream(java.io.InputStream) Document(org.w3c.dom.Document)

Example 8 with JadxException

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();
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) IOException(java.io.IOException) InputFile(jadx.core.utils.files.InputFile) File(java.io.File)

Example 9 with JadxException

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;
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) ResContainer(jadx.core.xmlgen.ResContainer) ZipFile(java.util.zip.ZipFile) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) ZipEntry(java.util.zip.ZipEntry) IOException(java.io.IOException) ZipRef(jadx.api.ResourceFile.ZipRef) JadxException(jadx.core.utils.exceptions.JadxException) IOException(java.io.IOException)

Example 10 with JadxException

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;
}
Also used : JadxException(jadx.core.utils.exceptions.JadxException) File(java.io.File)

Aggregations

JadxException (jadx.core.utils.exceptions.JadxException)10 File (java.io.File)3 IOException (java.io.IOException)3 InputStream (java.io.InputStream)3 ResContainer (jadx.core.xmlgen.ResContainer)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 Dex (com.android.dex.Dex)1 JadxDecompiler (jadx.api.JadxDecompiler)1 ResourceFile (jadx.api.ResourceFile)1 ZipRef (jadx.api.ResourceFile.ZipRef)1 ResourcesLoader (jadx.api.ResourcesLoader)1 ClassNode (jadx.core.dex.nodes.ClassNode)1 RootNode (jadx.core.dex.nodes.RootNode)1 DecodeException (jadx.core.utils.exceptions.DecodeException)1 InputFile (jadx.core.utils.files.InputFile)1 ResTableParser (jadx.core.xmlgen.ResTableParser)1 ResourceStorage (jadx.core.xmlgen.ResourceStorage)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1