use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class ReSugarCode method checkEnumMapAccess.
public static EnumMapInfo checkEnumMapAccess(MethodNode mth, InsnNode checkInsn) {
InsnArg sgetArg = checkInsn.getArg(0);
InsnArg invArg = checkInsn.getArg(1);
if (!sgetArg.isInsnWrap() || !invArg.isInsnWrap()) {
return null;
}
InsnNode invInsn = ((InsnWrapArg) invArg).getWrapInsn();
InsnNode sgetInsn = ((InsnWrapArg) sgetArg).getWrapInsn();
if (invInsn.getType() != InsnType.INVOKE || sgetInsn.getType() != InsnType.SGET) {
return null;
}
InvokeNode inv = (InvokeNode) invInsn;
if (!inv.getCallMth().getShortId().equals("ordinal()I")) {
return null;
}
ClassNode enumCls = mth.dex().resolveClass(inv.getCallMth().getDeclClass());
if (enumCls == null || !enumCls.isEnum()) {
return null;
}
Object index = ((IndexInsnNode) sgetInsn).getIndex();
if (!(index instanceof FieldInfo)) {
return null;
}
FieldNode enumMapField = mth.dex().resolveField((FieldInfo) index);
if (enumMapField == null || !enumMapField.getAccessFlags().isSynthetic()) {
return null;
}
return new EnumMapInfo(inv.getArg(0), enumMapField);
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class ReSugarCode method addToEnumMap.
private static void addToEnumMap(MethodNode mth, EnumMapAttr mapAttr, InsnNode aputInsn) {
InsnArg litArg = aputInsn.getArg(2);
if (!litArg.isLiteral()) {
return;
}
EnumMapInfo mapInfo = checkEnumMapAccess(mth, aputInsn);
if (mapInfo == null) {
return;
}
InsnArg enumArg = mapInfo.getArg();
FieldNode field = mapInfo.getMapField();
if (field == null || !enumArg.isInsnWrap()) {
return;
}
InsnNode sget = ((InsnWrapArg) enumArg).getWrapInsn();
if (!(sget instanceof IndexInsnNode)) {
return;
}
Object index = ((IndexInsnNode) sget).getIndex();
if (!(index instanceof FieldInfo)) {
return;
}
FieldNode fieldNode = mth.dex().resolveField((FieldInfo) index);
if (fieldNode == null) {
return;
}
int literal = (int) ((LiteralArg) litArg).getLiteral();
mapAttr.add(field, literal, fieldNode);
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class Deobfuscator method processClass.
private void processClass(DexNode dex, ClassNode cls) {
ClassInfo clsInfo = cls.getClassInfo();
String fullName = getClassFullName(clsInfo);
if (!fullName.equals(clsInfo.getFullName())) {
clsInfo.rename(dex, fullName);
}
for (FieldNode field : cls.getFields()) {
FieldInfo fieldInfo = field.getFieldInfo();
String alias = getFieldAlias(field);
if (alias != null) {
fieldInfo.setAlias(alias);
}
}
for (MethodNode mth : cls.getMethods()) {
MethodInfo methodInfo = mth.getMethodInfo();
String alias = getMethodAlias(mth);
if (alias != null) {
methodInfo.setAlias(alias);
}
if (mth.isVirtual()) {
resolveOverriding(dex, cls, mth);
}
}
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class ShadowFieldVisitor method init.
@Override
public void init(RootNode root) {
Map<String, FieldFixInfo> map = new HashMap<>();
for (ClassNode cls : root.getClasses(true)) {
Map<FieldInfo, FieldFixType> fieldFixMap = searchShadowedFields(cls);
if (!fieldFixMap.isEmpty()) {
FieldFixInfo fixInfo = new FieldFixInfo();
fixInfo.fieldFixMap = fieldFixMap;
map.put(cls.getRawName(), fixInfo);
}
}
this.fixInfoMap = map;
}
use of jadx.core.dex.info.FieldInfo in project jadx by skylot.
the class ShadowFieldVisitor method processInsn.
private static void processInsn(MethodNode mth, InsnNode insn, Map<String, FieldFixInfo> fixInfoMap) {
FieldInfo fieldInfo = getFieldInfo(insn);
if (fieldInfo == null) {
return;
}
InsnArg arg = insn.getArg(insn.getArgsCount() - 1);
ArgType type = arg.getType();
if (!type.isTypeKnown() || !type.isObject()) {
return;
}
FieldFixInfo fieldFixInfo = fixInfoMap.get(type.getObject());
if (fieldFixInfo == null) {
return;
}
FieldFixType fieldFixType = fieldFixInfo.fieldFixMap.get(fieldInfo);
if (fieldFixType == null) {
return;
}
fixFieldAccess(mth, fieldInfo, fieldFixType, arg);
}
Aggregations