mirror of
https://github.com/revanced/smali.git
synced 2025-05-29 04:10:13 +02:00
add -V option for baksmali to verify the bytecode
git-svn-id: https://smali.googlecode.com/svn/trunk@664 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
7025dfb753
commit
7bb8ace93b
@ -248,7 +248,7 @@ public class MethodDefinition {
|
|||||||
return methodItems;
|
return methodItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (baksmali.registerInfo != 0 || baksmali.deodex) {
|
if (baksmali.registerInfo != 0 || baksmali.deodex || baksmali.verify) {
|
||||||
methodAnalyzer.analyze();
|
methodAnalyzer.analyze();
|
||||||
|
|
||||||
ValidationException validationException = methodAnalyzer.getValidationException();
|
ValidationException validationException = methodAnalyzer.getValidationException();
|
||||||
@ -256,6 +256,15 @@ public class MethodDefinition {
|
|||||||
methodItems.add(new CommentMethodItem(stg,
|
methodItems.add(new CommentMethodItem(stg,
|
||||||
String.format("ValidationException: %s" ,validationException.getMessage()),
|
String.format("ValidationException: %s" ,validationException.getMessage()),
|
||||||
validationException.getCodeAddress(), Integer.MIN_VALUE));
|
validationException.getCodeAddress(), Integer.MIN_VALUE));
|
||||||
|
} else if (baksmali.verify) {
|
||||||
|
methodAnalyzer.verify();
|
||||||
|
|
||||||
|
validationException = methodAnalyzer.getValidationException();
|
||||||
|
if (validationException != null) {
|
||||||
|
methodItems.add(new CommentMethodItem(stg,
|
||||||
|
String.format("ValidationException: %s" ,validationException.getMessage()),
|
||||||
|
validationException.getCodeAddress(), Integer.MIN_VALUE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<AnalyzedInstruction> instructions = methodAnalyzer.getInstructions();
|
List<AnalyzedInstruction> instructions = methodAnalyzer.getInstructions();
|
||||||
|
@ -46,13 +46,15 @@ public class baksmali {
|
|||||||
public static boolean outputDebugInfo = true;
|
public static boolean outputDebugInfo = true;
|
||||||
public static boolean addCodeOffsets = false;
|
public static boolean addCodeOffsets = false;
|
||||||
public static boolean deodex = false;
|
public static boolean deodex = false;
|
||||||
|
public static boolean verify = false;
|
||||||
public static int registerInfo = 0;
|
public static int registerInfo = 0;
|
||||||
public static String bootClassPath;
|
public static String bootClassPath;
|
||||||
|
|
||||||
public static void disassembleDexFile(DexFile dexFile, boolean deodex, String outputDirectory,
|
public static void disassembleDexFile(DexFile dexFile, boolean deodex, String outputDirectory,
|
||||||
String[] classPathDirs, String bootClassPath, boolean noParameterRegisters,
|
String[] classPathDirs, String bootClassPath, boolean noParameterRegisters,
|
||||||
boolean useLocalsDirective, boolean useSequentialLabels,
|
boolean useLocalsDirective, boolean useSequentialLabels,
|
||||||
boolean outputDebugInfo, boolean addCodeOffsets, int registerInfo)
|
boolean outputDebugInfo, boolean addCodeOffsets, int registerInfo,
|
||||||
|
boolean verify)
|
||||||
{
|
{
|
||||||
baksmali.noParameterRegisters = noParameterRegisters;
|
baksmali.noParameterRegisters = noParameterRegisters;
|
||||||
baksmali.useLocalsDirective = useLocalsDirective;
|
baksmali.useLocalsDirective = useLocalsDirective;
|
||||||
@ -62,8 +64,9 @@ public class baksmali {
|
|||||||
baksmali.deodex = deodex;
|
baksmali.deodex = deodex;
|
||||||
baksmali.registerInfo = registerInfo;
|
baksmali.registerInfo = registerInfo;
|
||||||
baksmali.bootClassPath = bootClassPath;
|
baksmali.bootClassPath = bootClassPath;
|
||||||
|
baksmali.verify = verify;
|
||||||
|
|
||||||
if (registerInfo != 0 || deodex) {
|
if (registerInfo != 0 || deodex || verify) {
|
||||||
try {
|
try {
|
||||||
ClassPath.InitializeClassPath(classPathDirs, bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
ClassPath.InitializeClassPath(classPathDirs, bootClassPath==null?null:bootClassPath.split(":"), dexFile);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -102,6 +102,7 @@ public class main {
|
|||||||
boolean outputDebugInfo = true;
|
boolean outputDebugInfo = true;
|
||||||
boolean addCodeOffsets = false;
|
boolean addCodeOffsets = false;
|
||||||
boolean deodex = false;
|
boolean deodex = false;
|
||||||
|
boolean verify = false;
|
||||||
|
|
||||||
int registerInfo = 0;
|
int registerInfo = 0;
|
||||||
|
|
||||||
@ -216,6 +217,9 @@ public class main {
|
|||||||
case 'F':
|
case 'F':
|
||||||
fixRegisters = true;
|
fixRegisters = true;
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
verify = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
assert false;
|
assert false;
|
||||||
}
|
}
|
||||||
@ -262,7 +266,7 @@ public class main {
|
|||||||
|
|
||||||
baksmali.disassembleDexFile(dexFile, deodex, outputDirectory, bootClassPathDirsArray, bootClassPath,
|
baksmali.disassembleDexFile(dexFile, deodex, outputDirectory, bootClassPathDirsArray, bootClassPath,
|
||||||
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, addCodeOffsets,
|
noParameterRegisters, useLocalsDirective, useSequentialLabels, outputDebugInfo, addCodeOffsets,
|
||||||
registerInfo);
|
registerInfo, verify);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((doDump || write) && !dexFile.isOdex()) {
|
if ((doDump || write) && !dexFile.isOdex()) {
|
||||||
@ -417,6 +421,10 @@ public class main {
|
|||||||
.withDescription("add comments to the disassembly containing the code offset for each address")
|
.withDescription("add comments to the disassembly containing the code offset for each address")
|
||||||
.create("f");
|
.create("f");
|
||||||
|
|
||||||
|
Option verifyDexOption = OptionBuilder.withLongOpt("verify")
|
||||||
|
.withDescription("perform bytecode verification")
|
||||||
|
.create("V");
|
||||||
|
|
||||||
basicOptions.addOption(versionOption);
|
basicOptions.addOption(versionOption);
|
||||||
basicOptions.addOption(helpOption);
|
basicOptions.addOption(helpOption);
|
||||||
basicOptions.addOption(outputDirOption);
|
basicOptions.addOption(outputDirOption);
|
||||||
@ -435,6 +443,7 @@ public class main {
|
|||||||
debugOptions.addOption(writeDexOption);
|
debugOptions.addOption(writeDexOption);
|
||||||
debugOptions.addOption(sortOption);
|
debugOptions.addOption(sortOption);
|
||||||
debugOptions.addOption(fixSignedRegisterOption);
|
debugOptions.addOption(fixSignedRegisterOption);
|
||||||
|
debugOptions.addOption(verifyDexOption);
|
||||||
|
|
||||||
|
|
||||||
for (Object option: basicOptions.getOptions()) {
|
for (Object option: basicOptions.getOptions()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user