org.jf.dexlib2.AccessFlags Java Examples
The following examples show how to use
org.jf.dexlib2.AccessFlags.
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: SmaliClassDetailLoader.java From PATDroid with Apache License 2.0 | 8 votes |
private static int translateAccessFlags(int accessFlags) { int f = 0; f |= (AccessFlags.ABSTRACT.isSet(accessFlags) ? Modifier.ABSTRACT : 0); // f |= (AccessFlags.ANNOTATION.isSet(accessFlags) ? Modifier.ANNOTATION : 0); // f |= (AccessFlags.BRIDGE.isSet(accessFlags) ? Modifier.BRIDGE : 0); // f |= (AccessFlags.CONSTRUCTOR.isSet(accessFlags) ? Modifier.CONSTRUCTOR : 0); // f |= (AccessFlags.DECLARED_SYNCHRONIZED.isSet(accessFlags) ? Modifier.DECLARED_SYNCHRONIZED : 0); // f |= (AccessFlags.ENUM.isSet(accessFlags) ? Modifier.ENUM : 0); f |= (AccessFlags.FINAL.isSet(accessFlags) ? Modifier.FINAL : 0); f |= (AccessFlags.INTERFACE.isSet(accessFlags) ? Modifier.INTERFACE : 0); f |= (AccessFlags.NATIVE.isSet(accessFlags) ? Modifier.NATIVE : 0); f |= (AccessFlags.PRIVATE.isSet(accessFlags) ? Modifier.PRIVATE : 0); f |= (AccessFlags.PROTECTED.isSet(accessFlags) ? Modifier.PROTECTED : 0); f |= (AccessFlags.PUBLIC.isSet(accessFlags) ? Modifier.PUBLIC : 0); f |= (AccessFlags.STATIC.isSet(accessFlags) ? Modifier.STATIC : 0); f |= (AccessFlags.STRICTFP.isSet(accessFlags) ? Modifier.STRICT : 0); f |= (AccessFlags.SYNCHRONIZED.isSet(accessFlags) ? Modifier.SYNCHRONIZED : 0); // f |= (AccessFlags.SYNTHETIC.isSet(accessFlags) ? Modifier.SYNTHETIC : 0); f |= (AccessFlags.TRANSIENT.isSet(accessFlags) ? Modifier.TRANSIENT : 0); // f |= (AccessFlags.VARARGS.isSet(accessFlags) ? Modifier.VARARGS : 0); f |= (AccessFlags.VOLATILE.isSet(accessFlags) ? Modifier.VOLATILE : 0); return f; }
Example #2
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL; } Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #3
Source File: MethodAnalyzer.java From HeyGirl with Apache License 2.0 | 6 votes |
private void analyzeExecuteInlineRange(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction3rmi instruction = (Instruction3rmi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC_RANGE; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT_RANGE; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL_RANGE; } Instruction3rc deodexedInstruction = new ImmutableInstruction3rc(deodexedOpcode, instruction.getStartRegister(), instruction.getRegisterCount(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #4
Source File: MethodAnalyzer.java From HeyGirl with Apache License 2.0 | 6 votes |
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL; } Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #5
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL; } Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #6
Source File: MethodAnalyzer.java From zjdroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInlineRange(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction3rmi instruction = (Instruction3rmi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC_RANGE; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT_RANGE; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL_RANGE; } Instruction3rc deodexedInstruction = new ImmutableInstruction3rc(deodexedOpcode, instruction.getStartRegister(), instruction.getRegisterCount(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #7
Source File: MethodAnalyzer.java From zjdroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInline(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction35mi instruction = (Instruction35mi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL; } Instruction35c deodexedInstruction = new ImmutableInstruction35c(deodexedOpcode, instruction.getRegisterCount(), instruction.getRegisterC(), instruction.getRegisterD(), instruction.getRegisterE(), instruction.getRegisterF(), instruction.getRegisterG(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #8
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInlineRange(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction3rmi instruction = (Instruction3rmi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC_RANGE; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT_RANGE; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL_RANGE; } Instruction3rc deodexedInstruction = new ImmutableInstruction3rc(deodexedOpcode, instruction.getStartRegister(), instruction.getRegisterCount(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #9
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 6 votes |
private void analyzeExecuteInlineRange(@Nonnull AnalyzedInstruction analyzedInstruction) { if (inlineResolver == null) { throw new AnalysisException("Cannot analyze an odexed instruction unless we are deodexing"); } Instruction3rmi instruction = (Instruction3rmi)analyzedInstruction.instruction; Method resolvedMethod = inlineResolver.resolveExecuteInline(analyzedInstruction); Opcode deodexedOpcode; int acccessFlags = resolvedMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_STATIC_RANGE; } else if (AccessFlags.PRIVATE.isSet(acccessFlags)) { deodexedOpcode = Opcode.INVOKE_DIRECT_RANGE; } else { deodexedOpcode = Opcode.INVOKE_VIRTUAL_RANGE; } Instruction3rc deodexedInstruction = new ImmutableInstruction3rc(deodexedOpcode, instruction.getStartRegister(), instruction.getRegisterCount(), resolvedMethod); analyzedInstruction.setDeodexedInstruction(deodexedInstruction); analyzeInstruction(analyzedInstruction); }
Example #10
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private static void writeParameters(IndentingWriter writer, Method method, List<? extends MethodParameter> parameters, baksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic?0:1; for (MethodParameter parameter: parameters) { String parameterType = parameter.getType(); String parameterName = parameter.getName(); Collection<? extends Annotation> annotations = parameter.getAnnotations(); if (parameterName != null || annotations.size() != 0) { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); if (parameterName != null && options.outputDebugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); } writer.write(" # "); writer.write(parameterType); writer.write("\n"); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end param\n"); } } registerNumber++; if (TypeUtils.isWideType(parameterType)) { registerNumber++; } } }
Example #11
Source File: FieldDefinition.java From HeyGirl with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example #12
Source File: ExecuteInlineInstruction.java From JAADAS with GNU General Public License v3.0 | 5 votes |
@Override public void jimplify(DexBody body) { int acccessFlags = targetMethod.getAccessFlags(); if (AccessFlags.STATIC.isSet(acccessFlags)) jimplifyStatic(body); else if (AccessFlags.PRIVATE.isSet(acccessFlags)) jimplifySpecial(body); else jimplifyVirtual(body); }
Example #13
Source File: FieldDefinition.java From zjdroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example #14
Source File: MethodDefinition.java From zjdroid with Apache License 2.0 | 5 votes |
private static void writeParameters(IndentingWriter writer, Method method, List<? extends MethodParameter> parameters, baksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic?0:1; for (MethodParameter parameter: parameters) { String parameterType = parameter.getType(); String parameterName = parameter.getName(); Collection<? extends Annotation> annotations = parameter.getAnnotations(); if (parameterName != null || annotations.size() != 0) { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); if (parameterName != null && options.outputDebugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); } writer.write(" # "); writer.write(parameterType); writer.write("\n"); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end param\n"); } } registerNumber++; if (TypeUtils.isWideType(parameterType)) { registerNumber++; } } }
Example #15
Source File: MethodDefinition.java From zjdroid with Apache License 2.0 | 5 votes |
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
Example #16
Source File: MethodDefinition.java From HeyGirl with Apache License 2.0 | 5 votes |
private static void writeParameters(IndentingWriter writer, Method method, List<? extends MethodParameter> parameters, baksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic?0:1; for (MethodParameter parameter: parameters) { String parameterType = parameter.getType(); String parameterName = parameter.getName(); Collection<? extends Annotation> annotations = parameter.getAnnotations(); if (parameterName != null || annotations.size() != 0) { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); if (parameterName != null && options.outputDebugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); } writer.write(" # "); writer.write(parameterType); writer.write("\n"); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end param\n"); } } registerNumber++; if (TypeUtils.isWideType(parameterType)) { registerNumber++; } } }
Example #17
Source File: SmaliClassDetailLoader.java From PATDroid with Apache License 2.0 | 5 votes |
private MethodInfo translateMethod(ClassInfo ci, Method method, IdentityHashMap<MethodInfo, MethodImplementation> collector) { final ClassInfo retType = Dalvik.findOrCreateClass(ci.scope, method.getReturnType()); final ImmutableList<ClassInfo> paramTypes = findOrCreateClasses(ci.scope, method.getParameterTypes()); final MethodSignature signature = new MethodSignature(method.getName(), paramTypes); final FullMethodSignature fullSignature = new FullMethodSignature(retType, signature); final int accessFlags = translateAccessFlags(method.getAccessFlags()); final MethodInfo mi = new MethodInfo(ci, fullSignature, accessFlags, AccessFlags.SYNTHETIC.isSet(method.getAccessFlags())); Log.msg("Translating method: %s", mi.toString()); collector.put(mi, method.getImplementation()); return mi; }
Example #18
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 5 votes |
private boolean canAccessClass(@Nonnull ClassDef accessorClassDef, @Nonnull ClassDef accesseeClassDef) { if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) { return true; } // Classes can only be public or package private. Any private or protected inner classes are actually // package private. return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorClassDef.getType())); }
Example #19
Source File: MethodAnalyzer.java From zjdroid with Apache License 2.0 | 5 votes |
private boolean canAccessClass(@Nonnull ClassDef accessorClassDef, @Nonnull ClassDef accesseeClassDef) { if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) { return true; } // Classes can only be public or package private. Any private or protected inner classes are actually // package private. return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorClassDef.getType())); }
Example #20
Source File: FieldDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example #21
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
Example #22
Source File: MethodAnalyzer.java From ZjDroid with Apache License 2.0 | 5 votes |
private boolean canAccessClass(@Nonnull ClassDef accessorClassDef, @Nonnull ClassDef accesseeClassDef) { if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) { return true; } // Classes can only be public or package private. Any private or protected inner classes are actually // package private. return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorClassDef.getType())); }
Example #23
Source File: MethodDefinition.java From atlas with Apache License 2.0 | 5 votes |
private static void writeParameters(IndentingWriter writer, Method method, List<? extends MethodParameter> parameters, BaksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic ? 0 : 1; for (MethodParameter parameter : parameters) { String parameterType = parameter.getType(); String parameterName = parameter.getName(); Collection<? extends Annotation> annotations = parameter.getAnnotations(); if (parameterName != null || annotations.size() != 0) { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); if (parameterName != null && options.debugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); } writer.write(" # "); writer.write(parameterType); writer.write("\n"); if (annotations.size() > 0) { writer.indent(4); String containingClass = null; if (options.implicitReferences) { containingClass = method.getDefiningClass(); } AnnotationFormatter.writeTo(writer, annotations, containingClass); writer.deindent(4); writer.write(".end param\n"); } } registerNumber++; if (TypeUtils.isWideType(parameterType)) { registerNumber++; } } }
Example #24
Source File: MethodDefinition.java From atlas with Apache License 2.0 | 5 votes |
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag : AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
Example #25
Source File: MethodAnalyzer.java From HeyGirl with Apache License 2.0 | 5 votes |
private boolean canAccessClass(@Nonnull ClassDef accessorClassDef, @Nonnull ClassDef accesseeClassDef) { if (AccessFlags.PUBLIC.isSet(accesseeClassDef.getAccessFlags())) { return true; } // Classes can only be public or package private. Any private or protected inner classes are actually // package private. return getPackage(accesseeClassDef.getType()).equals(getPackage(accessorClassDef.getType())); }
Example #26
Source File: PatchFieldTool.java From atlas with Apache License 2.0 | 5 votes |
public static DexFile addField(DexFile dexFile, final String className, final Field field) { DexRewriter rewriter = new DexRewriter(new RewriterModule() { @Nonnull @Override public Rewriter<ClassDef> getClassDefRewriter(@Nonnull Rewriters rewriters) { return new ClassDefRewriter(rewriters) { @Nonnull @Override public ClassDef rewrite(@Nonnull ClassDef classDef) { if (classDef.getType().equals(className)) { return new RewrittenClassDef(classDef) { @Nonnull @Override public Iterable<? extends Field> getInstanceFields() { if ((field.getAccessFlags() & AccessFlags.STATIC.getValue()) == 0) { return Iterables.concat(super.getInstanceFields(), ImmutableList.of(field)); } return super.getInstanceFields(); } @Nonnull @Override public Iterable<? extends Field> getStaticFields() { if ((field.getAccessFlags() & AccessFlags.STATIC.getValue()) != 0) { return Iterables.concat(super.getStaticFields(), ImmutableList.of(field)); } return super.getStaticFields(); } }; } return super.rewrite(classDef); } }; } }); return rewriter.rewriteDexFile(dexFile); }
Example #27
Source File: MethodDefinition.java From HeyGirl with Apache License 2.0 | 5 votes |
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
Example #28
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private static void writeAccessFlags(IndentingWriter writer, int accessFlags) throws IOException { for (AccessFlags accessFlag: AccessFlags.getAccessFlagsForMethod(accessFlags)) { writer.write(accessFlag.toString()); writer.write(' '); } }
Example #29
Source File: FieldDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
public static void writeTo(IndentingWriter writer, Field field, boolean setInStaticConstructor) throws IOException { EncodedValue initialValue = field.getInitialValue(); int accessFlags = field.getAccessFlags(); if (setInStaticConstructor && AccessFlags.STATIC.isSet(accessFlags) && AccessFlags.FINAL.isSet(accessFlags) && initialValue != null) { if (!EncodedValueUtils.isDefaultValue(initialValue)) { writer.write("# The value of this static final field might be set in the static constructor\n"); } else { // don't write out the default initial value for static final fields that get set in the static // constructor initialValue = null; } } writer.write(".field "); writeAccessFlags(writer, field.getAccessFlags()); writer.write(field.getName()); writer.write(':'); writer.write(field.getType()); if (initialValue != null) { writer.write(" = "); EncodedValueAdaptor.writeTo(writer, initialValue); } writer.write('\n'); Collection<? extends Annotation> annotations = field.getAnnotations(); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end field\n"); } }
Example #30
Source File: MethodDefinition.java From ZjDroid with Apache License 2.0 | 5 votes |
private static void writeParameters(IndentingWriter writer, Method method, List<? extends MethodParameter> parameters, baksmaliOptions options) throws IOException { boolean isStatic = AccessFlags.STATIC.isSet(method.getAccessFlags()); int registerNumber = isStatic?0:1; for (MethodParameter parameter: parameters) { String parameterType = parameter.getType(); String parameterName = parameter.getName(); Collection<? extends Annotation> annotations = parameter.getAnnotations(); if (parameterName != null || annotations.size() != 0) { writer.write(".param p"); writer.printSignedIntAsDec(registerNumber); if (parameterName != null && options.outputDebugInfo) { writer.write(", "); ReferenceFormatter.writeStringReference(writer, parameterName); } writer.write(" # "); writer.write(parameterType); writer.write("\n"); if (annotations.size() > 0) { writer.indent(4); AnnotationFormatter.writeTo(writer, annotations); writer.deindent(4); writer.write(".end param\n"); } } registerNumber++; if (TypeUtils.isWideType(parameterType)) { registerNumber++; } } }