DexRepair
DexRepair copied to clipboard
code_item ins 方法体写入
com/android/dex/Dex.java: read hanlders first ---> and then skip 8byties ---> read tries by hanlders; don't know why, but this seems success fixed try-catch; modify follow:
private Code readCode() { int registersSize = readUnsignedShort(); int insSize = readUnsignedShort(); int outsSize = readUnsignedShort(); int triesSize = readUnsignedShort(); int debugInfoOffset = readInt(); int instructionsSize = readInt(); short[] instructions = readShortArray(instructionsSize); Try[] tries; CatchHandler[] catchHandlers; if (triesSize > 0) { if (instructions.length % 2 == 1) { readShort(); // padding }
/*
* We can't read the tries until we've read the catch handlers.
* Unfortunately they're in the opposite order in the dex file
* so we need to read them out-of-order.
*/
// old
// Section triesSection = open(data.position()); // skip(triesSize * SizeOf.TRY_ITEM); // catchHandlers = readCatchHandlers(); // tries = triesSection.readTries(triesSize, catchHandlers);
catchHandlers = readCatchHandlers();
Section triesSection = open(data.position());
skip(triesSize * SizeOf.TRY_ITEM);
tries = triesSection.readTries(triesSize, catchHandlers);
} else {
tries = new Try[0];
catchHandlers = new CatchHandler[0];
}
return new Code(registersSize, insSize, outsSize, debugInfoOffset, instructions,
tries, catchHandlers);
}