Skip to content

Commit

Permalink
Finally fix handling of large arrays
Browse files Browse the repository at this point in the history
# Conflicts:
#	dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java
  • Loading branch information
ThexXTURBOXx authored and pxb1988 committed Aug 31, 2023
1 parent 6a798f7 commit f3fc040
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dex-translator/src/main/java/com/googlecode/d2j/dex/Dex2Asm.java
Original file line number Diff line number Diff line change
Expand Up @@ -524,11 +524,13 @@ public void convertClass(int dexVersion, DexClassNode classNode, ClassVisitorFac
cv.visitEnd();
}

private static final String HEX_CLASS_LOCATION = "res/Hex";

private static final Set<String> HEX_DECODE_METHODS =
new HashSet<>(Arrays.asList("decode_J", "decode_I", "decode_S", "decode_B"));

private void addHexDecodeMethod(ClassVisitor outCV, String className, String hexDecodeMethodNameBase) {
try (InputStream is = Dex2Asm.class.getResourceAsStream("/res/Hex.class")) {
try (InputStream is = Dex2Asm.class.getResourceAsStream("/" + HEX_CLASS_LOCATION + ".class")) {
ClassReader cr = new ClassReader(is);
cr.accept(new ClassVisitor(Opcodes.ASM9) {
@Override
Expand All @@ -537,14 +539,16 @@ public MethodVisitor visitMethod(int access, String name, String desc, String si
if (HEX_DECODE_METHODS.contains(name)) {
return new MethodVisitor(Opcodes.ASM9,
outCV.visitMethod(Opcodes.ACC_PRIVATE | Opcodes.ACC_STATIC,
hexDecodeMethodNameBase + "$" + name,
desc, signature, exceptions
)) {
hexDecodeMethodNameBase + "$" + name, desc, signature, exceptions)) {
@Override
public void visitMethodInsn(int opcode, String owner, String name, String descriptor,
boolean isInterface) {
super.visitMethodInsn(opcode, owner.equals("res/Hex") ? className : owner, name,
descriptor, isInterface);
if (owner.equals(HEX_CLASS_LOCATION)) {
super.visitMethodInsn(opcode, className, hexDecodeMethodNameBase + "$" + name,
descriptor, isInterface);
} else {
super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
}
}
};
} else {
Expand All @@ -553,7 +557,7 @@ public void visitMethodInsn(int opcode, String owner, String name, String descri
}
}, ClassReader.EXPAND_FRAMES);
} catch (Throwable t) {
throw new RuntimeException("Failed to add Hex.decode_*", t);
throw new RuntimeException("Failed to add " + HEX_CLASS_LOCATION + ".decode_*", t);
}
}
public void convertCode(DexMethodNode methodNode, MethodVisitor mv, ClzCtx clzCtx) {
Expand Down

0 comments on commit f3fc040

Please sign in to comment.