org.jf.dexlib2.analysis.RegisterType Java Examples

The following examples show how to use org.jf.dexlib2.analysis.RegisterType. 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: PostInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #2
Source File: PostInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #3
Source File: PreInstructionRegisterInfoMethodItem.java    From atlas with Apache License 2.0 6 votes vote down vote up
private void addMergeRegs(BitSet registers, int registerCount) {
    if (analyzedInstruction.getPredecessorCount() <= 1) {
        //in the common case of an instruction that only has a single predecessor which is the previous
        //instruction, the pre-instruction registers will always match the previous instruction's
        //post-instruction registers
        return;
    }

    for (int registerNum=0; registerNum<registerCount; registerNum++) {
        RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
            if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                    !predecessorRegisterType.equals(mergedRegisterType)) {
                registers.set(registerNum);
            }
        }
    }
}
 
Example #4
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void addMergeRegs(BitSet registers, int registerCount) {
    if (analyzedInstruction.getPredecessorCount() <= 1) {
        //in the common case of an instruction that only has a single predecessor which is the previous
        //instruction, the pre-instruction registers will always match the previous instruction's
        //post-instruction registers
        return;
    }

    for (int registerNum=0; registerNum<registerCount; registerNum++) {
        RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
            if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                    !predecessorRegisterType.equals(mergedRegisterType)) {
                registers.set(registerNum);
            }
        }
    }
}
 
Example #5
Source File: PostInstructionRegisterInfoMethodItem.java    From atlas with Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #6
Source File: PreInstructionRegisterInfoMethodItem.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
private void addMergeRegs(BitSet registers, int registerCount) {
    if (analyzedInstruction.getPredecessorCount() <= 1) {
        //in the common case of an instruction that only has a single predecessor which is the previous
        //instruction, the pre-instruction registers will always match the previous instruction's
        //post-instruction registers
        return;
    }

    for (int registerNum=0; registerNum<registerCount; registerNum++) {
        RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
            if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                    !predecessorRegisterType.equals(mergedRegisterType)) {
                registers.set(registerNum);
            }
        }
    }
}
 
Example #7
Source File: PostInstructionRegisterInfoMethodItem.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #8
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
private void addMergeRegs(BitSet registers, int registerCount) {
    if (analyzedInstruction.getPredecessorCount() <= 1) {
        //in the common case of an instruction that only has a single predecessor which is the previous
        //instruction, the pre-instruction registers will always match the previous instruction's
        //post-instruction registers
        return;
    }

    for (int registerNum=0; registerNum<registerCount; registerNum++) {
        RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
            if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                    !predecessorRegisterType.equals(mergedRegisterType)) {
                registers.set(registerNum);
            }
        }
    }
}
 
Example #9
Source File: PostInstructionRegisterInfoMethodItem.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException {
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum);

        registerFormatter.writeTo(writer, registerNum);
        writer.write('=');
        registerType.writeTo(writer);
        writer.write(';');
    }
    return true;
}
 
Example #10
Source File: PreInstructionRegisterInfoMethodItem.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
private void addMergeRegs(BitSet registers, int registerCount) {
    if (analyzedInstruction.getPredecessorCount() <= 1) {
        //in the common case of an instruction that only has a single predecessor which is the previous
        //instruction, the pre-instruction registers will always match the previous instruction's
        //post-instruction registers
        return;
    }

    for (int registerNum=0; registerNum<registerCount; registerNum++) {
        RegisterType mergedRegisterType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

        for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
            RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);
            if (predecessorRegisterType.category != RegisterType.UNKNOWN &&
                    !predecessorRegisterType.equals(mergedRegisterType)) {
                registers.set(registerNum);
            }
        }
    }
}
 
Example #11
Source File: PreInstructionRegisterInfoMethodItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
                                  BitSet fullMergeRegisters) throws IOException {
    boolean firstRegister = true;
    boolean previousWasFullMerge = false;
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum);
        if (fullMerge) {
            if (!firstRegister) {
                writer.write('\n');
                writer.write('#');
            }
            writeFullMerge(writer, registerNum);
            previousWasFullMerge = true;
        } else {
            if (previousWasFullMerge) {
                writer.write('\n');
                writer.write('#');
                previousWasFullMerge = false;
            }

            RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');

            registerType.writeTo(writer);
            writer.write(';');
        }

        firstRegister = false;
    }
    return true;
}
 
Example #12
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
                                  BitSet fullMergeRegisters) throws IOException {
    boolean firstRegister = true;
    boolean previousWasFullMerge = false;
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum);
        if (fullMerge) {
            if (!firstRegister) {
                writer.write('\n');
                writer.write('#');
            }
            writeFullMerge(writer, registerNum);
            previousWasFullMerge = true;
        } else {
            if (previousWasFullMerge) {
                writer.write('\n');
                writer.write('#');
                previousWasFullMerge = false;
            }

            RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');

            registerType.writeTo(writer);
            writer.write(';');
        }

        firstRegister = false;
    }
    return true;
}
 
Example #13
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void writeFullMerge(IndentingWriter writer, int registerNum) throws IOException {
    registerFormatter.writeTo(writer, registerNum);
    writer.write('=');
    analyzedInstruction.getPreInstructionRegisterType(registerNum).writeTo(writer);
    writer.write(":merge{");

    boolean first = true;

    for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
        RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

        if (!first) {
            writer.write(',');
        }

        if (predecessor.getInstructionIndex() == -1) {
            //the fake "StartOfMethod" instruction
            writer.write("Start:");
        } else {
            writer.write("0x");
            writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
            writer.write(':');
        }
        predecessorRegisterType.writeTo(writer);

        first = false;
    }
    writer.write('}');
}
 
