mirror of
https://github.com/revanced/smali.git
synced 2025-05-13 20:57:07 +02:00
Added a --dump command
git-svn-id: https://smali.googlecode.com/svn/trunk@192 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
2065bf9602
commit
2b7d3ebb66
76
baksmali/src/main/java/org/jf/baksmali/dump.java
Normal file
76
baksmali/src/main/java/org/jf/baksmali/dump.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* [The "BSD licence"]
|
||||||
|
* Copyright (c) 2009 Ben Gruver
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
|
* documentation and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||||
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||||
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||||
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jf.baksmali;
|
||||||
|
|
||||||
|
import org.jf.dexlib.DexFile;
|
||||||
|
import org.jf.dexlib.util.ByteArrayAnnotatedOutput;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class dump {
|
||||||
|
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
|
||||||
|
if (args.length < 2) {
|
||||||
|
throw new UsageException();
|
||||||
|
}
|
||||||
|
|
||||||
|
String dexFileName = args[0];
|
||||||
|
String outFile = args[1];
|
||||||
|
|
||||||
|
File dexFileFile = new File(dexFileName);
|
||||||
|
if (!dexFileFile.exists()) {
|
||||||
|
System.out.println("Can't find the file " + dexFileFile.toString());
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DexFile dexFile = new DexFile(new File(dexFileName), true);
|
||||||
|
|
||||||
|
ByteArrayAnnotatedOutput out = new ByteArrayAnnotatedOutput();
|
||||||
|
out.enableAnnotations(120, true);
|
||||||
|
dexFile.writeTo(out);
|
||||||
|
|
||||||
|
out.finishAnnotating();
|
||||||
|
|
||||||
|
FileWriter writer = null;
|
||||||
|
try {
|
||||||
|
writer = new FileWriter(outFile);
|
||||||
|
out.writeAnnotationsTo(writer);
|
||||||
|
writer.close();
|
||||||
|
}catch (IOException ex) {
|
||||||
|
if (writer != null) {
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -22,7 +22,7 @@ package org.jf.baksmali;
|
|||||||
*/
|
*/
|
||||||
public class main {
|
public class main {
|
||||||
|
|
||||||
public static final String VERSION = "0.9";
|
public static final String VERSION = "0.91";
|
||||||
|
|
||||||
|
|
||||||
private static String USAGE_MESSAGE =
|
private static String USAGE_MESSAGE =
|
||||||
@ -30,6 +30,9 @@ public class main {
|
|||||||
" java -jar baksmali.jar --disassemble <.dex file> <output folder>\n" +
|
" java -jar baksmali.jar --disassemble <.dex file> <output folder>\n" +
|
||||||
" disassembles the given dex file into a set of .smali files\n" +
|
" disassembles the given dex file into a set of .smali files\n" +
|
||||||
" in the given folder\n" +
|
" in the given folder\n" +
|
||||||
|
" java -jar baksmali.jar --dump <.dex file> <dump file>\n" +
|
||||||
|
" dumps the given dex file to a single annotated dump file\n" +
|
||||||
|
" that follows the order and structure of the dex file.\n" +
|
||||||
" java -jar baksmali.jar --version\n" +
|
" java -jar baksmali.jar --version\n" +
|
||||||
" Print the version of this tool (" + VERSION +
|
" Print the version of this tool (" + VERSION +
|
||||||
").\n" +
|
").\n" +
|
||||||
@ -63,6 +66,9 @@ public class main {
|
|||||||
if (arg.equals("--disassemble")) {
|
if (arg.equals("--disassemble")) {
|
||||||
baksmali.main(without(args, i));
|
baksmali.main(without(args, i));
|
||||||
break;
|
break;
|
||||||
|
} else if (arg.equals("--dump")) {
|
||||||
|
dump.main(without(args, i));
|
||||||
|
break;
|
||||||
} else if (arg.equals("--version")) {
|
} else if (arg.equals("--version")) {
|
||||||
version();
|
version();
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user