org.jf.dexlib2.iface.reference.Reference Java Examples

The following examples show how to use org.jf.dexlib2.iface.reference.Reference. 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 Project: ZjDroid   Author: KB5201314   File: MethodAnalyzer.java    License: Apache License 2.0 6 votes vote down vote up
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
Example #2
Source Project: ZjDroid   Author: KB5201314   File: BuilderInstruction35c.java    License: Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(registerCount);
    this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
    this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
    this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
    this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
    this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
    this.reference = reference;
}
 
Example #3
Source Project: atlas   Author: alibaba   File: ReferenceFormatter.java    License: Apache License 2.0 6 votes vote down vote up
public static void writeReference(IndentingWriter writer, int referenceType,
                                  Reference reference) throws IOException {
    switch (referenceType) {
        case ReferenceType.STRING:
            writeStringReference(writer, ((StringReference)reference).getString());
            return;
        case ReferenceType.TYPE:
            writer.write(((TypeReference)reference).getType());
            return;
        case ReferenceType.METHOD:
            ReferenceUtil.writeMethodDescriptor(writer, (MethodReference) reference);
            return;
        case ReferenceType.FIELD:
            ReferenceUtil.writeFieldDescriptor(writer, (FieldReference)reference);
            return;
        default:
            throw new IllegalStateException("Unknown reference type");
    }
}
 
Example #4
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstruction35c.java    License: Apache License 2.0 6 votes vote down vote up
public ImmutableInstruction35c(@Nonnull Opcode opcode,
                               int registerCount,
                               int registerC,
                               int registerD,
                               int registerE,
                               int registerF,
                               int registerG,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(registerCount);
    this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
    this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
    this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
    this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
    this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #5
Source Project: zjdroid   Author: Miracle963   File: BuilderInstruction35c.java    License: Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(registerCount);
    this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
    this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
    this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
    this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
    this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
    this.reference = reference;
}
 