Example #14
Source File: PreInstructionRegisterInfoMethodItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
                                  BitSet fullMergeRegisters) throws IOException {
    boolean firstRegister = true;
    boolean previousWasFullMerge = false;
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum);
        if (fullMerge) {
            if (!firstRegister) {
                writer.write('\n');
                writer.write('#');
            }
            writeFullMerge(writer, registerNum);
            previousWasFullMerge = true;
        } else {
            if (previousWasFullMerge) {
                writer.write('\n');
                writer.write('#');
                previousWasFullMerge = false;
            }

            RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');

            registerType.writeTo(writer);
            writer.write(';');
        }

        firstRegister = false;
    }
    return true;
}
 
Example #15
Source File: PreInstructionRegisterInfoMethodItem.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
private void writeFullMerge(IndentingWriter writer, int registerNum) throws IOException {
    registerFormatter.writeTo(writer, registerNum);
    writer.write('=');
    analyzedInstruction.getPreInstructionRegisterType(registerNum).writeTo(writer);
    writer.write(":merge{");

    boolean first = true;

    for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
        RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

        if (!first) {
            writer.write(',');
        }

        if (predecessor.getInstructionIndex() == -1) {
            //the fake "StartOfMethod" instruction
            writer.write("Start:");
        } else {
            writer.write("0x");
            writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
            writer.write(':');
        }
        predecessorRegisterType.writeTo(writer);

        first = false;
    }
    writer.write('}');
}
 
Example #16
Source File: PreInstructionRegisterInfoMethodItem.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
private void writeFullMerge(IndentingWriter writer, int registerNum) throws IOException {
    registerFormatter.writeTo(writer, registerNum);
    writer.write('=');
    analyzedInstruction.getPreInstructionRegisterType(registerNum).writeTo(writer);
    writer.write(":merge{");

    boolean first = true;

    for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
        RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

        if (!first) {
            writer.write(',');
        }

        if (predecessor.getInstructionIndex() == -1) {
            //the fake "StartOfMethod" instruction
            writer.write("Start:");
        } else {
            writer.write("0x");
            writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
            writer.write(':');
        }
        predecessorRegisterType.writeTo(writer);

        first = false;
    }
    writer.write('}');
}
 
Example #17
Source File: PreInstructionRegisterInfoMethodItem.java    From atlas with Apache License 2.0 5 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
                                  BitSet fullMergeRegisters) throws IOException {
    boolean firstRegister = true;
    boolean previousWasFullMerge = false;
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum);
        if (fullMerge) {
            if (!firstRegister) {
                writer.write('\n');
                writer.write('#');
            }
            writeFullMerge(writer, registerNum);
            previousWasFullMerge = true;
        } else {
            if (previousWasFullMerge) {
                writer.write('\n');
                writer.write('#');
                previousWasFullMerge = false;
            }

            RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');

            registerType.writeTo(writer);
            writer.write(';');
        }

        firstRegister = false;
    }
    return true;
}
 
Example #18
Source File: PreInstructionRegisterInfoMethodItem.java    From atlas with Apache License 2.0 5 votes vote down vote up
private void writeFullMerge(IndentingWriter writer, int registerNum) throws IOException {
    registerFormatter.writeTo(writer, registerNum);
    writer.write('=');
    analyzedInstruction.getPreInstructionRegisterType(registerNum).writeTo(writer);
    writer.write(":merge{");

    boolean first = true;

    for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
        RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

        if (!first) {
            writer.write(',');
        }

        if (predecessor.getInstructionIndex() == -1) {
            //the fake "StartOfMethod" instruction
            writer.write("Start:");
        } else {
            writer.write("0x");
            writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
            writer.write(':');
        }
        predecessorRegisterType.writeTo(writer);

        first = false;
    }
    writer.write('}');
}
 
Example #19
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers,
                                  BitSet fullMergeRegisters) throws IOException {
    boolean firstRegister = true;
    boolean previousWasFullMerge = false;
    int registerNum = registers.nextSetBit(0);
    if (registerNum < 0) {
        return false;
    }

    writer.write('#');
    for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) {
        boolean fullMerge = fullMergeRegisters!=null && fullMergeRegisters.get(registerNum);
        if (fullMerge) {
            if (!firstRegister) {
                writer.write('\n');
                writer.write('#');
            }
            writeFullMerge(writer, registerNum);
            previousWasFullMerge = true;
        } else {
            if (previousWasFullMerge) {
                writer.write('\n');
                writer.write('#');
                previousWasFullMerge = false;
            }

            RegisterType registerType = analyzedInstruction.getPreInstructionRegisterType(registerNum);

            registerFormatter.writeTo(writer, registerNum);
            writer.write('=');

            registerType.writeTo(writer);
            writer.write(';');
        }

        firstRegister = false;
    }
    return true;
}
 
Example #20
Source File: PreInstructionRegisterInfoMethodItem.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
private void writeFullMerge(IndentingWriter writer, int registerNum) throws IOException {
    registerFormatter.writeTo(writer, registerNum);
    writer.write('=');
    analyzedInstruction.getPreInstructionRegisterType(registerNum).writeTo(writer);
    writer.write(":merge{");

    boolean first = true;

    for (AnalyzedInstruction predecessor: analyzedInstruction.getPredecessors()) {
        RegisterType predecessorRegisterType = predecessor.getPostInstructionRegisterType(registerNum);

        if (!first) {
            writer.write(',');
        }

        if (predecessor.getInstructionIndex() == -1) {
            //the fake "StartOfMethod" instruction
            writer.write("Start:");
        } else {
            writer.write("0x");
            writer.printUnsignedLongAsHex(methodAnalyzer.getInstructionAddress(predecessor));
            writer.write(':');
        }
        predecessorRegisterType.writeTo(writer);

        first = false;
    }
    writer.write('}');
}