mirror of
https://github.com/revanced/smali.git
synced 2025-04-30 06:34:25 +02:00
Fixing METHOD_PROTO and DualReferenceInstruction writing via class interning in DexPool
This commit is contained in:
parent
11f71ae481
commit
3fb538f202
@ -44,6 +44,7 @@ import org.jf.dexlib2.builder.MutableMethodImplementation;
|
|||||||
import org.jf.dexlib2.formatter.DexFormatter;
|
import org.jf.dexlib2.formatter.DexFormatter;
|
||||||
import org.jf.dexlib2.iface.*;
|
import org.jf.dexlib2.iface.*;
|
||||||
import org.jf.dexlib2.iface.debug.*;
|
import org.jf.dexlib2.iface.debug.*;
|
||||||
|
import org.jf.dexlib2.iface.instruction.DualReferenceInstruction;
|
||||||
import org.jf.dexlib2.iface.instruction.Instruction;
|
import org.jf.dexlib2.iface.instruction.Instruction;
|
||||||
import org.jf.dexlib2.iface.instruction.ReferenceInstruction;
|
import org.jf.dexlib2.iface.instruction.ReferenceInstruction;
|
||||||
import org.jf.dexlib2.iface.reference.*;
|
import org.jf.dexlib2.iface.reference.*;
|
||||||
@ -133,27 +134,12 @@ public class ClassPool extends BasePool<String, PoolClassDef> implements ClassSe
|
|||||||
for (Instruction instruction: methodImpl.getInstructions()) {
|
for (Instruction instruction: methodImpl.getInstructions()) {
|
||||||
hasInstruction = true;
|
hasInstruction = true;
|
||||||
if (instruction instanceof ReferenceInstruction) {
|
if (instruction instanceof ReferenceInstruction) {
|
||||||
Reference reference = ((ReferenceInstruction)instruction).getReference();
|
ReferenceInstruction refInst = (ReferenceInstruction)instruction;
|
||||||
switch (instruction.getOpcode().referenceType) {
|
internReference(refInst.getReference(), refInst.getReferenceType());
|
||||||
case ReferenceType.STRING:
|
|
||||||
dexPool.stringSection.intern((StringReference)reference);
|
|
||||||
break;
|
|
||||||
case ReferenceType.TYPE:
|
|
||||||
dexPool.typeSection.intern(((TypeReference)reference).getType());
|
|
||||||
break;
|
|
||||||
case ReferenceType.FIELD:
|
|
||||||
dexPool.fieldSection.intern((FieldReference) reference);
|
|
||||||
break;
|
|
||||||
case ReferenceType.METHOD:
|
|
||||||
dexPool.methodSection.intern((MethodReference)reference);
|
|
||||||
break;
|
|
||||||
case ReferenceType.CALL_SITE:
|
|
||||||
dexPool.callSiteSection.intern((CallSiteReference) reference);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new ExceptionWithContext("Unrecognized reference type: %d",
|
|
||||||
instruction.getOpcode().referenceType);
|
|
||||||
}
|
}
|
||||||
|
if (instruction instanceof DualReferenceInstruction) {
|
||||||
|
DualReferenceInstruction dualRefInst = (DualReferenceInstruction)instruction;
|
||||||
|
internReference(dualRefInst.getReference2(), dualRefInst.getReferenceType2());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +156,32 @@ public class ClassPool extends BasePool<String, PoolClassDef> implements ClassSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void internReference(@Nonnull Reference reference, int referenceType) {
|
||||||
|
switch (referenceType) {
|
||||||
|
case ReferenceType.STRING:
|
||||||
|
dexPool.stringSection.intern((StringReference)reference);
|
||||||
|
break;
|
||||||
|
case ReferenceType.TYPE:
|
||||||
|
dexPool.typeSection.intern(((TypeReference)reference).getType());
|
||||||
|
break;
|
||||||
|
case ReferenceType.FIELD:
|
||||||
|
dexPool.fieldSection.intern((FieldReference) reference);
|
||||||
|
break;
|
||||||
|
case ReferenceType.METHOD:
|
||||||
|
dexPool.methodSection.intern((MethodReference)reference);
|
||||||
|
break;
|
||||||
|
case ReferenceType.METHOD_PROTO:
|
||||||
|
dexPool.protoSection.intern((MethodProtoReference)reference);
|
||||||
|
break;
|
||||||
|
case ReferenceType.CALL_SITE:
|
||||||
|
dexPool.callSiteSection.intern((CallSiteReference) reference);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ExceptionWithContext("Unrecognized reference type: %d",
|
||||||
|
referenceType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void internDebug(@Nonnull Method method) {
|
private void internDebug(@Nonnull Method method) {
|
||||||
for (MethodParameter param: method.getParameters()) {
|
for (MethodParameter param: method.getParameters()) {
|
||||||
String paramName = param.getName();
|
String paramName = param.getName();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user