/** * Gets the item at the specified index in this section, or null if the index is -1 * @param index the index of the item to get * @return the item at the specified index in this section, or null if the index is -1 */ public T getOptionalItemByIndex(int index) { if (index == -1) { return null; } return getItemByIndex(index); }
private void lookupReferencedItem(DexFile dexFile, Opcode opcode, int itemIndex) { switch (referenceType) { case field: referencedItem = dexFile.FieldIdsSection.getItemByIndex(itemIndex); return; case method: referencedItem = dexFile.MethodIdsSection.getItemByIndex(itemIndex); return; case type: referencedItem = dexFile.TypeIdsSection.getItemByIndex(itemIndex); return; case string: referencedItem = dexFile.StringIdsSection.getItemByIndex(itemIndex); } }
@Override public void ProcessSetFile(int startDebugOffset, int length, int nameIndex) { if (nameIndex != -1) { referencedItemsList.add(dexFile.StringIdsSection.getItemByIndex(nameIndex)); } } });
@Override public void ProcessStartLocal(int startDebugOffset, int length, int registerNum, int nameIndex, int typeIndex, boolean registerIsSigned) { if (nameIndex != -1) { referencedItemsList.add(dexFile.StringIdsSection.getItemByIndex(nameIndex)); } if (typeIndex != -1) { referencedItemsList.add(dexFile.TypeIdsSection.getItemByIndex(typeIndex)); } }
@Override public void ProcessStartLocalExtended(int startDebugOffset, int length, int registerNume, int nameIndex, int typeIndex, int signatureIndex, boolean registerIsSigned) { if (nameIndex != -1) { referencedItemsList.add(dexFile.StringIdsSection.getItemByIndex(nameIndex)); } if (typeIndex != -1) { referencedItemsList.add(dexFile.TypeIdsSection.getItemByIndex(typeIndex)); } if (signatureIndex != -1) { referencedItemsList.add(dexFile.StringIdsSection.getItemByIndex(signatureIndex)); } }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { int stringIdIndex = in.readInt(); this.typeDescriptor = dexFile.StringIdsSection.getItemByIndex(stringIdIndex); }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { classType = dexFile.TypeIdsSection.getItemByIndex(in.readShort()); methodPrototype = dexFile.ProtoIdsSection.getItemByIndex(in.readShort()); methodName = dexFile.StringIdsSection.getItemByIndex(in.readInt()); }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { classType = dexFile.TypeIdsSection.getItemByIndex(in.readShort()); fieldType = dexFile.TypeIdsSection.getItemByIndex(in.readShort()); fieldName = dexFile.StringIdsSection.getItemByIndex(in.readInt()); }
/** * Constructs a new <code>TypeEncodedValue</code> by reading the type index from the given <code>Input</code> * object. The <code>Input</code>'s cursor should be set to the 2nd byte of the encoded value, and the high 3 bits * of the first byte should be passed as the valueArg parameter * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from * @param valueArg The high 3 bits of the first byte of this encoded value */ protected TypeEncodedValue(DexFile dexFile, Input in, byte valueArg) { int index = (int) EncodedValueUtils.decodeUnsignedIntegralValue(in.readBytes(valueArg+1)); value = dexFile.TypeIdsSection.getItemByIndex(index); }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { int size = in.readInt(); typeList = new TypeIdItem[size]; for (int i=0; i<size; i++) { int typeIndex = in.readShort(); typeList[i] = dexFile.TypeIdsSection.getItemByIndex(typeIndex); } }
/** * Constructs a new <code>StringEncodedValue</code> by reading the string index from the given <code>Input</code> * object. The <code>Input</code>'s cursor should be set to the 2nd byte of the encoded value, and the high 3 bits * of the first byte should be passed as the valueArg parameter * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from * @param valueArg The high 3 bits of the first byte of this encoded value */ protected StringEncodedValue(DexFile dexFile, Input in, byte valueArg) { int index = (int)EncodedValueUtils.decodeUnsignedIntegralValue(in.readBytes(valueArg+1)); value = dexFile.StringIdsSection.getItemByIndex(index); }
/** * Constructs a new <code>FieldEncodedValue</code> by reading the field index from the given <code>Input</code> * object. The <code>Input</code>'s cursor should be set to the 2nd byte of the encoded value, and the high 3 bits * of the first byte should be passed as the valueArg parameter * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from * @param valueArg The high 3 bits of the first byte of this encoded value */ protected FieldEncodedValue(DexFile dexFile, Input in, byte valueArg) { int index = (int) EncodedValueUtils.decodeUnsignedIntegralValue(in.readBytes(valueArg+1)); value = dexFile.FieldIdsSection.getItemByIndex(index); }
/** * This is used internally to construct a new <code>EncodedTypeAddrPair</code> while reading in a * <code>DexFile</code> * @param dexFile the <code>DexFile</code> that is being read in * @param in the Input object to read the <code>EncodedCatchHandler</code> from */ private EncodedTypeAddrPair(DexFile dexFile, Input in) { exceptionType = dexFile.TypeIdsSection.getItemByIndex(in.readUnsignedLeb128()); handlerAddress = in.readUnsignedLeb128(); }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { shortyDescriptor = dexFile.StringIdsSection.getItemByIndex(in.readInt()); returnType = dexFile.TypeIdsSection.getItemByIndex(in.readInt()); parameters = (TypeListItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_TYPE_LIST, in.readInt()); }
/** * Constructs a new <code>EnumEncodedValue</code> by reading the field index from the given <code>Input</code> * object. The <code>Input</code>'s cursor should be set to the 2nd byte of the encoded value, and the high 3 bits * of the first byte should be passed as the valueArg parameter * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from * @param valueArg The high 3 bits of the first byte of this encoded value */ protected EnumEncodedValue(DexFile dexFile, Input in, byte valueArg) { int index = (int) EncodedValueUtils.decodeUnsignedIntegralValue(in.readBytes(valueArg+1)); value = dexFile.FieldIdsSection.getItemByIndex(index); }
/** * Constructs a new <code>MethodEncodedValue</code> by reading the method index from the given <code>Input</code> * object. The <code>Input</code>'s cursor should be set to the 2nd byte of the encoded value, and the high 3 bits * of the first byte should be passed as the valueArg parameter * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from * @param valueArg The high 3 bits of the first byte of this encoded value */ protected MethodEncodedValue(DexFile dexFile, Input in, byte valueArg) { int index = (int) EncodedValueUtils.decodeUnsignedIntegralValue(in.readBytes(valueArg+1)); value = dexFile.MethodIdsSection.getItemByIndex(index); }
/** * Constructs a new <code>AnnotationEncodedSubValue</code> by reading the value from the given <code>Input</code> * object. * @param dexFile The <code>DexFile</code> that is being read in * @param in The <code>Input</code> object to read from */ public AnnotationEncodedSubValue(DexFile dexFile, Input in) { annotationType = dexFile.TypeIdsSection.getItemByIndex(in.readUnsignedLeb128()); names = new StringIdItem[in.readUnsignedLeb128()]; values = new EncodedValue[names.length]; for (int i=0; i<names.length; i++) { names[i] = dexFile.StringIdsSection.getItemByIndex(in.readUnsignedLeb128()); values[i] = EncodedValue.readEncodedValue(dexFile, in); } }
/** * This is used internally to construct a new <code>EncodedField</code> while reading in a <code>DexFile</code> * @param dexFile The <code>DexFile</code> that is being read in * @param in the Input object to read the <code>EncodedField</code> from * @param previousEncodedField The previous <code>EncodedField</code> in the list containing this * <code>EncodedField</code>. */ private EncodedField(DexFile dexFile, Input in, EncodedField previousEncodedField) { int previousIndex = previousEncodedField==null?0:previousEncodedField.field.getIndex(); field = dexFile.FieldIdsSection.getItemByIndex(in.readUnsignedLeb128() + previousIndex); accessFlags = in.readUnsignedLeb128(); }
/** * This is used internally to construct a new <code>EncodedMethod</code> while reading in a <code>DexFile</code> * @param dexFile The <code>DexFile</code> that is being read in * @param readContext a <code>ReadContext</code> object to hold information that is only needed while reading * in a file * @param in the Input object to read the <code>EncodedMethod</code> from * @param previousEncodedMethod The previous <code>EncodedMethod</code> in the list containing this * <code>EncodedMethod</code>. */ public EncodedMethod(DexFile dexFile, ReadContext readContext, Input in, EncodedMethod previousEncodedMethod) { int previousIndex = previousEncodedMethod==null?0:previousEncodedMethod.method.getIndex(); method = dexFile.MethodIdsSection.getItemByIndex(in.readUnsignedLeb128() + previousIndex); accessFlags = in.readUnsignedLeb128(); if (dexFile.skipInstructions()) { in.readUnsignedLeb128(); codeItem = null; } else { codeItem = (CodeItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_CODE_ITEM, in.readUnsignedLeb128()); } if (codeItem != null) { codeItem.setParent(this); } }
/** {@inheritDoc} */ protected void readItem(Input in, ReadContext readContext) { classType = dexFile.TypeIdsSection.getItemByIndex(in.readInt()); accessFlags = in.readInt(); superType = dexFile.TypeIdsSection.getOptionalItemByIndex(in.readInt()); implementedInterfaces = (TypeListItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_TYPE_LIST, in.readInt()); sourceFile = dexFile.StringIdsSection.getOptionalItemByIndex(in.readInt()); annotations = (AnnotationDirectoryItem)readContext.getOptionalOffsettedItemByOffset( ItemType.TYPE_ANNOTATIONS_DIRECTORY_ITEM, in.readInt()); classData = (ClassDataItem)readContext.getOptionalOffsettedItemByOffset(ItemType.TYPE_CLASS_DATA_ITEM, in.readInt()); staticFieldInitializers = (EncodedArrayItem)readContext.getOptionalOffsettedItemByOffset( ItemType.TYPE_ENCODED_ARRAY_ITEM, in.readInt()); if (classData != null) { classData.setParent(this); } if (annotations != null) { annotations.setParent(this); } }