Java Code Examples for org.jf.dexlib2.dexbacked.DexReader#readSizedSmallUint()
The following examples show how to use
org.jf.dexlib2.dexbacked.DexReader#readSizedSmallUint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DexBackedTypeEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public DexBackedTypeEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; typeIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 2
Source File: DexBackedEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
@Nonnull public static EncodedValue readFrom(@Nonnull DexReader reader) { int startOffset = reader.getOffset(); try { int b = reader.readUbyte(); int valueType = b & 0x1f; int valueArg = b >>> 5; switch (valueType) { case ValueType.BYTE: Preconditions.checkValueArg(valueArg, 0); return new ImmutableByteEncodedValue((byte)reader.readByte()); case ValueType.SHORT: Preconditions.checkValueArg(valueArg, 1); return new ImmutableShortEncodedValue((short)reader.readSizedInt(valueArg + 1)); case ValueType.CHAR: Preconditions.checkValueArg(valueArg, 1); return new ImmutableCharEncodedValue((char)reader.readSizedSmallUint(valueArg + 1)); case ValueType.INT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableIntEncodedValue(reader.readSizedInt(valueArg + 1)); case ValueType.LONG: Preconditions.checkValueArg(valueArg, 7); return new ImmutableLongEncodedValue(reader.readSizedLong(valueArg + 1)); case ValueType.FLOAT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableFloatEncodedValue(Float.intBitsToFloat( reader.readSizedRightExtendedInt(valueArg + 1))); case ValueType.DOUBLE: Preconditions.checkValueArg(valueArg, 7); return new ImmutableDoubleEncodedValue(Double.longBitsToDouble( reader.readSizedRightExtendedLong(valueArg + 1))); case ValueType.STRING: Preconditions.checkValueArg(valueArg, 3); return new DexBackedStringEncodedValue(reader, valueArg); case ValueType.TYPE: Preconditions.checkValueArg(valueArg, 3); return new DexBackedTypeEncodedValue(reader, valueArg); case ValueType.FIELD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedFieldEncodedValue(reader, valueArg); case ValueType.METHOD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedMethodEncodedValue(reader, valueArg); case ValueType.ENUM: Preconditions.checkValueArg(valueArg, 3); return new DexBackedEnumEncodedValue(reader, valueArg); case ValueType.ARRAY: Preconditions.checkValueArg(valueArg, 0); return new DexBackedArrayEncodedValue(reader); case ValueType.ANNOTATION: Preconditions.checkValueArg(valueArg, 0); return new DexBackedAnnotationEncodedValue(reader); case ValueType.NULL: Preconditions.checkValueArg(valueArg, 0); return ImmutableNullEncodedValue.INSTANCE; case ValueType.BOOLEAN: Preconditions.checkValueArg(valueArg, 1); return ImmutableBooleanEncodedValue.forBoolean(valueArg == 1); default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); } } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, "Error while reading encoded value at offset 0x%x", startOffset); } }
Example 3
Source File: DexBackedStringEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public DexBackedStringEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; stringIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 4
Source File: DexBackedTypeEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public DexBackedTypeEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; typeIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 5
Source File: DexBackedMethodEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public DexBackedMethodEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; MethodIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 6
Source File: EncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: 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: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: 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.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 7
Source File: DexBackedFieldEncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; fieldIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 8
Source File: EncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: 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: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: 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.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 9
Source File: DexBackedEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
@Nonnull public static EncodedValue readFrom(@Nonnull DexReader reader) { int startOffset = reader.getOffset(); try { int b = reader.readUbyte(); int valueType = b & 0x1f; int valueArg = b >>> 5; switch (valueType) { case ValueType.BYTE: Preconditions.checkValueArg(valueArg, 0); return new ImmutableByteEncodedValue((byte)reader.readByte()); case ValueType.SHORT: Preconditions.checkValueArg(valueArg, 1); return new ImmutableShortEncodedValue((short)reader.readSizedInt(valueArg + 1)); case ValueType.CHAR: Preconditions.checkValueArg(valueArg, 1); return new ImmutableCharEncodedValue((char)reader.readSizedSmallUint(valueArg + 1)); case ValueType.INT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableIntEncodedValue(reader.readSizedInt(valueArg + 1)); case ValueType.LONG: Preconditions.checkValueArg(valueArg, 7); return new ImmutableLongEncodedValue(reader.readSizedLong(valueArg + 1)); case ValueType.FLOAT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableFloatEncodedValue(Float.intBitsToFloat( reader.readSizedRightExtendedInt(valueArg + 1))); case ValueType.DOUBLE: Preconditions.checkValueArg(valueArg, 7); return new ImmutableDoubleEncodedValue(Double.longBitsToDouble( reader.readSizedRightExtendedLong(valueArg + 1))); case ValueType.STRING: Preconditions.checkValueArg(valueArg, 3); return new DexBackedStringEncodedValue(reader, valueArg); case ValueType.TYPE: Preconditions.checkValueArg(valueArg, 3); return new DexBackedTypeEncodedValue(reader, valueArg); case ValueType.FIELD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedFieldEncodedValue(reader, valueArg); case ValueType.METHOD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedMethodEncodedValue(reader, valueArg); case ValueType.ENUM: Preconditions.checkValueArg(valueArg, 3); return new DexBackedEnumEncodedValue(reader, valueArg); case ValueType.ARRAY: Preconditions.checkValueArg(valueArg, 0); return new DexBackedArrayEncodedValue(reader); case ValueType.ANNOTATION: Preconditions.checkValueArg(valueArg, 0); return new DexBackedAnnotationEncodedValue(reader); case ValueType.NULL: Preconditions.checkValueArg(valueArg, 0); return ImmutableNullEncodedValue.INSTANCE; case ValueType.BOOLEAN: Preconditions.checkValueArg(valueArg, 1); return ImmutableBooleanEncodedValue.forBoolean(valueArg == 1); default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); } } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, "Error while reading encoded value at offset 0x%x", startOffset); } }
Example 10
Source File: DexBackedStringEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public DexBackedStringEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; stringIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 11
Source File: DexBackedFieldEncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; fieldIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 12
Source File: DexBackedMethodEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public DexBackedMethodEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; MethodIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 13
Source File: DexBackedEnumEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public DexBackedEnumEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; fieldIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 14
Source File: DexBackedFieldEncodedValue.java From zjdroid with Apache License 2.0 | 4 votes |
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; fieldIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 15
Source File: EncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: 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: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: 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.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 16
Source File: DexBackedEncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull public static EncodedValue readFrom(@Nonnull DexReader reader) { int startOffset = reader.getOffset(); try { int b = reader.readUbyte(); int valueType = b & 0x1f; int valueArg = b >>> 5; switch (valueType) { case ValueType.BYTE: Preconditions.checkValueArg(valueArg, 0); return new ImmutableByteEncodedValue((byte)reader.readByte()); case ValueType.SHORT: Preconditions.checkValueArg(valueArg, 1); return new ImmutableShortEncodedValue((short)reader.readSizedInt(valueArg + 1)); case ValueType.CHAR: Preconditions.checkValueArg(valueArg, 1); return new ImmutableCharEncodedValue((char)reader.readSizedSmallUint(valueArg + 1)); case ValueType.INT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableIntEncodedValue(reader.readSizedInt(valueArg + 1)); case ValueType.LONG: Preconditions.checkValueArg(valueArg, 7); return new ImmutableLongEncodedValue(reader.readSizedLong(valueArg + 1)); case ValueType.FLOAT: Preconditions.checkValueArg(valueArg, 3); return new ImmutableFloatEncodedValue(Float.intBitsToFloat( reader.readSizedRightExtendedInt(valueArg + 1))); case ValueType.DOUBLE: Preconditions.checkValueArg(valueArg, 7); return new ImmutableDoubleEncodedValue(Double.longBitsToDouble( reader.readSizedRightExtendedLong(valueArg + 1))); case ValueType.STRING: Preconditions.checkValueArg(valueArg, 3); return new DexBackedStringEncodedValue(reader, valueArg); case ValueType.TYPE: Preconditions.checkValueArg(valueArg, 3); return new DexBackedTypeEncodedValue(reader, valueArg); case ValueType.FIELD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedFieldEncodedValue(reader, valueArg); case ValueType.METHOD: Preconditions.checkValueArg(valueArg, 3); return new DexBackedMethodEncodedValue(reader, valueArg); case ValueType.ENUM: Preconditions.checkValueArg(valueArg, 3); return new DexBackedEnumEncodedValue(reader, valueArg); case ValueType.ARRAY: Preconditions.checkValueArg(valueArg, 0); return new DexBackedArrayEncodedValue(reader); case ValueType.ANNOTATION: Preconditions.checkValueArg(valueArg, 0); return new DexBackedAnnotationEncodedValue(reader); case ValueType.NULL: Preconditions.checkValueArg(valueArg, 0); return ImmutableNullEncodedValue.INSTANCE; case ValueType.BOOLEAN: Preconditions.checkValueArg(valueArg, 1); return ImmutableBooleanEncodedValue.forBoolean(valueArg == 1); default: throw new ExceptionWithContext("Invalid encoded_value type: 0x%x", valueType); } } catch (Exception ex) { throw ExceptionWithContext.withContext(ex, "Error while reading encoded value at offset 0x%x", startOffset); } }
Example 17
Source File: EncodedValue.java From HeyGirl with Apache License 2.0 | 4 votes |
public static void annotateEncodedValue(@Nonnull AnnotatedBytes out, @Nonnull DexReader reader) { int valueArgType = reader.readUbyte(); int valueArg = valueArgType >>> 5; int valueType = valueArgType & 0x1f; switch (valueType) { case 0x00: out.annotate(1, "valueArg = %d, valueType = 0x%x: byte", valueArg, valueType); int intValue = reader.readByte(); out.annotate(1, "value = 0x%x", intValue); break; case 0x02: out.annotate(1, "valueArg = %d, valueType = 0x%x: short", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg + 1, "value = 0x%x", intValue); break; case 0x03: out.annotate(1, "valueArg = %d, valueType = 0x%x: char", valueArg, valueType); intValue = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x04: out.annotate(1, "valueArg = %d, valueType = 0x%x: int", valueArg, valueType); intValue = reader.readSizedInt(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", intValue); break; case 0x06: out.annotate(1, "valueArg = %d, valueType = 0x%x: long", valueArg, valueType); long longValue = reader.readSizedLong(valueArg+1); out.annotate(valueArg+1, "value = 0x%x", longValue); break; case 0x10: out.annotate(1, "valueArg = %d, valueType = 0x%x: float", valueArg, valueType); float floatValue = Float.intBitsToFloat(reader.readSizedRightExtendedInt(valueArg + 1)); out.annotate(valueArg+1, "value = %f", floatValue); break; case 0x11: out.annotate(1, "valueArg = %d, valueType = 0x%x: double", valueArg, valueType); double doubleValue = Double.longBitsToDouble(reader.readSizedRightExtendedLong(valueArg + 1)); out.annotate(valueArg+1, "value = %f", doubleValue); break; case 0x17: out.annotate(1, "valueArg = %d, valueType = 0x%x: string", valueArg, valueType); int stringIndex = reader.readSizedSmallUint(valueArg + 1); out.annotate(valueArg+1, "value = %s", StringIdItem.getReferenceAnnotation(reader.dexBuf, stringIndex, true)); break; case 0x18: out.annotate(1, "valueArg = %d, valueType = 0x%x: type", valueArg, valueType); int typeIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", TypeIdItem.getReferenceAnnotation(reader.dexBuf, typeIndex)); break; case 0x19: 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: method", valueArg, valueType); int methodIndex = reader.readSizedSmallUint(valueArg+1); out.annotate(valueArg+1, "value = %s", MethodIdItem.getReferenceAnnotation(reader.dexBuf, methodIndex)); break; case 0x1b: 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.annotate(1, "valueArg = %d, valueType = 0x%x: array", valueArg, valueType); annotateEncodedArray(out, reader); break; case 0x1d: out.annotate(1, "valueArg = %d, valueType = 0x%x: annotation", valueArg, valueType); annotateEncodedAnnotation(out, reader); break; case 0x1e: out.annotate(1, "valueArg = %d, valueType = 0x%x: null", valueArg, valueType); break; case 0x1f: out.annotate(1, "valueArg = %d, valueType = 0x%x: boolean, value=%s", valueArg, valueType, valueArg==1); break; default: throw new ExceptionWithContext("Invalid encoded value type 0x%x at offset 0x%x", valueType, out.getCursor()); } }
Example 18
Source File: DexBackedFieldEncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public DexBackedFieldEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; fieldIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 19
Source File: DexBackedMethodEncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public DexBackedMethodEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; MethodIndex = reader.readSizedSmallUint(valueArg + 1); }
Example 20
Source File: DexBackedStringEncodedValue.java From ZjDroid with Apache License 2.0 | 4 votes |
public DexBackedStringEncodedValue(@Nonnull DexReader reader, int valueArg) { this.dexFile = reader.dexBuf; stringIndex = reader.readSizedSmallUint(valueArg + 1); }