mirror of
https://github.com/revanced/smali.git
synced 2025-05-09 19:04:32 +02:00
Re-enable deodexing in baksmali
It's not quite working yet.
This commit is contained in:
parent
fd258ad543
commit
a55990c876
@ -29,6 +29,7 @@
|
|||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
import org.jf.baksmali.Adaptors.MethodDefinition;
|
import org.jf.baksmali.Adaptors.MethodDefinition;
|
||||||
|
import org.jf.dexlib2.analysis.UnresolvedOdexInstruction;
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||||
import org.jf.dexlib2.iface.instruction.OffsetInstruction;
|
import org.jf.dexlib2.iface.instruction.OffsetInstruction;
|
||||||
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
import org.jf.dexlib2.iface.instruction.formats.ArrayPayload;
|
||||||
@ -47,6 +48,11 @@ public class InstructionMethodItemFactory {
|
|||||||
(OffsetInstruction)instruction);
|
(OffsetInstruction)instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (instruction instanceof UnresolvedOdexInstruction) {
|
||||||
|
return new UnresolvedOdexInstructionMethodItem(methodDef, codeAddress,
|
||||||
|
(UnresolvedOdexInstruction)instruction);
|
||||||
|
}
|
||||||
|
|
||||||
switch (instruction.getOpcode().format) {
|
switch (instruction.getOpcode().format) {
|
||||||
case ArrayPayload:
|
case ArrayPayload:
|
||||||
return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
|
return new ArrayDataMethodItem(methodDef, codeAddress, (ArrayPayload)instruction);
|
||||||
@ -54,10 +60,6 @@ public class InstructionMethodItemFactory {
|
|||||||
return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
|
return new PackedSwitchMethodItem(methodDef, codeAddress, (PackedSwitchPayload)instruction);
|
||||||
case SparseSwitchPayload:
|
case SparseSwitchPayload:
|
||||||
return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
|
return new SparseSwitchMethodItem(methodDef, codeAddress, (SparseSwitchPayload)instruction);
|
||||||
//TODO: uncomment
|
|
||||||
/*case UnresolvedOdexInstruction:
|
|
||||||
return new UnresolvedOdexInstructionMethodItem(codeItem, codeAddress,
|
|
||||||
(UnresolvedOdexInstruction)instruction);*/
|
|
||||||
default:
|
default:
|
||||||
return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
|
return new InstructionMethodItem<Instruction>(methodDef, codeAddress, instruction);
|
||||||
}
|
}
|
||||||
|
@ -28,10 +28,17 @@
|
|||||||
|
|
||||||
package org.jf.baksmali.Adaptors.Format;
|
package org.jf.baksmali.Adaptors.Format;
|
||||||
|
|
||||||
//TODO: uncomment
|
import org.jf.baksmali.Adaptors.MethodDefinition;
|
||||||
/*public class UnresolvedOdexInstructionMethodItem extends InstructionMethodItem<UnresolvedOdexInstruction> {
|
import org.jf.dexlib2.analysis.UnresolvedOdexInstruction;
|
||||||
public UnresolvedOdexInstructionMethodItem(CodeItem codeItem, int codeAddress, UnresolvedOdexInstruction instruction) {
|
import org.jf.util.IndentingWriter;
|
||||||
super(codeItem, codeAddress, instruction);
|
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class UnresolvedOdexInstructionMethodItem extends InstructionMethodItem<UnresolvedOdexInstruction> {
|
||||||
|
public UnresolvedOdexInstructionMethodItem(@Nonnull MethodDefinition methodDef, int codeAddress,
|
||||||
|
@Nonnull UnresolvedOdexInstruction instruction) {
|
||||||
|
super(methodDef, codeAddress, instruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean writeTo(IndentingWriter writer) throws IOException {
|
public boolean writeTo(IndentingWriter writer) throws IOException {
|
||||||
@ -42,6 +49,6 @@ package org.jf.baksmali.Adaptors.Format;
|
|||||||
private void writeThrowTo(IndentingWriter writer) throws IOException {
|
private void writeThrowTo(IndentingWriter writer) throws IOException {
|
||||||
writer.write("#Replaced unresolvable odex instruction with a throw\n");
|
writer.write("#Replaced unresolvable odex instruction with a throw\n");
|
||||||
writer.write("throw ");
|
writer.write("throw ");
|
||||||
writeRegister(writer, instruction.ObjectRegisterNum);
|
writeRegister(writer, instruction.objectRegisterNum);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}*/
|
|
||||||
|
@ -359,9 +359,11 @@ public class MethodDefinition {
|
|||||||
|
|
||||||
AnalysisException analysisException = methodAnalyzer.getAnalysisException();
|
AnalysisException analysisException = methodAnalyzer.getAnalysisException();
|
||||||
if (analysisException != null) {
|
if (analysisException != null) {
|
||||||
|
// TODO: need to keep track of whether any errors occurred, so we can exit with a non-zero result
|
||||||
methodItems.add(new CommentMethodItem(
|
methodItems.add(new CommentMethodItem(
|
||||||
String.format("AnalysisException: %s", analysisException.getMessage()),
|
String.format("AnalysisException: %s", analysisException.getMessage()),
|
||||||
analysisException.codeAddress, Integer.MIN_VALUE));
|
analysisException.codeAddress, Integer.MIN_VALUE));
|
||||||
|
analysisException.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
|
|
||||||
List<AnalyzedInstruction> instructions = methodAnalyzer.getAnalyzedInstructions();
|
List<AnalyzedInstruction> instructions = methodAnalyzer.getAnalyzedInstructions();
|
||||||
|
@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableList;
|
|||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
import org.jf.baksmali.Adaptors.ClassDefinition;
|
import org.jf.baksmali.Adaptors.ClassDefinition;
|
||||||
import org.jf.dexlib2.analysis.ClassPath;
|
import org.jf.dexlib2.analysis.ClassPath;
|
||||||
|
import org.jf.dexlib2.dexbacked.DexBackedOdexFile;
|
||||||
import org.jf.dexlib2.iface.ClassDef;
|
import org.jf.dexlib2.iface.ClassDef;
|
||||||
import org.jf.dexlib2.iface.DexFile;
|
import org.jf.dexlib2.iface.DexFile;
|
||||||
import org.jf.dexlib2.util.SyntheticAccessorResolver;
|
import org.jf.dexlib2.util.SyntheticAccessorResolver;
|
||||||
@ -77,6 +78,10 @@ public class baksmali {
|
|||||||
Iterable<String> bootClassPaths = null;
|
Iterable<String> bootClassPaths = null;
|
||||||
if (bootClassPath != null) {
|
if (bootClassPath != null) {
|
||||||
bootClassPaths = Splitter.on(':').split(bootClassPath);
|
bootClassPaths = Splitter.on(':').split(bootClassPath);
|
||||||
|
} else if (dexFile instanceof DexBackedOdexFile) {
|
||||||
|
bootClassPaths = ((DexBackedOdexFile)dexFile).getDependencies();
|
||||||
|
}else {
|
||||||
|
bootClassPaths = ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
options.classPath = ClassPath.fromClassPath(Arrays.asList(classPathDirs),
|
options.classPath = ClassPath.fromClassPath(Arrays.asList(classPathDirs),
|
||||||
|
@ -248,26 +248,19 @@ public class main {
|
|||||||
//TODO: add "fix registers" functionality?
|
//TODO: add "fix registers" functionality?
|
||||||
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile);
|
DexBackedDexFile dexFile = DexFileFactory.loadDexFile(dexFileFile);
|
||||||
|
|
||||||
//TODO: uncomment
|
if (dexFile.isOdexFile()) {
|
||||||
/*if (dexFile.isOdex()) {
|
|
||||||
if (doDump) {
|
|
||||||
System.err.println("-D cannot be used with on odex file. Ignoring -D");
|
|
||||||
}
|
|
||||||
if (write) {
|
|
||||||
System.err.println("-W cannot be used with an odex file. Ignoring -W");
|
|
||||||
}
|
|
||||||
if (!deodex) {
|
if (!deodex) {
|
||||||
System.err.println("Warning: You are disassembling an odex file without deodexing it. You");
|
System.err.println("Warning: You are disassembling an odex file without deodexing it. You");
|
||||||
System.err.println("won't be able to re-assemble the results unless you deodex it with the -x");
|
System.err.println("won't be able to re-assemble the results unless you deodex it with the -x");
|
||||||
System.err.println("option");
|
System.err.println("option");
|
||||||
}
|
}
|
||||||
} else {*/
|
} else {
|
||||||
deodex = false;
|
deodex = false;
|
||||||
|
|
||||||
if (bootClassPath == null) {
|
if (bootClassPath == null) {
|
||||||
bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
bootClassPath = "core.jar:ext.jar:framework.jar:android.policy.jar:services.jar";
|
||||||
}
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
if (disassemble) {
|
if (disassemble) {
|
||||||
String[] bootClassPathDirsArray = new String[bootClassPathDirs.size()];
|
String[] bootClassPathDirsArray = new String[bootClassPathDirs.size()];
|
||||||
@ -281,12 +274,8 @@ public class main {
|
|||||||
noAccessorComments, registerInfo, ignoreErrors, inlineTable, checkPackagePrivateAccess);
|
noAccessorComments, registerInfo, ignoreErrors, inlineTable, checkPackagePrivateAccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement rewrite + optional sort functionality
|
|
||||||
|
|
||||||
// TODO: need to check if odex file
|
|
||||||
if (doDump) {
|
if (doDump) {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
dump.dump(dexFile, dumpFileName);
|
dump.dump(dexFile, dumpFileName);
|
||||||
}catch (IOException ex) {
|
}catch (IOException ex) {
|
||||||
System.err.println("Error occured while writing dump file");
|
System.err.println("Error occured while writing dump file");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user