mirror of
https://github.com/revanced/smali.git
synced 2025-06-12 12:17:37 +02:00
Add support for the invoke-object-init/range opcode in ICS
This commit is contained in:
@ -1069,6 +1069,9 @@ public class MethodAnalyzer {
|
||||
case INVOKE_DIRECT_EMPTY:
|
||||
analyzeInvokeDirectEmpty(analyzedInstruction);
|
||||
return true;
|
||||
case INVOKE_OBJECT_INIT_RANGE:
|
||||
analyzeInvokeObjectInitRange(analyzedInstruction);
|
||||
return true;
|
||||
case IGET_QUICK:
|
||||
case IGET_WIDE_QUICK:
|
||||
case IGET_OBJECT_QUICK:
|
||||
@ -1568,6 +1571,7 @@ public class MethodAnalyzer {
|
||||
case EXECUTE_INLINE:
|
||||
case EXECUTE_INLINE_RANGE:
|
||||
case INVOKE_DIRECT_EMPTY:
|
||||
case INVOKE_OBJECT_INIT_RANGE:
|
||||
case IGET_QUICK:
|
||||
case IGET_WIDE_QUICK:
|
||||
case IGET_OBJECT_QUICK:
|
||||
@ -3470,6 +3474,17 @@ public class MethodAnalyzer {
|
||||
analyzeInstruction(analyzedInstruction);
|
||||
}
|
||||
|
||||
private void analyzeInvokeObjectInitRange(AnalyzedInstruction analyzedInstruction) {
|
||||
Instruction3rc instruction = (Instruction3rc)analyzedInstruction.instruction;
|
||||
|
||||
Instruction3rc deodexedInstruction = new Instruction3rc(Opcode.INVOKE_DIRECT_RANGE,
|
||||
(short)instruction.getRegCount(), instruction.getStartRegister(), instruction.getReferencedItem());
|
||||
|
||||
analyzedInstruction.setDeodexedInstruction(deodexedInstruction);
|
||||
|
||||
analyzeInstruction(analyzedInstruction);
|
||||
}
|
||||
|
||||
private boolean analyzeIputIgetQuick(AnalyzedInstruction analyzedInstruction) {
|
||||
Instruction22cs instruction = (Instruction22cs)analyzedInstruction.instruction;
|
||||
|
||||
|
@ -117,7 +117,8 @@ public class Instruction3rc extends InstructionWithReference implements Register
|
||||
if (type.charAt(1) == 'J' || type.charAt(1) == 'D') {
|
||||
throw new RuntimeException("The type cannot be an array of longs or doubles");
|
||||
}
|
||||
} else if (opcode.value >= INVOKE_VIRTUAL_RANGE.value && opcode.value <= INVOKE_INTERFACE_RANGE.value) {
|
||||
} else if (opcode.value >= INVOKE_VIRTUAL_RANGE.value && opcode.value <= INVOKE_INTERFACE_RANGE.value ||
|
||||
opcode == INVOKE_OBJECT_INIT_RANGE) {
|
||||
//check data for invoke-*/range opcodes
|
||||
MethodIdItem methodIdItem = (MethodIdItem) item;
|
||||
int parameterRegisterCount = methodIdItem.getPrototype().getParameterRegisterCount();
|
||||
|
@ -267,6 +267,7 @@ public enum Opcode
|
||||
EXECUTE_INLINE((short)0xee, "execute-inline", ReferenceType.none, Format.Format35mi, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
|
||||
EXECUTE_INLINE_RANGE((short)0xef, "execute-inline/range", ReferenceType.none, Format.Format3rmi, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
|
||||
INVOKE_DIRECT_EMPTY((short)0xf0, "invoke-direct-empty", ReferenceType.method, Format.Format35s, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
|
||||
INVOKE_OBJECT_INIT_RANGE((short)0xf0, "invoke-object-init/range", ReferenceType.method, Format.Format3rc, Opcode.ODEX_ONLY | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_RESULT),
|
||||
IGET_QUICK((short)0xf2, "iget-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
|
||||
IGET_WIDE_QUICK((short)0xf3, "iget-wide-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER | Opcode.SETS_WIDE_REGISTER),
|
||||
IGET_OBJECT_QUICK((short)0xf4, "iget-object-quick", ReferenceType.none, Format.Format22cs, Opcode.ODEX_ONLY | Opcode.ODEXED_INSTANCE_QUICK | Opcode.CAN_THROW | Opcode.CAN_CONTINUE | Opcode.SETS_REGISTER),
|
||||
@ -351,13 +352,16 @@ public enum Opcode
|
||||
opcodesByName = new HashMap<Integer, Opcode>();
|
||||
|
||||
for (Opcode opcode: Opcode.values()) {
|
||||
if (((opcode.value >> 8) & 0xFF) == 0x00) {
|
||||
opcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
} else {
|
||||
assert ((opcode.value >> 8) & 0xFF) == 0xFF;
|
||||
expandedOpcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
//INVOKE_DIRECT_EMPTY was changed to INVOKE_OBJECT_INIT_RANGE in ICS
|
||||
if (opcode != INVOKE_DIRECT_EMPTY) {
|
||||
if (((opcode.value >> 8) & 0xFF) == 0x00) {
|
||||
opcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
} else {
|
||||
assert ((opcode.value >> 8) & 0xFF) == 0xFF;
|
||||
expandedOpcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
}
|
||||
opcodesByName.put(opcode.name.hashCode(), opcode);
|
||||
}
|
||||
opcodesByName.put(opcode.name.hashCode(), opcode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -386,6 +390,18 @@ public enum Opcode
|
||||
}
|
||||
}
|
||||
|
||||
private static void addOpcodes(Opcode... toAdd) {
|
||||
for (Opcode opcode: toAdd) {
|
||||
if (((opcode.value >> 8) & 0xFF) == 0x00) {
|
||||
opcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
} else {
|
||||
assert ((opcode.value >> 8) & 0xFF) == 0xFF;
|
||||
expandedOpcodesByValue[opcode.value & 0xFF] = opcode;
|
||||
}
|
||||
opcodesByName.put(opcode.name.hashCode(), opcode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This will add/remove/replace various opcodes in the value/name maps as needed,
|
||||
* based on the idiosyncrasies of that api level
|
||||
@ -411,7 +427,9 @@ public enum Opcode
|
||||
SGET_JUMBO, SGET_WIDE_JUMBO, SGET_OBJECT_JUMBO, SGET_BOOLEAN_JUMBO, SGET_BYTE_JUMBO,
|
||||
SGET_CHAR_JUMBO, SGET_SHORT_JUMBO, SPUT_JUMBO, SPUT_WIDE_JUMBO, SPUT_OBJECT_JUMBO,
|
||||
SPUT_BOOLEAN_JUMBO, SPUT_BYTE_JUMBO, SPUT_CHAR_JUMBO, SPUT_SHORT_JUMBO, INVOKE_VIRTUAL_JUMBO,
|
||||
INVOKE_SUPER_JUMBO, INVOKE_DIRECT_JUMBO, INVOKE_STATIC_JUMBO, INVOKE_INTERFACE_JUMBO);
|
||||
INVOKE_SUPER_JUMBO, INVOKE_DIRECT_JUMBO, INVOKE_STATIC_JUMBO, INVOKE_INTERFACE_JUMBO,
|
||||
INVOKE_OBJECT_INIT_RANGE);
|
||||
addOpcodes(INVOKE_DIRECT_EMPTY);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user