private ClassData.Method[] readMethods(int count) { ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) { methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128(); result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff); } return result; }
public DebugInfoItem readDebugInfoItem() { int off = data.position(); int lineStart = readUleb128(); int parametersSize = readUleb128(); int[] parameterNames = new int[parametersSize]; for (int i = 0; i < parametersSize; ++i) { int addrDiff = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, addrDiff); break; int registerNum = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, registerNum); int nameIndex = readUleb128p1(); int registerNum = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, registerNum); break;
private ClassData.Field[] readFields(int count) { ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) { fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128(); result[i] = new ClassData.Field(fieldIndex, accessFlags); } return result; }
int oldAddrDiff = oldDbgInfoBuffer.readUleb128(); int newAddrDiff = newDbgInfoBuffer.readUleb128(); oldAddress += oldAddrDiff; newAddress += newAddrDiff; int oldRegisterNum = oldDbgInfoBuffer.readUleb128(); int newRegisterNum = newDbgInfoBuffer.readUleb128(); if (oldRegisterNum != newRegisterNum) { return false; int oldRegisterNum = oldDbgInfoBuffer.readUleb128(); int newRegisterNum = newDbgInfoBuffer.readUleb128(); if (oldRegisterNum != newRegisterNum) { return false;
private Code.CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = new int[handlersCount]; int[] addresses = new int[handlersCount]; for (int i = 0; i < handlersCount; i++) { typeIndexes[i] = readUleb128(); addresses[i] = readUleb128(); } int catchAllAddress = size <= 0 ? readUleb128() : -1; return new Code.CatchHandler(typeIndexes, addresses, catchAllAddress, offset); }
public DebugInfoItem readDebugInfoItem() { int off = data.position(); int lineStart = readUleb128(); int parametersSize = readUleb128(); int[] parameterNames = new int[parametersSize]; for (int i = 0; i < parametersSize; ++i) { int addrDiff = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, addrDiff); break; int registerNum = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, registerNum); int nameIndex = readUleb128p1(); int registerNum = readUleb128(); Leb128.writeUnsignedLeb128(outAdapter, registerNum); break;
private Code.CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128(); Code.CatchHandler[] result = new Code.CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset; result[i] = readCatchHandler(offset); } return result; }
int oldAddrDiff = oldDbgInfoBuffer.readUleb128(); int newAddrDiff = newDbgInfoBuffer.readUleb128(); oldAddress += oldAddrDiff; newAddress += newAddrDiff; int oldRegisterNum = oldDbgInfoBuffer.readUleb128(); int newRegisterNum = newDbgInfoBuffer.readUleb128(); if (oldRegisterNum != newRegisterNum) { return false; int oldRegisterNum = oldDbgInfoBuffer.readUleb128(); int newRegisterNum = newDbgInfoBuffer.readUleb128(); if (oldRegisterNum != newRegisterNum) { return false;
public ClassData readClassData() { int off = data.position(); int staticFieldsSize = readUleb128(); int instanceFieldsSize = readUleb128(); int directMethodsSize = readUleb128(); int virtualMethodsSize = readUleb128(); ClassData.Field[] staticFields = readFields(staticFieldsSize); ClassData.Field[] instanceFields = readFields(instanceFieldsSize); ClassData.Method[] directMethods = readMethods(directMethodsSize); ClassData.Method[] virtualMethods = readMethods(virtualMethodsSize); return new ClassData(off, staticFields, instanceFields, directMethods, virtualMethods); }
public StringData readStringData() { int off = data.position(); try { int expectedLength = readUleb128(); String result = Mutf8.decode(this, new char[expectedLength]); if (result.length() != expectedLength) { throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length()); } return new StringData(off, result); } catch (UTFDataFormatException e) { throw new DexException(e); } }
public void execute() { final int deletedItemCount = patchFile.getBuffer().readUleb128(); final int[] deletedIndices = readDeltaIndiciesOrOffsets(deletedItemCount); final int addedItemCount = patchFile.getBuffer().readUleb128(); final int[] addedIndices = readDeltaIndiciesOrOffsets(addedItemCount); final int replacedItemCount = patchFile.getBuffer().readUleb128(); final int[] replacedIndices = readDeltaIndiciesOrOffsets(replacedItemCount); final TableOfContents.Section tocSec = getTocSection(this.oldDex); Dex.Section oldSection = null; int oldItemCount = 0; if (tocSec.exists()) { oldSection = this.oldDex.openSection(tocSec); oldItemCount = tocSec.size; } // Now rest data are added and replaced items arranged in the order of // added indices and replaced indices. doFullPatch( oldSection, oldItemCount, deletedIndices, addedIndices, replacedIndices ); }
private ClassData.Method[] readMethods(int count) { ClassData.Method[] result = new ClassData.Method[count]; int methodIndex = 0; for (int i = 0; i < count; i++) { methodIndex += readUleb128(); // method index diff int accessFlags = readUleb128(); int codeOff = readUleb128(); result[i] = new ClassData.Method(methodIndex, accessFlags, codeOff); } return result; }
private ClassData.Field[] readFields(int count) { ClassData.Field[] result = new ClassData.Field[count]; int fieldIndex = 0; for (int i = 0; i < count; i++) { fieldIndex += readUleb128(); // field index diff int accessFlags = readUleb128(); result[i] = new ClassData.Field(fieldIndex, accessFlags); } return result; }
private Code.CatchHandler readCatchHandler(int offset) { int size = readSleb128(); int handlersCount = Math.abs(size); int[] typeIndexes = new int[handlersCount]; int[] addresses = new int[handlersCount]; for (int i = 0; i < handlersCount; i++) { typeIndexes[i] = readUleb128(); addresses[i] = readUleb128(); } int catchAllAddress = size <= 0 ? readUleb128() : -1; return new Code.CatchHandler(typeIndexes, addresses, catchAllAddress, offset); }
private Code.CatchHandler[] readCatchHandlers() { int baseOffset = data.position(); int catchHandlersSize = readUleb128(); Code.CatchHandler[] result = new Code.CatchHandler[catchHandlersSize]; for (int i = 0; i < catchHandlersSize; i++) { int offset = data.position() - baseOffset; result[i] = readCatchHandler(offset); } return result; }
public ClassData readClassData() { int off = data.position(); int staticFieldsSize = readUleb128(); int instanceFieldsSize = readUleb128(); int directMethodsSize = readUleb128(); int virtualMethodsSize = readUleb128(); ClassData.Field[] staticFields = readFields(staticFieldsSize); ClassData.Field[] instanceFields = readFields(instanceFieldsSize); ClassData.Method[] directMethods = readMethods(directMethodsSize); ClassData.Method[] virtualMethods = readMethods(virtualMethodsSize); return new ClassData(off, staticFields, instanceFields, directMethods, virtualMethods); }
public StringData readStringData() { int off = data.position(); try { int expectedLength = readUleb128(); String result = Mutf8.decode(this, new char[expectedLength]); if (result.length() != expectedLength) { throw new DexException("Declared length " + expectedLength + " doesn't match decoded length of " + result.length()); } return new StringData(off, result); } catch (UTFDataFormatException e) { throw new DexException(e); } }
List<Integer> replaceOpIndexList = new ArrayList<>(); int delOpIndexListSize = dexDataBuffer.readUleb128(); int previousIndex = 0; for (int i = 0; i < delOpIndexListSize; i++) { int addOpIndexListSize = dexDataBuffer.readUleb128(); previousIndex = 0; for (int i = 0; i < addOpIndexListSize; i++) { int replaceOpIndexListSize = dexDataBuffer.readUleb128(); previousIndex = 0; for (int i = 0; i < replaceOpIndexListSize; i++) {
public void execute() { final int deletedItemCount = patchFile.getBuffer().readUleb128(); final int[] deletedIndices = readDeltaIndiciesOrOffsets(deletedItemCount); final int addedItemCount = patchFile.getBuffer().readUleb128(); final int[] addedIndices = readDeltaIndiciesOrOffsets(addedItemCount); final int replacedItemCount = patchFile.getBuffer().readUleb128(); final int[] replacedIndices = readDeltaIndiciesOrOffsets(replacedItemCount); final TableOfContents.Section tocSec = getTocSection(this.oldDex); Dex.Section oldSection = null; int oldItemCount = 0; if (tocSec.exists()) { oldSection = this.oldDex.openSection(tocSec); oldItemCount = tocSec.size; } // Now rest data are added and replaced items arranged in the order of // added indices and replaced indices. doFullPatch( oldSection, oldItemCount, deletedIndices, addedIndices, replacedIndices ); }