/** * Write ProtoId item into current section. * * @return real offset of item we've just written in this section. */ public int writeProtoId(ProtoId protoId) { int off = data.position(); writeInt(protoId.shortyIndex); writeInt(protoId.returnTypeIndex); writeInt(protoId.parametersOffset); return off; }
/** * Write AnnotationSet item into current section. * * @return real offset of item we've just written in this section. */ public int writeAnnotationSet(AnnotationSet annotationSet) { int off = data.position(); writeInt(annotationSet.annotationOffsets.length); for (int annotationOffset : annotationSet.annotationOffsets) { writeInt(annotationOffset); } return off; }
/** * Write AnnotationSetRefList item into current section. * * @return real offset of item we've just written in this section. */ public int writeAnnotationSetRefList(AnnotationSetRefList annotationSetRefList) { int off = data.position(); writeInt(annotationSetRefList.annotationSetRefItems.length); for (int annotationSetRefItem : annotationSetRefList.annotationSetRefItems) { writeInt(annotationSetRefItem); } return off; }
/** * Write ClassDef item into current section. * * @return real offset of item we've just written in this section. */ public int writeClassDef(ClassDef classDef) { int off = data.position(); writeInt(classDef.typeIndex); writeInt(classDef.accessFlags); writeInt(classDef.supertypeIndex); writeInt(classDef.interfacesOffset); writeInt(classDef.sourceFileIndex); writeInt(classDef.annotationsOffset); writeInt(classDef.classDataOffset); writeInt(classDef.staticValuesOffset); return off; }
/** * Write AnnotationDirectory item into current section. * * @return real offset of item we've just written in this section. */ public int writeAnnotationsDirectory(AnnotationsDirectory annotationsDirectory) { int off = data.position(); writeInt(annotationsDirectory.classAnnotationsOffset); writeInt(annotationsDirectory.fieldAnnotations.length); writeInt(annotationsDirectory.methodAnnotations.length); writeInt(annotationsDirectory.parameterAnnotations.length); for (int[] fieldAnnotation : annotationsDirectory.fieldAnnotations) { writeInt(fieldAnnotation[0]); writeInt(fieldAnnotation[1]); } for (int[] methodAnnotation : annotationsDirectory.methodAnnotations) { writeInt(methodAnnotation[0]); writeInt(methodAnnotation[1]); } for (int[] parameterAnnotation : annotationsDirectory.parameterAnnotations) { writeInt(parameterAnnotation[0]); writeInt(parameterAnnotation[1]); } return off; }
/** * Write TypeList item into current section. * * @return real offset of item we've just written in this section. */ public int writeTypeList(TypeList typeList) { int off = data.position(); short[] types = typeList.types; writeInt(types.length); for (short type : types) { writeShort(type); } return off; }
/** * Write MethodId item into current section. * * @return real offset of item we've just written in this section. */ public int writeMethodId(MethodId methodId) { int off = data.position(); writeUnsignedShort(methodId.declaringClassIndex); writeUnsignedShort(methodId.protoIndex); writeInt(methodId.nameIndex); return off; }
/** * Write FieldId item into current section. * * @return real offset of item we've just written in this section. */ public int writeFieldId(FieldId fieldId) { int off = data.position(); writeUnsignedShort(fieldId.declaringClassIndex); writeUnsignedShort(fieldId.typeIndex); writeInt(fieldId.nameIndex); return off; }
private void writeTries(Code.Try[] tries, int[] catchHandlerOffsets) { for (Code.Try tryItem : tries) { writeInt(tryItem.startAddress); writeUnsignedShort(tryItem.instructionCount); writeUnsignedShort(catchHandlerOffsets[tryItem.catchHandlerIndex]); } }
buffer.write(DexPatchFile.MAGIC); buffer.writeShort(DexPatchFile.CURRENT_VERSION); buffer.writeInt(this.patchedDexSize); buffer.writeInt(0); buffer.writeInt(this.patchedStringIdsOffset); buffer.writeInt(this.patchedTypeIdsOffset); buffer.writeInt(this.patchedProtoIdsOffset); buffer.writeInt(this.patchedFieldIdsOffset); buffer.writeInt(this.patchedMethodIdsOffset); buffer.writeInt(this.patchedClassDefsOffset); buffer.writeInt(this.patchedMapListOffset); buffer.writeInt(this.patchedTypeListsOffset); buffer.writeInt(this.patchedAnnotationSetRefListItemsOffset); buffer.writeInt(this.patchedAnnotationSetItemsOffset); buffer.writeInt(this.patchedClassDataItemsOffset); buffer.writeInt(this.patchedCodeItemsOffset); buffer.writeInt(this.patchedStringDataItemsOffset); buffer.writeInt(this.patchedDebugInfoItemsOffset); buffer.writeInt(this.patchedAnnotationItemsOffset); buffer.writeInt(this.patchedEncodedArrayItemsOffset); buffer.writeInt(this.patchedAnnotationsDirectoryItemsOffset); buffer.write(this.oldDex.computeSignature(false)); int firstChunkOffset = buffer.position(); buffer.position(posOfFirstChunkOffsetField); buffer.writeInt(firstChunkOffset); buffer.position(firstChunkOffset);
if (newItem instanceof Integer) { buffer.writeInt((Integer) newItem); } else if (newItem instanceof TypeList) {
/** * Write ProtoId item into current section. * * @return real offset of item we've just written in this section. */ public int writeProtoId(ProtoId protoId) { int off = data.position(); writeInt(protoId.shortyIndex); writeInt(protoId.returnTypeIndex); writeInt(protoId.parametersOffset); return off; }
/** * Write AnnotationSet item into current section. * * @return real offset of item we've just written in this section. */ public int writeAnnotationSet(AnnotationSet annotationSet) { int off = data.position(); writeInt(annotationSet.annotationOffsets.length); for (int annotationOffset : annotationSet.annotationOffsets) { writeInt(annotationOffset); } return off; }
/** * Write ClassDef item into current section. * * @return real offset of item we've just written in this section. */ public int writeClassDef(ClassDef classDef) { int off = data.position(); writeInt(classDef.typeIndex); writeInt(classDef.accessFlags); writeInt(classDef.supertypeIndex); writeInt(classDef.interfacesOffset); writeInt(classDef.sourceFileIndex); writeInt(classDef.annotationsOffset); writeInt(classDef.classDataOffset); writeInt(classDef.staticValuesOffset); return off; }
/** * Write AnnotationSetRefList item into current section. * * @return real offset of item we've just written in this section. */ public int writeAnnotationSetRefList(AnnotationSetRefList annotationSetRefList) { int off = data.position(); writeInt(annotationSetRefList.annotationSetRefItems.length); for (int annotationSetRefItem : annotationSetRefList.annotationSetRefItems) { writeInt(annotationSetRefItem); } return off; }
/** * Write TypeList item into current section. * * @return real offset of item we've just written in this section. */ public int writeTypeList(TypeList typeList) { int off = data.position(); short[] types = typeList.types; writeInt(types.length); for (short type : types) { writeShort(type); } return off; }
/** * Write MethodId item into current section. * * @return real offset of item we've just written in this section. */ public int writeMethodId(MethodId methodId) { int off = data.position(); writeUnsignedShort(methodId.declaringClassIndex); writeUnsignedShort(methodId.protoIndex); writeInt(methodId.nameIndex); return off; }
/** * Write FieldId item into current section. * * @return real offset of item we've just written in this section. */ public int writeFieldId(FieldId fieldId) { int off = data.position(); writeUnsignedShort(fieldId.declaringClassIndex); writeUnsignedShort(fieldId.typeIndex); writeInt(fieldId.nameIndex); return off; }
private void writeTries(Code.Try[] tries, int[] catchHandlerOffsets) { for (Code.Try tryItem : tries) { writeInt(tryItem.startAddress); writeUnsignedShort(tryItem.instructionCount); writeUnsignedShort(catchHandlerOffsets[tryItem.catchHandlerIndex]); } }