Example #6
Source Project: HeyGirl   Author: mikusjelly   File: ImmutableInstruction35c.java    License: Apache License 2.0 6 votes vote down vote up
public ImmutableInstruction35c(@Nonnull Opcode opcode,
                               int registerCount,
                               int registerC,
                               int registerD,
                               int registerE,
                               int registerF,
                               int registerG,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(registerCount);
    this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
    this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
    this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
    this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
    this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #7
Source Project: HeyGirl   Author: mikusjelly   File: BuilderInstruction35c.java    License: Apache License 2.0 6 votes vote down vote up
public BuilderInstruction35c(@Nonnull Opcode opcode,
                             int registerCount,
                             int registerC,
                             int registerD,
                             int registerE,
                             int registerF,
                             int registerG,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerCount = Preconditions.check35cRegisterCount(registerCount);
    this.registerC = (registerCount>0) ? Preconditions.checkNibbleRegister(registerC) : 0;
    this.registerD = (registerCount>1) ? Preconditions.checkNibbleRegister(registerD) : 0;
    this.registerE = (registerCount>2) ? Preconditions.checkNibbleRegister(registerE) : 0;
    this.registerF = (registerCount>3) ? Preconditions.checkNibbleRegister(registerF) : 0;
    this.registerG = (registerCount>4) ? Preconditions.checkNibbleRegister(registerG) : 0;
    this.reference = reference;
}
 
Example #8
Source Project: HeyGirl   Author: mikusjelly   File: MethodAnalyzer.java    License: Apache License 2.0 6 votes vote down vote up
private void analyzeMoveResult(@Nonnull AnalyzedInstruction analyzedInstruction) {
    AnalyzedInstruction previousInstruction = analyzedInstructions.valueAt(analyzedInstruction.instructionIndex-1);
    if (!previousInstruction.instruction.getOpcode().setsResult()) {
        throw new AnalysisException(analyzedInstruction.instruction.getOpcode().name + " must occur after an " +
                "invoke-*/fill-new-array instruction");
    }

    RegisterType resultRegisterType;
    ReferenceInstruction invokeInstruction = (ReferenceInstruction)previousInstruction.instruction;
    Reference reference = invokeInstruction.getReference();

    if (reference instanceof MethodReference) {
        resultRegisterType = RegisterType.getRegisterType(classPath, ((MethodReference)reference).getReturnType());
    } else {
        resultRegisterType = RegisterType.getRegisterType(classPath, (TypeReference)reference);
    }

    setDestinationRegisterTypeAndPropagateChanges(analyzedInstruction, resultRegisterType);
}
 
Example #9
Source Project: ZjDroid   Author: KB5201314   File: ImmutableInstruction21c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction21c(@Nonnull Opcode opcode,
                                  int registerA,
                                  @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #10
Source Project: HeyGirl   Author: mikusjelly   File: BuilderInstruction20bc.java    License: Apache License 2.0 5 votes vote down vote up
public BuilderInstruction20bc(@Nonnull Opcode opcode,
                                int verificationError,
                                @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = reference;
}
 
Example #11
Source Project: HeyGirl   Author: mikusjelly   File: InstructionRewriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public Reference getReference() {
    switch (getReferenceType()) {
        case ReferenceType.TYPE:
            return RewriterUtils.rewriteTypeReference(rewriters.getTypeRewriter(),
                    (TypeReference)instruction.getReference());
        case ReferenceType.FIELD:
            return rewriters.getFieldReferenceRewriter().rewrite((FieldReference)instruction.getReference());
        case ReferenceType.METHOD:
            return rewriters.getMethodReferenceRewriter().rewrite((MethodReference)instruction.getReference());
        case ReferenceType.STRING:
            return instruction.getReference();
        default:
            throw new IllegalArgumentException();
    }
}
 
Example #12
Source Project: ZjDroid   Author: KB5201314   File: ImmutableInstructionFactory.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction35c makeInstruction35c(@Nonnull Opcode opcode,
                                                  int registerCount,
                                                  int registerC,
                                                  int registerD,
                                                  int registerE,
                                                  int registerF,
                                                  int registerG,
                                                  @Nonnull Reference reference) {
    return new ImmutableInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG,
            reference);
}
 
Example #13
Source Project: ZjDroid   Author: KB5201314   File: ImmutableInstruction22c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #14
Source Project: HeyGirl   Author: mikusjelly   File: DexBackedReference.java    License: Apache License 2.0 5 votes vote down vote up
public static Reference makeReference(@Nonnull DexBackedDexFile dexFile, int referenceType, int referenceIndex) {
    switch (referenceType) {
        case ReferenceType.STRING:
            return new DexBackedStringReference(dexFile, referenceIndex);
        case ReferenceType.TYPE:
            return new DexBackedTypeReference(dexFile, referenceIndex);
        case ReferenceType.METHOD:
            return new DexBackedMethodReference(dexFile, referenceIndex);
        case ReferenceType.FIELD:
            return new DexBackedFieldReference(dexFile, referenceIndex);
        default:
            throw new ExceptionWithContext("Invalid reference type: %d", referenceType);
    }
}
 
Example #15
Source Project: ZjDroid   Author: KB5201314   File: ImmutableInstruction31c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #16
Source Project: ZjDroid   Author: KB5201314   File: ImmutableInstruction20bc.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #17
Source Project: ZjDroid   Author: KB5201314   File: InstructionRewriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public Reference getReference() {
    switch (getReferenceType()) {
        case ReferenceType.TYPE:
            return RewriterUtils.rewriteTypeReference(rewriters.getTypeRewriter(),
                    (TypeReference)instruction.getReference());
        case ReferenceType.FIELD:
            return rewriters.getFieldReferenceRewriter().rewrite((FieldReference)instruction.getReference());
        case ReferenceType.METHOD:
            return rewriters.getMethodReferenceRewriter().rewrite((MethodReference)instruction.getReference());
        case ReferenceType.STRING:
            return instruction.getReference();
        default:
            throw new IllegalArgumentException();
    }
}
 
Example #18
Source Project: HeyGirl   Author: mikusjelly   File: BuilderInstruction22c.java    License: Apache License 2.0 5 votes vote down vote up
public BuilderInstruction22c(@Nonnull Opcode opcode,
                             int registerA,
                             int registerB,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = reference;
}
 
Example #19
Source Project: ZjDroid   Author: KB5201314   File: BuilderInstruction20bc.java    License: Apache License 2.0 5 votes vote down vote up
public BuilderInstruction20bc(@Nonnull Opcode opcode,
                                int verificationError,
                                @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = reference;
}
 
Example #20
Source Project: HeyGirl   Author: mikusjelly   File: ImmutableInstruction22c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #21
Source Project: HeyGirl   Author: mikusjelly   File: BuilderInstruction31c.java    License: Apache License 2.0 5 votes vote down vote up
public BuilderInstruction31c(@Nonnull Opcode opcode,
                             int registerA,
                             @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = reference;
}
 
Example #22
Source Project: HeyGirl   Author: mikusjelly   File: ImmutableInstruction20bc.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #23
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstructionFactory.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction35c makeInstruction35c(@Nonnull Opcode opcode,
                                                  int registerCount,
                                                  int registerC,
                                                  int registerD,
                                                  int registerE,
                                                  int registerF,
                                                  int registerG,
                                                  @Nonnull Reference reference) {
    return new ImmutableInstruction35c(opcode, registerCount, registerC, registerD, registerE, registerF, registerG,
            reference);
}
 
Example #24
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstruction22c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction22c(@Nonnull Opcode opcode,
                               int registerA,
                               int registerB,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkNibbleRegister(registerA);
    this.registerB = Preconditions.checkNibbleRegister(registerB);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #25
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstruction3rc.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction3rc(@Nonnull Opcode opcode,
                               int startRegister,
                               int registerCount,
                               @Nonnull Reference reference) {
    super(opcode);
    this.startRegister = Preconditions.checkShortRegister(startRegister);
    this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #26
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstruction31c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #27
Source Project: zjdroid   Author: Miracle963   File: ImmutableInstruction20bc.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction20bc(@Nonnull Opcode opcode,
                               int verificationError,
                               @Nonnull Reference reference) {
    super(opcode);
    this.verificationError = Preconditions.checkVerificationError(verificationError);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #28
Source Project: zjdroid   Author: Miracle963   File: InstructionRewriter.java    License: Apache License 2.0 5 votes vote down vote up
@Override @Nonnull public Reference getReference() {
    switch (getReferenceType()) {
        case ReferenceType.TYPE:
            return RewriterUtils.rewriteTypeReference(rewriters.getTypeRewriter(),
                    (TypeReference)instruction.getReference());
        case ReferenceType.FIELD:
            return rewriters.getFieldReferenceRewriter().rewrite((FieldReference)instruction.getReference());
        case ReferenceType.METHOD:
            return rewriters.getMethodReferenceRewriter().rewrite((MethodReference)instruction.getReference());
        case ReferenceType.STRING:
            return instruction.getReference();
        default:
            throw new IllegalArgumentException();
    }
}
 
Example #29
Source Project: HeyGirl   Author: mikusjelly   File: ImmutableInstruction3rc.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction3rc(@Nonnull Opcode opcode,
                               int startRegister,
                               int registerCount,
                               @Nonnull Reference reference) {
    super(opcode);
    this.startRegister = Preconditions.checkShortRegister(startRegister);
    this.registerCount = Preconditions.checkRegisterRangeCount(registerCount);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}
 
Example #30
Source Project: HeyGirl   Author: mikusjelly   File: ImmutableInstruction31c.java    License: Apache License 2.0 5 votes vote down vote up
public ImmutableInstruction31c(@Nonnull Opcode opcode,
                               int registerA,
                               @Nonnull Reference reference) {
    super(opcode);
    this.registerA = Preconditions.checkByteRegister(registerA);
    this.reference = ImmutableReferenceFactory.of(opcode.referenceType, reference);
}