capacitor-dex-editor 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1672,12 +1672,39 @@ public class DexManager {
|
|
|
1672
1672
|
MethodImplementation impl = method.getImplementation();
|
|
1673
1673
|
if (impl != null) {
|
|
1674
1674
|
smali.append(" .registers ").append(impl.getRegisterCount()).append("\n");
|
|
1675
|
+
smali.append("\n");
|
|
1675
1676
|
|
|
1676
|
-
//
|
|
1677
|
+
// 输出指令,跟踪标签位置
|
|
1678
|
+
java.util.Map<Integer, String> labelMap = new java.util.HashMap<>();
|
|
1679
|
+
int codeOffset = 0;
|
|
1680
|
+
|
|
1681
|
+
// 第一遍:收集所有标签位置
|
|
1677
1682
|
for (Instruction instruction : impl.getInstructions()) {
|
|
1678
|
-
smali.
|
|
1679
|
-
|
|
1683
|
+
if (instruction instanceof com.android.tools.smali.dexlib2.iface.instruction.OffsetInstruction) {
|
|
1684
|
+
com.android.tools.smali.dexlib2.iface.instruction.OffsetInstruction offInstr =
|
|
1685
|
+
(com.android.tools.smali.dexlib2.iface.instruction.OffsetInstruction) instruction;
|
|
1686
|
+
int targetOffset = codeOffset + offInstr.getCodeOffset();
|
|
1687
|
+
labelMap.put(targetOffset, ":cond_" + Integer.toHexString(targetOffset));
|
|
1688
|
+
}
|
|
1689
|
+
codeOffset += instruction.getCodeUnits();
|
|
1690
|
+
}
|
|
1691
|
+
|
|
1692
|
+
// 第二遍:输出指令
|
|
1693
|
+
codeOffset = 0;
|
|
1694
|
+
for (Instruction instruction : impl.getInstructions()) {
|
|
1695
|
+
// 输出标签(如果有)
|
|
1696
|
+
if (labelMap.containsKey(codeOffset)) {
|
|
1697
|
+
smali.append("\n ").append(labelMap.get(codeOffset)).append("\n");
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
smali.append(" ").append(instruction.getOpcode().name.toLowerCase().replace('_', '-'));
|
|
1701
|
+
String params = formatInstruction(instruction);
|
|
1702
|
+
if (!params.isEmpty()) {
|
|
1703
|
+
smali.append(" ").append(params);
|
|
1704
|
+
}
|
|
1680
1705
|
smali.append("\n");
|
|
1706
|
+
|
|
1707
|
+
codeOffset += instruction.getCodeUnits();
|
|
1681
1708
|
}
|
|
1682
1709
|
}
|
|
1683
1710
|
|