mirror of
https://github.com/revanced/smali.git
synced 2025-05-06 17:34:34 +02:00
- removed the ability to dump to stdout (issues with the CLI recognizing '-' as a value instead of an option)
- tweaked the version and usage info git-svn-id: https://smali.googlecode.com/svn/trunk@218 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
60188336df
commit
c894b9658c
@ -38,11 +38,6 @@ public class dump {
|
|||||||
public static void dump(DexFile dexFile, String dumpFileName, String outputDexFileName, boolean sort)
|
public static void dump(DexFile dexFile, String dumpFileName, String outputDexFileName, boolean sort)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
|
||||||
boolean dumpToStdOut = false;
|
|
||||||
if (dumpFileName != null && dumpFileName.equals("-")) {
|
|
||||||
dumpToStdOut = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sort) {
|
if (sort) {
|
||||||
//sort all items, to guarantee a unique ordering
|
//sort all items, to guarantee a unique ordering
|
||||||
dexFile.setSortAllItems(true);
|
dexFile.setSortAllItems(true);
|
||||||
@ -65,23 +60,20 @@ public class dump {
|
|||||||
out.finishAnnotating();
|
out.finishAnnotating();
|
||||||
FileWriter writer = null;
|
FileWriter writer = null;
|
||||||
|
|
||||||
if (dumpToStdOut) {
|
|
||||||
out.writeAnnotationsTo(new OutputStreamWriter(System.out));
|
try {
|
||||||
} else {
|
writer = new FileWriter(dumpFileName);
|
||||||
try {
|
out.writeAnnotationsTo(writer);
|
||||||
writer = new FileWriter(dumpFileName);
|
} catch (IOException ex) {
|
||||||
out.writeAnnotationsTo(writer);
|
System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName);
|
||||||
} catch (IOException ex) {
|
ex.printStackTrace();
|
||||||
System.err.println("\n\nThere was an error while dumping the dex file to " + dumpFileName);
|
} finally {
|
||||||
ex.printStackTrace();
|
if (writer != null) {
|
||||||
} finally {
|
try {
|
||||||
if (writer != null) {
|
writer.close();
|
||||||
try {
|
} catch (IOException ex) {
|
||||||
writer.close();
|
System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName);
|
||||||
} catch (IOException ex) {
|
ex.printStackTrace();
|
||||||
System.err.println("\n\nThere was an error while closing the dump file " + dumpFileName);
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,9 +30,10 @@ public class main {
|
|||||||
|
|
||||||
public static final String VERSION = "0.91";
|
public static final String VERSION = "0.91";
|
||||||
|
|
||||||
private static Options options;
|
private static final Options options;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
options = new Options();
|
||||||
buildOptions();
|
buildOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,16 +162,13 @@ public class main {
|
|||||||
* Prints the version message.
|
* Prints the version message.
|
||||||
*/
|
*/
|
||||||
private static void version() {
|
private static void version() {
|
||||||
System.out.println("baksmali " + VERSION);
|
System.out.println("baksmali " + VERSION + " (http://smali.googlecode.com)");
|
||||||
System.out.println("Copyright (C) 2009 Ben Gruver");
|
System.out.println("Copyright (C) 2009 Ben Gruver");
|
||||||
System.out.println("License: \"new\" BSD license");
|
System.out.println("BSD license (http://www.opensource.org/licenses/bsd-license.php)");
|
||||||
System.out.println("http://smali.googlecode.com");
|
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void buildOptions() {
|
private static void buildOptions() {
|
||||||
options = new Options();
|
|
||||||
|
|
||||||
Option versionOption = OptionBuilder.withLongOpt("version")
|
Option versionOption = OptionBuilder.withLongOpt("version")
|
||||||
.withDescription("prints the version then exits")
|
.withDescription("prints the version then exits")
|
||||||
.create("v");
|
.create("v");
|
||||||
@ -182,13 +180,13 @@ public class main {
|
|||||||
Option dumpOption = OptionBuilder.withLongOpt("dump-to")
|
Option dumpOption = OptionBuilder.withLongOpt("dump-to")
|
||||||
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), along with the normal disassembly.")
|
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), along with the normal disassembly.")
|
||||||
.hasOptionalArg()
|
.hasOptionalArg()
|
||||||
.withArgName("FILE|-")
|
.withArgName("FILE")
|
||||||
.create("d");
|
.create("d");
|
||||||
|
|
||||||
Option dumpOnlyOption = OptionBuilder.withLongOpt("dump-only")
|
Option dumpOnlyOption = OptionBuilder.withLongOpt("dump-only")
|
||||||
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), and does not generate the disassembly")
|
.withDescription("dumps the given dex file into a single annotated dump file named FILE (<dexfile>.dump by default), and does not generate the disassembly")
|
||||||
.hasOptionalArg()
|
.hasOptionalArg()
|
||||||
.withArgName("FILE|-")
|
.withArgName("FILE")
|
||||||
.create("D");
|
.create("D");
|
||||||
|
|
||||||
Option writeDexOption = OptionBuilder.withLongOpt("write-dex")
|
Option writeDexOption = OptionBuilder.withLongOpt("write-dex")
|
||||||
@ -204,7 +202,7 @@ public class main {
|
|||||||
.create("o");
|
.create("o");
|
||||||
|
|
||||||
Option sortOption = OptionBuilder.withLongOpt("sort")
|
Option sortOption = OptionBuilder.withLongOpt("sort")
|
||||||
.withDescription("when dumping or rewriting, sort the items in the dex file before dumping/writing.")
|
.withDescription("sort the items in the dex file into a canonical order before dumping/writing")
|
||||||
.create("s");
|
.create("s");
|
||||||
|
|
||||||
Option fixSignedRegisterOption = OptionBuilder.withLongOpt("fix-signed-registers")
|
Option fixSignedRegisterOption = OptionBuilder.withLongOpt("fix-signed-registers")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user