private boolean isSameTries( Dex oldDex, Dex newDex, Code.Try[] oldTries, Code.Try[] newTries, InstructionComparator insnComparator ) { if (oldTries.length != newTries.length) { return false; } for (int i = 0; i < oldTries.length; ++i) { Code.Try oldTry = oldTries[i]; Code.Try newTry = newTries[i]; if (oldTry.instructionCount != newTry.instructionCount) { return false; } if (oldTry.catchHandlerIndex != newTry.catchHandlerIndex) { return false; } if (!insnComparator.isSameInstruction(oldTry.startAddress, newTry.startAddress)) { return false; } } return true; }
private boolean compareIndex(int opcode, int index1, int index2) { switch (InstructionCodec.getInstructionIndexType(opcode)) { case InstructionCodec.INDEX_TYPE_STRING_REF: { return compareString(index1, index2); } case InstructionCodec.INDEX_TYPE_TYPE_REF: { return compareType(index1, index2); } case InstructionCodec.INDEX_TYPE_FIELD_REF: { return compareField(index1, index2); } case InstructionCodec.INDEX_TYPE_METHOD_REF: { return compareMethod(index1, index2); } default: { return index1 == index2; } } }
public InstructionComparator(short[] insns1, short[] insns2) { this.insns1 = insns1; this.insns2 = insns2; if (insns1 != null) { ShortArrayCodeInput codeIn1 = new ShortArrayCodeInput(insns1); this.insnHolders1 = readInstructionsIntoHolders(codeIn1, insns1.length); } else { this.insnHolders1 = null; } if (insns2 != null) { ShortArrayCodeInput codeIn2 = new ShortArrayCodeInput(insns2); this.insnHolders2 = readInstructionsIntoHolders(codeIn2, insns2.length); } else { this.insnHolders2 = null; } visitedInsnAddrPairs = new HashSet<>(); }
if (insnHolder1.opcode == Opcodes.CONST_STRING && insnHolder2.opcode == Opcodes.CONST_STRING_JUMBO) { if (!compareString(insnHolder1.index, insnHolder2.index)) { return false; if (insnHolder1.opcode == Opcodes.CONST_STRING_JUMBO && insnHolder2.opcode == Opcodes.CONST_STRING) { if (!compareString(insnHolder1.index, insnHolder2.index)) { return false; if (!isSameInstruction(insnHolder1.address, insnHolder2.address)) { return false;
return isSameInstruction(insnHolder1.target, insnHolder2.target); } else { case InstructionCodec.INSN_FORMAT_35C: case InstructionCodec.INSN_FORMAT_3RC: { return compareIndex(opcode, insnHolder1.index, insnHolder2.index); if (!isSameInstruction(specInsnHolder1.targets[i], specInsnHolder2.targets[i])) { return false; if (!isSameInstruction(specInsnHolder1.targets[i], specInsnHolder2.targets[i])) { return false;
if (!insnComparator.compare()) { return false;
if (insnHolder1.opcode == Opcodes.CONST_STRING && insnHolder2.opcode == Opcodes.CONST_STRING_JUMBO) { if (!compareString(insnHolder1.index, insnHolder2.index)) { return false; if (insnHolder1.opcode == Opcodes.CONST_STRING_JUMBO && insnHolder2.opcode == Opcodes.CONST_STRING) { if (!compareString(insnHolder1.index, insnHolder2.index)) { return false; if (!isSameInstruction(insnHolder1.address, insnHolder2.address)) { return false;
return isSameInstruction(insnHolder1.target, insnHolder2.target); } else { case InstructionCodec.INSN_FORMAT_35C: case InstructionCodec.INSN_FORMAT_3RC: { return compareIndex(opcode, insnHolder1.index, insnHolder2.index); if (!isSameInstruction(specInsnHolder1.targets[i], specInsnHolder2.targets[i])) { return false; if (!isSameInstruction(specInsnHolder1.targets[i], specInsnHolder2.targets[i])) { return false;
if (!insnComparator.compare()) { return false;
private boolean compareIndex(int opcode, int index1, int index2) { switch (InstructionCodec.getInstructionIndexType(opcode)) { case InstructionCodec.INDEX_TYPE_STRING_REF: { return compareString(index1, index2); } case InstructionCodec.INDEX_TYPE_TYPE_REF: { return compareType(index1, index2); } case InstructionCodec.INDEX_TYPE_FIELD_REF: { return compareField(index1, index2); } case InstructionCodec.INDEX_TYPE_METHOD_REF: { return compareMethod(index1, index2); } default: { return index1 == index2; } } }
return insnComparator.isSameInstruction( oldCatchHandler.catchAllAddress, newCatchHandler.catchAllAddress ); if (!insnComparator.isSameInstruction( oldCatchHandler.addresses[j], newCatchHandler.addresses[j] )) {
public InstructionComparator(short[] insns1, short[] insns2) { this.insns1 = insns1; this.insns2 = insns2; if (insns1 != null) { ShortArrayCodeInput codeIn1 = new ShortArrayCodeInput(insns1); this.insnHolders1 = readInstructionsIntoHolders(codeIn1, insns1.length); } else { this.insnHolders1 = null; } if (insns2 != null) { ShortArrayCodeInput codeIn2 = new ShortArrayCodeInput(insns2); this.insnHolders2 = readInstructionsIntoHolders(codeIn2, insns2.length); } else { this.insnHolders2 = null; } visitedInsnAddrPairs = new HashSet<>(); }
oldAddress += oldAddrDiff; newAddress += newAddrDiff; if (!insnComparator.isSameInstruction(oldAddress, newAddress)) { return false; return false; if (!insnComparator.isSameInstruction(oldAddress, newAddress)) { return false;
private boolean isSameTries( Dex oldDex, Dex newDex, Code.Try[] oldTries, Code.Try[] newTries, InstructionComparator insnComparator ) { if (oldTries.length != newTries.length) { return false; } for (int i = 0; i < oldTries.length; ++i) { Code.Try oldTry = oldTries[i]; Code.Try newTry = newTries[i]; if (oldTry.instructionCount != newTry.instructionCount) { return false; } if (oldTry.catchHandlerIndex != newTry.catchHandlerIndex) { return false; } if (!insnComparator.isSameInstruction(oldTry.startAddress, newTry.startAddress)) { return false; } } return true; }
return insnComparator.isSameInstruction( oldCatchHandler.catchAllAddress, newCatchHandler.catchAllAddress ); if (!insnComparator.isSameInstruction( oldCatchHandler.addresses[j], newCatchHandler.addresses[j] )) {
oldAddress += oldAddrDiff; newAddress += newAddrDiff; if (!insnComparator.isSameInstruction(oldAddress, newAddress)) { return false; return false; if (!insnComparator.isSameInstruction(oldAddress, newAddress)) { return false;