org.jf.dexlib2.dexbacked.instruction.DexBackedInstruction Java Examples

The following examples show how to use org.jf.dexlib2.dexbacked.instruction.DexBackedInstruction. 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: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
    // instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
    int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);

    final int instructionsStartOffset = codeOffset + CodeItem.INSTRUCTION_START_OFFSET;
    final int endOffset = instructionsStartOffset + (instructionsSize*2);
    return new Iterable<Instruction>() {
        @Override
        public Iterator<Instruction> iterator() {
            return new VariableSizeLookaheadIterator<Instruction>(dexFile, instructionsStartOffset) {
                @Override
                protected Instruction readNextItem(@Nonnull DexReader reader) {
                    if (reader.getOffset() >= endOffset) {
                        return null;
                    }
                    return DexBackedInstruction.readFrom(reader);
                }
            };
        }
    };
}
 
Example #2
Source File: DexBackedMethodImplementation.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
    // instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
    int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);

    final int instructionsStartOffset = codeOffset + CodeItem.INSTRUCTION_START_OFFSET;
    final int endOffset = instructionsStartOffset + (instructionsSize*2);
    return new Iterable<Instruction>() {
        @Override
        public Iterator<Instruction> iterator() {
            return new VariableSizeLookaheadIterator<Instruction>(dexFile, instructionsStartOffset) {
                @Override
                protected Instruction readNextItem(@Nonnull DexReader reader) {
                    if (reader.getOffset() >= endOffset) {
                        return null;
                    }
                    return DexBackedInstruction.readFrom(reader);
                }
            };
        }
    };
}
 
Example #3
Source File: DexBackedMethodImplementation.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
    // instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
    int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);

    final int instructionsStartOffset = codeOffset + CodeItem.INSTRUCTION_START_OFFSET;
    final int endOffset = instructionsStartOffset + (instructionsSize*2);
    return new Iterable<Instruction>() {
        @Override
        public Iterator<Instruction> iterator() {
            return new VariableSizeLookaheadIterator<Instruction>(dexFile, instructionsStartOffset) {
                @Override
                protected Instruction readNextItem(@Nonnull DexReader reader) {
                    if (reader.getOffset() >= endOffset) {
                        return null;
                    }
                    return DexBackedInstruction.readFrom(reader);
                }
            };
        }
    };
}
 
Example #4
Source File: BasicBlockInstruction.java    From CFGScanDroid with GNU General Public License v2.0 6 votes vote down vote up
public BasicBlockInstruction(int address, Instruction insn) {
	this.instruction = insn;
	this.leader = address == 0 ? true : false;
	this.branch = isBranch();
	this.destinations = null;
	this.address = address;

	DexBackedInstruction dexBackedInstruction = (DexBackedInstruction)insn;
	this.offset = dexBackedInstruction.instructionStart;
	this.length = insn.getCodeUnits() * 2;
	this.rawBytes = new byte[this.length];
	// DexReader reader = readerAt(this.offset);
	for(int i=0; i<this.length; ++i) {
		this.rawBytes[i] = (byte)dexBackedInstruction.dexFile.readByte(this.offset + i);
		// System.out.print(this.rawBytes[i]);
		// System.out.print(' ');
	}
	// System.out.println();
}
 
Example #5
Source File: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull @Override public Iterable<? extends Instruction> getInstructions() {
    // instructionsSize is the number of 16-bit code units in the instruction list, not the number of instructions
    int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);

    final int instructionsStartOffset = codeOffset + CodeItem.INSTRUCTION_START_OFFSET;
    final int endOffset = instructionsStartOffset + (instructionsSize*2);
    return new Iterable<Instruction>() {
        @Override
        public Iterator<Instruction> iterator() {
            return new VariableSizeLookaheadIterator<Instruction>(dexFile, instructionsStartOffset) {
                @Override
                protected Instruction readNextItem(@Nonnull DexReader reader) {
                    if (reader.getOffset() >= endOffset) {
                        return null;
                    }
                    return DexBackedInstruction.readFrom(reader);
                }
            };
        }
    };
}