public void writeHeader(DexBuffer.Section out) throws IOException { out.write(DexFormat.apiToMagic(DexFormat.API_CURRENT).getBytes("UTF-8")); out.writeInt(checksum); out.write(signature); out.writeInt(fileSize); out.writeInt(SizeOf.HEADER_ITEM); out.writeInt(DexFormat.ENDIAN_TAG); out.writeInt(linkSize); out.writeInt(linkOff); out.writeInt(mapList.off); out.writeInt(stringIds.size); out.writeInt(stringIds.off); out.writeInt(typeIds.size); out.writeInt(typeIds.off); out.writeInt(protoIds.size); out.writeInt(protoIds.off); out.writeInt(fieldIds.size); out.writeInt(fieldIds.off); out.writeInt(methodIds.size); out.writeInt(methodIds.off); out.writeInt(classDefs.size); out.writeInt(classDefs.off); out.writeInt(dataSize); out.writeInt(dataOff); }
annotationsDirectoryOut.writeInt(classAnnotationsOffset); annotationsDirectoryOut.writeInt(fieldsSize); annotationsDirectoryOut.writeInt(methodsSize); annotationsDirectoryOut.writeInt(parameterListSize); annotationsDirectoryOut.writeInt(indexMap.adjustField(directoryIn.readInt())); annotationsDirectoryOut.writeInt(indexMap.adjustAnnotationSet(directoryIn.readInt())); annotationsDirectoryOut.writeInt(indexMap.adjustMethod(directoryIn.readInt())); annotationsDirectoryOut.writeInt( indexMap.adjustAnnotationSet(directoryIn.readInt())); annotationsDirectoryOut.writeInt(indexMap.adjustMethod(directoryIn.readInt())); annotationsDirectoryOut.writeInt(annotationSetRefListOut.getPosition()); DexBuffer.Section refListIn = in.open(directoryIn.readInt()); annotationSetRefListOut.writeInt(parameterCount); for (int p = 0; p < parameterCount; p++) { annotationSetRefListOut.writeInt(indexMap.adjustAnnotationSet(refListIn.readInt()));
codeOut.writeInt(0); : bInstructionTransformer; short[] newInstructions = transformer.transform(instructions); codeOut.writeInt(newInstructions.length); codeOut.write(newInstructions); codeOut.writeInt(tryItem.getStartAddress()); codeOut.writeUnsignedShort(tryItem.getInstructionCount()); codeOut.writeUnsignedShort(tryItem.getHandlerOffset());
idsDefsOut.writeInt(classDef.getTypeIndex()); idsDefsOut.writeInt(classDef.getAccessFlags()); idsDefsOut.writeInt(classDef.getSupertypeIndex()); idsDefsOut.writeInt(classDef.getInterfacesOffset()); idsDefsOut.writeInt(sourceFileIndex); idsDefsOut.writeInt(indexMap.adjustAnnotationDirectory(annotationsOff)); idsDefsOut.writeInt(0); } else { idsDefsOut.writeInt(classDataOut.getPosition()); ClassData classData = in.readClassData(classDef); transformClassData(in, classData, indexMap); idsDefsOut.writeInt(0); } else { DexBuffer.Section staticValuesIn = in.open(staticValuesOff); idsDefsOut.writeInt(encodedArrayOut.getPosition()); transformStaticValues(staticValuesIn, indexMap);
public void writeMap(DexBuffer.Section out) throws IOException { int count = 0; for (Section section : sections) { if (section.exists()) { count++; } } out.writeInt(count); for (Section section : sections) { if (section.exists()) { out.writeShort(section.type); out.writeShort((short) 0); out.writeInt(section.size); out.writeInt(section.off); } } }
/** * Transform all annotations on a single type, member or parameter. */ private void transformAnnotationSet(IndexMap indexMap, DexBuffer.Section setIn) { contentsOut.annotationSets.size++; annotationSetOut.assertFourByteAligned(); indexMap.putAnnotationSetOffset(setIn.getPosition(), annotationSetOut.getPosition()); int size = setIn.readInt(); annotationSetOut.writeInt(size); for (int j = 0; j < size; j++) { annotationSetOut.writeInt(indexMap.adjustAnnotation(setIn.readInt())); } }
@Override void write(Integer value) { idsDefsOut.writeInt(value); } }.mergeSorted();
public void writeTo(DexBuffer.Section out) { out.writeUnsignedShort(declaringClassIndex); out.writeUnsignedShort(typeIndex); out.writeInt(nameIndex); }
/** * Generates the signature and checksum of the dex file {@code out} and * writes them to the file. */ public void writeHashes(DexBuffer dex) throws IOException { byte[] signature = computeSignature(dex); dex.open(SIGNATURE_OFFSET).write(signature); int checksum = computeChecksum(dex); dex.open(CHECKSUM_OFFSET).writeInt(checksum); } }
public void writeTo(DexBuffer.Section out) { out.writeUnsignedShort(declaringClassIndex); out.writeUnsignedShort(protoIndex); out.writeInt(nameIndex); }
@Override void write(String value) { contentsOut.stringDatas.size++; idsDefsOut.writeInt(stringDataOut.getPosition()); stringDataOut.writeStringData(value); } }.mergeSorted();
public void writeTypeList(TypeList typeList) { short[] types = typeList.getTypes(); writeInt(types.length); for (short type : types) { writeShort(type); } alignToFourBytes(); }