/*
* Copyright 2013, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * 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.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "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 COPYRIGHT
* OWNER OR CONTRIBUTORS 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.dexlib2.analysis;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import org.jf.dexlib2.AccessFlags;
import org.jf.dexlib2.Opcode;
import org.jf.dexlib2.iface.*;
import org.jf.dexlib2.iface.instruction.*;
import org.jf.dexlib2.iface.instruction.formats.*;
import org.jf.dexlib2.iface.reference.FieldReference;
import org.jf.dexlib2.iface.reference.MethodReference;
import org.jf.dexlib2.iface.reference.Reference;
import org.jf.dexlib2.iface.reference.TypeReference;
import org.jf.dexlib2.immutable.instruction.*;
import org.jf.dexlib2.immutable.reference.ImmutableFieldReference;
import org.jf.dexlib2.immutable.reference.ImmutableMethodReference;
import org.jf.dexlib2.util.MethodUtil;
import org.jf.dexlib2.util.ReferenceUtil;
import org.jf.dexlib2.util.TypeUtils;
import org.jf.util.BitSetUtils;
import org.jf.util.ExceptionWithContext;
import org.jf.util.SparseArray;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.BitSet;
import java.util.List;
/**
* The MethodAnalyzer performs several functions. It "analyzes" the instructions and infers the register types
* for each register, it can deodex odexed instructions, and it can verify the bytecode. The analysis and verification
* are done in two separate passes, because the analysis has to process instructions multiple times in some cases, and
* there's no need to perform the verification multiple times, so we wait until the method is fully analyzed and then
* verify it.
*
* Before calling the analyze() method, you must have initialized the ClassPath by calling
* ClassPath.InitializeClassPath
*/
public class MethodAnalyzer {
@Nonnull private final Method method;
@Nonnull private final MethodImplementation methodImpl;
private final int paramRegisterCount;
@Nonnull private final ClassPath classPath;
@Nullable private final InlineMethodResolver inlineResolver;
// This contains all the AnalyzedInstruction instances, keyed by the code unit address of the instruction
@Nonnull private final SparseArray<AnalyzedInstruction> analyzedInstructions =
new SparseArray<AnalyzedInstruction>(0);
// Which instructions have been analyzed, keyed by instruction index
@Nonnull private final BitSet analyzedState;
@Nullable private AnalysisException analysisException = null;
//This is a dummy instruction that occurs immediately before the first real instruction. We can initialize the
//register types for this instruction to the parameter types, in order to have them propagate to all of its
//successors, e.g. the first real instruction, the first instructions in any exception handlers covering the first
//instruction, etc.
private final AnalyzedInstruction startOfMethod;
public MethodAnalyzer(@Nonnull ClassPath classPath, @Nonnull Method method,
@Nullable InlineMethodResolver inlineResolver) {
this.classPath = classPath;
this.inlineResolver = inlineResolver;
this.method = method;
MethodImplementation methodImpl = method.getImplementation();
if (methodImpl == null) {
throw new IllegalArgumentException("The method has no implementation");
}
this.methodImpl = methodImpl;
//override AnalyzedInstruction and provide custom implementations of some of the methods, so that we don't
//have to handle the case this special case of instruction being null, in the main class
startOfMethod = new AnalyzedInstruction(null, -1, methodImpl.getRegisterCount()) {
public boolean setsRegister() {
return false;
}
@Override
public boolean setsWideRegister() {
return false;
}
@Override
public boolean setsRegister(int registerNumber) {
return false;
}
@Override
public int getDestinationRegister() {
assert false;
return -1;
}
};
buildInstructionList();
analyzedState = new BitSet(analyzedInstructions.size());
paramRegisterCount = MethodUtil.getParameterRegisterCount(method);
analyze();
}
private void analyze() {
Method method = this.method;
MethodImplementation methodImpl = this.methodImpl;
int totalRegisters = methodImpl.getRegisterCount();
int parameterRegisters = paramRegisterCount;
int nonParameterRegisters = totalRegisters - parameterRegisters;
//if this isn't a static method, determine which register is the "this" register and set the type to the
//current class
if (!MethodUtil.isStatic(method)) {
int thisRegister = totalRegisters - parameterRegisters;
//if this is a constructor, then set the "this" register to an uninitialized reference of the current class
if (MethodUtil.isConstructor(method)) {
setPostRegisterTypeAndPropagateChanges(startOfMethod, thisRegister,
RegisterType.getRegisterType(RegisterType.UNINIT_THIS,
classPath.getClass(method.getDefiningClass())));
} else {
setPostRegisterTypeAndPropagateChanges(startOfMethod, thisRegister,
RegisterType.getRegisterType(RegisterType.REFERENCE,
classPath.getClass(method.getDefiningClass())));
}
propagateParameterTypes(totalRegisters-parameterRegisters+1);
} else {
propagateParameterTypes(totalRegisters-parameterRegisters);
}
RegisterType uninit = RegisterType.getRegisterType(RegisterType.UNINIT, null);
for (int i=0; i<nonParameterRegisters; i++) {
setPostRegisterTypeAndPropagateChanges(startOfMethod, i, uninit);
}
BitSet instructionsToAnalyze = new BitSet(analyzedInstructions.size());
//make sure all of the "first instructions" are marked for processing
for (AnalyzedInstruction successor: startOfMethod.successors) {
instructionsToAnalyze.set(successor.instructionIndex);
}
BitSet undeodexedInstructions = new BitSet(analyzedInstructions.size());
do {
boolean d
没有合适的资源?快使用搜索试试~ 我知道了~
smali2java And apktool
共896个文件
java:710个
smali:46个
xml:39个
需积分: 12 8 下载量 64 浏览量
2018-01-23
16:43:39
上传
评论
收藏 29.83MB ZIP 举报
温馨提示
smali2java And apktool smali2java And apktool smali2java And apktool
资源推荐
资源详情
资源评论
收起资源包目录
smali2java And apktool (896个子文件)
aapt 1.66MB
aapt 1.21MB
library.apk 13KB
client.apk 9KB
apktool 2KB
apktool 2KB
gradlew.bat 2KB
apktool.bat 111B
apktool.bat 109B
bug603 62B
CHANGES 9KB
classes.dex 1KB
classes.dex 832B
classes.dex 568B
classes.dex 552B
classes.dex 520B
classes.dex 508B
aapt.exe 5.19MB
aapt.exe 1.38MB
Smali2JavaUI.exe 378KB
hidden.file 21B
smaliLexer.flex 21KB
smaliTreeWalker.g 45KB
smaliParser.g 38KB
expectedTokensTestGrammar.g 5KB
.gitattributes 65B
.gitignore 176B
.gitignore 94B
build.gradle 6KB
build.gradle 4KB
build.gradle 4KB
build.gradle 3KB
build.gradle 3KB
build.gradle 2KB
build.gradle 2KB
build.gradle 2KB
build.gradle 2KB
functions.gradle 1KB
build.gradle 754B
build.gradle 749B
build.gradle 686B
settings.gradle 348B
gradlew 5KB
apktool.jar 5.95MB
apktool.jar 4.97MB
android-framework.jar 2.62MB
android-support-v13.jar 393KB
gradle-wrapper.jar 46KB
MethodAnalyzer.java 80KB
DexWriter.java 54KB
MutableMethodImplementation.java 41KB
Opcode.java 41KB
MXSerializer.java 34KB
AXmlResourceParser.java 31KB
AndrolibResources.java 31KB
ClassProto.java 28KB
Androlib.java 27KB
BaseDexReaderTest.java 27KB
DexDataWriterTest.java 24KB
MethodDefinition.java 24KB
TryListBuilderTest.java 24KB
main.java 24KB
ClassPool.java 23KB
CodeItem.java 22KB
Main.java 21KB
InstructionMethodItem.java 20KB
ResConfigFlags.java 19KB
ClassFileNameHandler.java 18KB
BaseDexReaderSleb128Test.java 18KB
BaseDexReader.java 18KB
BuilderClassPool.java 18KB
DexBackedClassDef.java 18KB
SyntheticAccessorFSM.java 17KB
RegisterType.java 17KB
BaseDexReaderLeb128Test.java 17KB
ARSCDecoder.java 17KB
InstructionWriter.java 16KB
RadixTreeImpl.java 16KB
DexWriterSleb128Test.java 16KB
DexWriterUleb128Test.java 15KB
TryListBuilder.java 15KB
ImplicitReferenceTest.java 15KB
ApkDecoder.java 14KB
LiteralTools.java 14KB
main.java 14KB
ClassDefinition.java 14KB
DebugInfo.java 13KB
AnnotatedBytes.java 13KB
AnalyzedInstruction.java 13KB
CommonSuperclassTest.java 12KB
DexBuilder.java 12KB
ImplicitReferenceTest.java 11KB
BuildAndDecodeTest.java 11KB
TypedValue.java 11KB
PayloadAlignmentTest.java 11KB
PreInstructionRegisterInfoMethodItem.java 11KB
ReflectionClassDef.java 11KB
StringBlock.java 11KB
ImmutableInstructionFactory.java 11KB
Utf8Utils.java 11KB
共 896 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
沉默GAVIN
- 粉丝: 6
- 资源: 125
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功