out.annotate("string_ids_size: " + dexFile.StringIdsSection.getItems().size()); out.writeInt(dexFile.StringIdsSection.getItems().size()); out.annotate("string_ids_off: 0x" + Integer.toHexString(dexFile.StringIdsSection.getOffset())); out.writeInt(dexFile.StringIdsSection.getOffset()); out.annotate("type_ids_size: " + dexFile.TypeIdsSection.getItems().size()); out.writeInt(dexFile.TypeIdsSection.getItems().size()); out.annotate("type_ids_off: 0x" + Integer.toHexString(dexFile.TypeIdsSection.getOffset())); out.writeInt(dexFile.TypeIdsSection.getOffset()); out.annotate("proto_ids_size: " + dexFile.ProtoIdsSection.getItems().size()); out.writeInt(dexFile.ProtoIdsSection.getItems().size()); out.annotate("proto_ids_off: 0x" + Integer.toHexString(dexFile.ProtoIdsSection.getOffset())); out.writeInt(dexFile.ProtoIdsSection.getOffset()); out.annotate("field_ids_size: " + dexFile.FieldIdsSection.getItems().size()); out.writeInt(dexFile.FieldIdsSection.getItems().size()); out.annotate("field_ids_off: 0x" + Integer.toHexString(dexFile.FieldIdsSection.getOffset())); out.writeInt(dexFile.FieldIdsSection.getOffset()); out.annotate("method_ids_size: " + dexFile.MethodIdsSection.getItems().size()); out.writeInt(dexFile.MethodIdsSection.getItems().size()); out.annotate("method_ids_off: 0x" + Integer.toHexString(dexFile.MethodIdsSection.getOffset())); out.writeInt(dexFile.MethodIdsSection.getOffset());
/** * Looks up the <code>ProtoIdItem</code> from the given <code>DexFile</code> for the given * values * @param dexFile the <code>Dexfile</code> to find the type in * @param returnType the return type * @param parameters a <code>TypeListItem</code> containing a list of the parameter types * @return a <code>ProtoIdItem</code> from the given <code>DexFile</code> for the given * values, or null if it doesn't exist */ public static ProtoIdItem lookupProtoIdItem(DexFile dexFile, TypeIdItem returnType, TypeListItem parameters) { ProtoIdItem protoIdItem = new ProtoIdItem(dexFile, returnType, parameters); return dexFile.ProtoIdsSection.getInternedItem(protoIdItem); }
/** * 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); }
/** * Returns a <code>TypeIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item will belong to * @param typeDescriptor The <code>StringIdItem</code> containing the type descriptor that * this <code>TypeIdItem</code> represents * @return a <code>TypeIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static TypeIdItem internTypeIdItem(DexFile dexFile, StringIdItem typeDescriptor) { TypeIdItem typeIdItem = new TypeIdItem(dexFile, typeDescriptor); return dexFile.TypeIdsSection.intern(typeIdItem); }
public DexFileClassMap(DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { definedClasses.put(classDefItem.getClassType().getTypeDescriptor(), classDefItem); } }
/** {@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); } }
IndexedSection<StringIdItem> stringIdSection = dexFile.StringIdsSection; for (int i=0; i<parameterNames.length; i++) { parameterNames[i] = stringIdSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1);
public int placeAt(int offset) { if (DexFile.this.getInplace()) { return super.placeAt(offset); } int ret = ClassDefItem.placeClassDefItems(this, offset); Collections.sort(this.items, new Comparator<ClassDefItem>() { public int compare(ClassDefItem a, ClassDefItem b) { return a.getOffset() - b.getOffset(); } }); this.offset = items.get(0).getOffset(); return ret; } };
/** * Returns a <code>ProtoIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item belongs to * @param returnType the return type * @param parameters a <code>TypeListItem</code> containing a list of the parameter types * @return a <code>ProtoIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static ProtoIdItem internProtoIdItem(DexFile dexFile, TypeIdItem returnType, TypeListItem parameters) { ProtoIdItem protoIdItem = new ProtoIdItem(dexFile, returnType, parameters); return dexFile.ProtoIdsSection.intern(protoIdItem); }
public void loadDexFile(String dexFilePath, DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { try { //TODO: need to check if the class already exists. (and if so, what to do about it?) TempClassInfo tempClassInfo = new TempClassInfo(dexFilePath, classDefItem); tempClasses.put(tempClassInfo.classType, tempClassInfo); } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, String.format("Error while loading class %s", classDefItem.getClassType().getTypeDescriptor())); } } }
/** {@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); } }
StringIdItem name = dexFile.StringIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); TypeIdItem type = dexFile.TypeIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); locals[registerNum] = new Local(registerNum, name, type, null); processDecodedDebugInstruction.ProcessStartLocal(currentCodeAddress, StringIdItem name = dexFile.StringIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); TypeIdItem type = dexFile.TypeIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); StringIdItem signature = dexFile.StringIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); locals[registerNum] = new Local(registerNum, name, type, signature); processDecodedDebugInstruction.ProcessStartLocalExtended(currentCodeAddress, StringIdItem name = dexFile.StringIdsSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1); processDecodedDebugInstruction.ProcessSetFile(currentCodeAddress, in.getCursor() - startDebugOffset, name); break;
public int placeAt(int offset) { if (DexFile.this.getInplace()) { return super.placeAt(offset); } int ret = ClassDefItem.placeClassDefItems(this, offset); Collections.sort(this.items); this.offset = items.get(0).getOffset(); return ret; }
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); } }
/** * Returns a <code>FieldIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> * @param dexFile The <code>DexFile</code> that this item belongs to * @param classType the class that the field is a member of * @param fieldType the type of the field * @param fieldName the name of the field * @return a <code>FieldIdItem</code> for the given values, and that has been interned into * the given <code>DexFile</code> */ public static FieldIdItem internFieldIdItem(DexFile dexFile, TypeIdItem classType, TypeIdItem fieldType, StringIdItem fieldName) { FieldIdItem fieldIdItem = new FieldIdItem(dexFile, classType, fieldType, fieldName); return dexFile.FieldIdsSection.intern(fieldIdItem); }
out.annotate("string_ids_size: " + dexFile.StringIdsSection.getItems().size()); out.writeInt(dexFile.StringIdsSection.getItems().size()); out.annotate("string_ids_off: 0x" + Integer.toHexString(dexFile.StringIdsSection.getOffset())); out.writeInt(dexFile.StringIdsSection.getOffset()); out.annotate("type_ids_size: " + dexFile.TypeIdsSection.getItems().size()); out.writeInt(dexFile.TypeIdsSection.getItems().size()); out.annotate("type_ids_off: 0x" + Integer.toHexString(dexFile.TypeIdsSection.getOffset())); out.writeInt(dexFile.TypeIdsSection.getOffset()); out.annotate("proto_ids_size: " + dexFile.ProtoIdsSection.getItems().size()); out.writeInt(dexFile.ProtoIdsSection.getItems().size()); out.annotate("proto_ids_off: 0x" + Integer.toHexString(dexFile.ProtoIdsSection.getOffset())); out.writeInt(dexFile.ProtoIdsSection.getOffset()); out.annotate("field_ids_size: " + dexFile.FieldIdsSection.getItems().size()); out.writeInt(dexFile.FieldIdsSection.getItems().size()); out.annotate("field_ids_off: 0x" + Integer.toHexString(dexFile.FieldIdsSection.getOffset())); out.writeInt(dexFile.FieldIdsSection.getOffset()); out.annotate("method_ids_size: " + dexFile.MethodIdsSection.getItems().size()); out.writeInt(dexFile.MethodIdsSection.getItems().size()); out.annotate("method_ids_off: 0x" + Integer.toHexString(dexFile.MethodIdsSection.getOffset())); out.writeInt(dexFile.MethodIdsSection.getOffset());
public DexFileClassMap(DexFile dexFile) { for (ClassDefItem classDefItem: dexFile.ClassDefsSection.getItems()) { definedClasses.put(classDefItem.getClassType().getTypeDescriptor(), classDefItem); } }
/** * Looks up a <code>MethodIdItem</code> from the given <code>DexFile</code> for the given * values * @param dexFile The <code>DexFile</code> that this item belongs to * @param classType the class that the method is a member of * @param methodPrototype the type of the method * @param methodName the name of the method * @return a <code>MethodIdItem</code> from the given <code>DexFile</code> for the given * values, or null if it doesn't exist */ public static MethodIdItem lookupMethodIdItem(DexFile dexFile, TypeIdItem classType, ProtoIdItem methodPrototype, StringIdItem methodName) { MethodIdItem methodIdItem = new MethodIdItem(dexFile, classType, methodPrototype, methodName); return dexFile.MethodIdsSection.getInternedItem(methodIdItem); }
IndexedSection<StringIdItem> stringIdSection = dexFile.StringIdsSection; for (int i=0; i<parameterNames.length; i++) { parameterNames[i] = stringIdSection.getOptionalItemByIndex(in.readUnsignedLeb128() - 1);
@Override public void ProcessSetFile(int startDebugOffset, int length, int nameIndex) { if (nameIndex != -1) { referencedItemsList.add(dexFile.StringIdsSection.getItemByIndex(nameIndex)); } } });