public static String getReferenceAnnotation(DexBackedDexFile dexFile, int fieldIndex) { try { String fieldString = asString(dexFile, fieldIndex); return String.format("field_id_item[%d]: %s", fieldIndex, fieldString); } catch (Exception ex) { ex.printStackTrace(System.err); } return String.format("field_id_item[%d]", fieldIndex); }
private int annotateEncodedField(@Nonnull AnnotatedBytes out, @Nonnull RawDexFile dexFile, @Nonnull DexReader reader, int previousIndex) { // large values may be used for the index delta, which cause the cumulative index to overflow upon // addition, effectively allowing out of order entries. int indexDelta = reader.readLargeUleb128(); int fieldIndex = previousIndex + indexDelta; out.annotateTo(reader.getOffset(), "field_idx_diff = %d: %s", indexDelta, FieldIdItem.getReferenceAnnotation(dexFile, fieldIndex)); int accessFlags = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "access_flags = 0x%x: %s", accessFlags, Joiner.on('|').join(AccessFlags.getAccessFlagsForField(accessFlags))); return fieldIndex; }
break; case ItemType.FIELD_ID_ITEM: annotators.put(mapItem.getType(), FieldIdItem.makeAnnotator(this, mapItem)); break; case ItemType.METHOD_ID_ITEM:
break; case ItemType.FIELD_ID_ITEM: annotators.put(mapItem.getType(), FieldIdItem.makeAnnotator(this, mapItem)); break; case ItemType.METHOD_ID_ITEM:
@Nonnull public static String getReferenceAnnotation(@Nonnull DexBackedDexFile dexFile, int fieldIndex) { try { String fieldString = asString(dexFile, fieldIndex); return String.format("field_id_item[%d]: %s", fieldIndex, fieldString); } catch (Exception ex) { ex.printStackTrace(System.err); } return String.format("field_id_item[%d]", fieldIndex); }
private int annotateEncodedField(@Nonnull AnnotatedBytes out, @Nonnull RawDexFile dexFile, @Nonnull DexReader reader, int previousIndex) { // large values may be used for the index delta, which cause the cumulative index to overflow upon // addition, effectively allowing out of order entries. int indexDelta = reader.readLargeUleb128(); int fieldIndex = previousIndex + indexDelta; out.annotateTo(reader.getOffset(), "field_idx_diff = %d: %s", indexDelta, FieldIdItem.getReferenceAnnotation(dexFile, fieldIndex)); int accessFlags = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "access_flags = 0x%x: %s", accessFlags, Joiner.on('|').join(AccessFlags.getAccessFlagsForField(accessFlags))); return fieldIndex; }
break; case ItemType.FIELD_ID_ITEM: annotators.put(mapItem.getType(), FieldIdItem.makeAnnotator(this, mapItem)); break; case ItemType.METHOD_ID_ITEM:
@Nonnull public static String getReferenceAnnotation(@Nonnull DexBackedDexFile dexFile, int fieldIndex) { try { String fieldString = asString(dexFile, fieldIndex); return String.format("field_id_item[%d]: %s", fieldIndex, fieldString); } catch (Exception ex) { ex.printStackTrace(System.err); } return String.format("field_id_item[%d]", fieldIndex); }
private int annotateEncodedField(@Nonnull AnnotatedBytes out, @Nonnull RawDexFile dexFile, @Nonnull DexReader reader, int previousIndex) { // large values may be used for the index delta, which cause the cumulative index to overflow upon // addition, effectively allowing out of order entries. int indexDelta = reader.readLargeUleb128(); int fieldIndex = previousIndex + indexDelta; out.annotateTo(reader.getOffset(), "field_idx_diff = %d: %s", indexDelta, FieldIdItem.getReferenceAnnotation(dexFile, fieldIndex)); int accessFlags = reader.readSmallUleb128(); out.annotateTo(reader.getOffset(), "access_flags = 0x%x: %s", accessFlags, Joiner.on('|').join(AccessFlags.getAccessFlagsForField(accessFlags))); return fieldIndex; }
@Nonnull public static String getReferenceAnnotation(@Nonnull DexBackedDexFile dexFile, int fieldIndex) { try { String fieldString = asString(dexFile, fieldIndex); return String.format("field_id_item[%d]: %s", fieldIndex, fieldString); } catch (Exception ex) { ex.printStackTrace(System.err); } return String.format("field_id_item[%d]", fieldIndex); }
case ValueType.FIELD: int fieldIndex = reader.readSizedSmallUint(valueArg+1); return FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex); case ValueType.METHOD: int methodIndex = reader.readSizedSmallUint(valueArg+1); case ValueType.ENUM: fieldIndex = reader.readSizedSmallUint(valueArg+1); return FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex); case ValueType.ARRAY: case ValueType.ANNOTATION:
public static String[] getFields(@Nonnull RawDexFile dexFile) { MapItem mapItem = dexFile.getMapItemForSection(ItemType.FIELD_ID_ITEM); if (mapItem == null) { return new String[0]; } int fieldCount = mapItem.getItemCount(); String[] ret = new String[fieldCount]; for (int i=0; i<fieldCount; i++) { ret[i] = asString(dexFile, i); } return ret; } }
case ValueType.FIELD: int fieldIndex = reader.readSizedSmallUint(valueArg+1); return FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex); case ValueType.METHOD: int methodIndex = reader.readSizedSmallUint(valueArg+1); case ValueType.ENUM: fieldIndex = reader.readSizedSmallUint(valueArg+1); return FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex); case ValueType.ARRAY: case ValueType.ANNOTATION:
public static String[] getFields(@Nonnull RawDexFile dexFile) { MapItem mapItem = dexFile.getMapItemForSection(ItemType.FIELD_ID_ITEM); if (mapItem == null) { return new String[0]; } int fieldCount = mapItem.getItemCount(); String[] ret = new String[fieldCount]; for (int i=0; i<fieldCount; i++) { ret[i] = asString(dexFile, i); } return ret; } }
@Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int methodHandleType = dexFile.readUshort(out.getCursor()); out.annotate(2, "type = %s", MethodHandleType.toString(methodHandleType)); out.annotate(2, "unused"); int fieldOrMethodId = dexFile.readUshort(out.getCursor()); String fieldOrMethodDescriptor; switch (methodHandleType) { case MethodHandleType.STATIC_PUT: case MethodHandleType.STATIC_GET: case MethodHandleType.INSTANCE_PUT: case MethodHandleType.INSTANCE_GET: fieldOrMethodDescriptor = FieldIdItem.getReferenceAnnotation(dexFile, fieldOrMethodId); break; case MethodHandleType.INVOKE_STATIC: case MethodHandleType.INVOKE_INSTANCE: case MethodHandleType.INVOKE_CONSTRUCTOR: case MethodHandleType.INVOKE_DIRECT: case MethodHandleType.INVOKE_INTERFACE: fieldOrMethodDescriptor = MethodIdItem.getReferenceAnnotation(dexFile, fieldOrMethodId); break; default: throw new ExceptionWithContext("Invalid method handle type: %d", methodHandleType); } out.annotate(2, "field_or_method_id = %s", fieldOrMethodDescriptor); out.annotate(2, "unused"); } };
public static String[] getFields(@Nonnull RawDexFile dexFile) { MapItem mapItem = dexFile.getMapItemForSection(ItemType.FIELD_ID_ITEM); if (mapItem == null) { return new String[0]; } int fieldCount = mapItem.getItemCount(); String[] ret = new String[fieldCount]; for (int i=0; i<fieldCount; i++) { ret[i] = asString(dexFile, i); } return ret; } }
@Override protected void annotateItem(@Nonnull AnnotatedBytes out, int itemIndex, @Nullable String itemIdentity) { int methodHandleType = dexFile.readUshort(out.getCursor()); out.annotate(2, "type = %s", MethodHandleType.toString(methodHandleType)); out.annotate(2, "unused"); int fieldOrMethodId = dexFile.readUshort(out.getCursor()); String fieldOrMethodDescriptor; switch (methodHandleType) { case MethodHandleType.STATIC_PUT: case MethodHandleType.STATIC_GET: case MethodHandleType.INSTANCE_PUT: case MethodHandleType.INSTANCE_GET: fieldOrMethodDescriptor = FieldIdItem.getReferenceAnnotation(dexFile, fieldOrMethodId); break; case MethodHandleType.INVOKE_STATIC: case MethodHandleType.INVOKE_INSTANCE: case MethodHandleType.INVOKE_CONSTRUCTOR: case MethodHandleType.INVOKE_DIRECT: case MethodHandleType.INVOKE_INTERFACE: fieldOrMethodDescriptor = MethodIdItem.getReferenceAnnotation(dexFile, fieldOrMethodId); break; default: throw new ExceptionWithContext("Invalid method handle type: %d", methodHandleType); } out.annotate(2, "field_or_method_id = %s", fieldOrMethodDescriptor); out.annotate(2, "unused"); } };
public static String[] getFields(RawDexFile dexFile) { MapItem mapItem = dexFile.getMapItemForSection(ItemType.FIELD_ID_ITEM); if (mapItem == null) { return new String[0]; } int fieldCount = mapItem.getItemCount(); String[] ret = new String[fieldCount]; for (int i = 0; i < fieldCount; i++) { ret[i] = asString(dexFile, i); } return ret; } }
out.annotate(1, "valueArg = %d, valueType = 0x%x: field", valueArg, valueType); int fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1a: out.annotate(1, "valueArg = %d, valueType = 0x%x: enum", valueArg, valueType); fieldIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", FieldIdItem.getReferenceAnnotation(reader.dexBuf, fieldIndex)); break; case 0x1c:
out.indent(); int fieldIndex = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "%s", FieldIdItem.getReferenceAnnotation(dexFile, fieldIndex)); int annotationOffset = dexFile.readSmallUint(out.getCursor()); out.annotate(4, "%s", AnnotationSetItem.getReferenceAnnotation(dexFile, annotationOffset));