use of jadx.core.utils.exceptions.DecodeException in project jadx by skylot.
the class ReSugarCode method getEnumMap.
private static EnumMapAttr.KeyValueMap getEnumMap(MethodNode mth, FieldNode field) {
ClassNode syntheticClass = field.getParentClass();
EnumMapAttr mapAttr = syntheticClass.get(AType.ENUM_MAP);
if (mapAttr != null) {
return mapAttr.getMap(field);
}
mapAttr = new EnumMapAttr();
syntheticClass.addAttr(mapAttr);
MethodNode clsInitMth = syntheticClass.searchMethodByName("<clinit>()V");
if (clsInitMth == null || clsInitMth.isNoCode()) {
return null;
}
if (clsInitMth.getBasicBlocks() == null) {
try {
clsInitMth.load();
} catch (DecodeException e) {
LOG.error("Load failed", e);
return null;
}
if (clsInitMth.getBasicBlocks() == null) {
// TODO:
return null;
}
}
for (BlockNode block : clsInitMth.getBasicBlocks()) {
for (InsnNode insn : block.getInstructions()) {
if (insn.getType() == InsnType.APUT) {
addToEnumMap(mth, mapAttr, insn);
}
}
}
return mapAttr.getMap(field);
}
use of jadx.core.utils.exceptions.DecodeException in project jadx by skylot.
the class MethodNode method load.
@Override
public void load() throws DecodeException {
try {
if (noCode) {
regsCount = 0;
codeSize = 0;
initMethodTypes();
return;
}
DexNode dex = parentClass.dex();
Code mthCode = dex.readCode(methodData);
regsCount = mthCode.getRegistersSize();
initMethodTypes();
InsnDecoder decoder = new InsnDecoder(this);
decoder.decodeInsns(mthCode);
instructions = decoder.process();
codeSize = instructions.length;
initTryCatches(mthCode);
initJumps();
this.debugInfoOffset = mthCode.getDebugInfoOffset();
} catch (Exception e) {
if (!noCode) {
noCode = true;
// load without code
load();
noCode = false;
}
throw new DecodeException(this, "Load method exception", e);
}
}
use of jadx.core.utils.exceptions.DecodeException in project jadx by skylot.
the class RootNode method load.
public void load(List<InputFile> inputFiles) throws DecodeException {
dexNodes = new ArrayList<DexNode>();
for (InputFile input : inputFiles) {
for (DexFile dexFile : input.getDexFiles()) {
try {
LOG.debug("Load: {}", dexFile);
DexNode dexNode = new DexNode(this, dexFile);
dexNodes.add(dexNode);
} catch (Exception e) {
throw new DecodeException("Error decode file: " + dexFile, e);
}
}
}
for (DexNode dexNode : dexNodes) {
dexNode.loadClasses();
}
initInnerClasses();
}
use of jadx.core.utils.exceptions.DecodeException in project jadx by skylot.
the class RootNode method initClassPath.
public void initClassPath() throws DecodeException {
try {
if (this.clsp == null) {
ClspGraph clsp = new ClspGraph();
clsp.load();
List<ClassNode> classes = new ArrayList<ClassNode>();
for (DexNode dexNode : dexNodes) {
classes.addAll(dexNode.getClasses());
}
clsp.addApp(classes);
this.clsp = clsp;
}
} catch (IOException e) {
throw new DecodeException("Error loading classpath", e);
}
}
use of jadx.core.utils.exceptions.DecodeException in project jadx by skylot.
the class AnnotationsParser method readAnnotation.
public static Annotation readAnnotation(DexNode dex, Section s, boolean readVisibility) throws DecodeException {
EncValueParser parser = new EncValueParser(dex, s);
Visibility visibility = null;
if (readVisibility) {
byte v = s.readByte();
visibility = VISIBILITIES[v];
}
int typeIndex = s.readUleb128();
int size = s.readUleb128();
Map<String, Object> values = new LinkedHashMap<String, Object>(size);
for (int i = 0; i < size; i++) {
String name = dex.getString(s.readUleb128());
values.put(name, parser.parseValue());
}
ArgType type = dex.getType(typeIndex);
Annotation annotation = new Annotation(visibility, type, values);
if (!type.isObject()) {
throw new DecodeException("Incorrect type for annotation: " + annotation);
}
return annotation;
}
Aggregations