org.jf.dexlib2.dexbacked.raw.CodeItem Java Examples

The following examples show how to use org.jf.dexlib2.dexbacked.raw.CodeItem. 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 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 #4
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 #5
Source File: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<? extends DexBackedTryBlock> getTryBlocks() {
    final int triesSize = dexFile.readUshort(codeOffset + CodeItem.TRIES_SIZE_OFFSET);
    if (triesSize > 0) {
        int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
        final int triesStartOffset = AlignmentUtils.alignOffset(
                codeOffset + CodeItem.INSTRUCTION_START_OFFSET + (instructionsSize*2), 4);
        final int handlersStartOffset = triesStartOffset + triesSize*CodeItem.TryItem.ITEM_SIZE;

        return new FixedSizeList<DexBackedTryBlock>() {
            @Nonnull
            @Override
            public DexBackedTryBlock readItem(int index) {
                return new DexBackedTryBlock(dexFile,
                        triesStartOffset + index*CodeItem.TryItem.ITEM_SIZE,
                        handlersStartOffset);
            }

            @Override
            public int size() {
                return triesSize;
            }
        };
    }
    return ImmutableList.of();
}
 
Example #6
Source File: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<? extends DexBackedTryBlock> getTryBlocks() {
    final int triesSize = dexFile.readUshort(codeOffset + CodeItem.TRIES_SIZE_OFFSET);
    if (triesSize > 0) {
        int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
        final int triesStartOffset = AlignmentUtils.alignOffset(
                codeOffset + CodeItem.INSTRUCTION_START_OFFSET + (instructionsSize*2), 4);
        final int handlersStartOffset = triesStartOffset + triesSize*CodeItem.TryItem.ITEM_SIZE;

        return new FixedSizeList<DexBackedTryBlock>() {
            @Nonnull
            @Override
            public DexBackedTryBlock readItem(int index) {
                return new DexBackedTryBlock(dexFile,
                        triesStartOffset + index*CodeItem.TryItem.ITEM_SIZE,
                        handlersStartOffset);
            }

            @Override
            public int size() {
                return triesSize;
            }
        };
    }
    return ImmutableList.of();
}
 
Example #7
Source File: DexBackedMethodImplementation.java    From zjdroid with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<? extends DexBackedTryBlock> getTryBlocks() {
    final int triesSize = dexFile.readUshort(codeOffset + CodeItem.TRIES_SIZE_OFFSET);
    if (triesSize > 0) {
        int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
        final int triesStartOffset = AlignmentUtils.alignOffset(
                codeOffset + CodeItem.INSTRUCTION_START_OFFSET + (instructionsSize*2), 4);
        final int handlersStartOffset = triesStartOffset + triesSize*CodeItem.TryItem.ITEM_SIZE;

        return new FixedSizeList<DexBackedTryBlock>() {
            @Nonnull
            @Override
            public DexBackedTryBlock readItem(int index) {
                return new DexBackedTryBlock(dexFile,
                        triesStartOffset + index*CodeItem.TryItem.ITEM_SIZE,
                        handlersStartOffset);
            }

            @Override
            public int size() {
                return triesSize;
            }
        };
    }
    return ImmutableList.of();
}
 
Example #8
Source File: DexBackedMethodImplementation.java    From HeyGirl with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public List<? extends DexBackedTryBlock> getTryBlocks() {
    final int triesSize = dexFile.readUshort(codeOffset + CodeItem.TRIES_SIZE_OFFSET);
    if (triesSize > 0) {
        int instructionsSize = dexFile.readSmallUint(codeOffset + CodeItem.INSTRUCTION_COUNT_OFFSET);
        final int triesStartOffset = AlignmentUtils.alignOffset(
                codeOffset + CodeItem.INSTRUCTION_START_OFFSET + (instructionsSize*2), 4);
        final int handlersStartOffset = triesStartOffset + triesSize*CodeItem.TryItem.ITEM_SIZE;

        return new FixedSizeList<DexBackedTryBlock>() {
            @Nonnull
            @Override
            public DexBackedTryBlock readItem(int index) {
                return new DexBackedTryBlock(dexFile,
                        triesStartOffset + index*CodeItem.TryItem.ITEM_SIZE,
                        handlersStartOffset);
            }

            @Override
            public int size() {
                return triesSize;
            }
        };
    }
    return ImmutableList.of();
}
 
Example #9
Source File: DexBackedTryBlock.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Override public int getStartCodeAddress() {
    return dexFile.readSmallUint(tryItemOffset + CodeItem.TryItem.START_ADDRESS_OFFSET);
}
 
Example #10
Source File: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private DebugInfo getDebugInfo() {
    return DebugInfo.newOrEmpty(dexFile, dexFile.readSmallUint(codeOffset + CodeItem.DEBUG_INFO_OFFSET), this);
}
 
Example #11
Source File: DexBackedTryBlock.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override public int getCodeUnitCount() {
    return dexFile.readUshort(tryItemOffset + CodeItem.TryItem.CODE_UNIT_COUNT_OFFSET);
}
 
Example #12
Source File: DexBackedTryBlock.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override public int getStartCodeAddress() {
    return dexFile.readSmallUint(tryItemOffset + CodeItem.TryItem.START_ADDRESS_OFFSET);
}
 
Example #13
Source File: DexBackedMethodImplementation.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Nonnull
private DebugInfo getDebugInfo() {
    return DebugInfo.newOrEmpty(dexFile, dexFile.readSmallUint(codeOffset + CodeItem.DEBUG_INFO_OFFSET), this);
}
 
Example #14
Source File: DexBackedTryBlock.java    From HeyGirl with Apache License 2.0 4 votes vote down vote up
@Override public int getCodeUnitCount() {
    return dexFile.readUshort(tryItemOffset + CodeItem.TryItem.CODE_UNIT_COUNT_OFFSET);
}
 
Example #15
Source File: DexBackedTryBlock.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override public int getStartCodeAddress() {
    return dexFile.readSmallUint(tryItemOffset + CodeItem.TryItem.START_ADDRESS_OFFSET);
}
 
Example #16
Source File: DexBackedMethodImplementation.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private DebugInfo getDebugInfo() {
    return DebugInfo.newOrEmpty(dexFile, dexFile.readSmallUint(codeOffset + CodeItem.DEBUG_INFO_OFFSET), this);
}
 
Example #17
Source File: DexBackedTryBlock.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Override public int getCodeUnitCount() {
    return dexFile.readUshort(tryItemOffset + CodeItem.TryItem.CODE_UNIT_COUNT_OFFSET);
}
 
Example #18
Source File: DexBackedTryBlock.java    From zjdroid with Apache License 2.0 4 votes vote down vote up
@Override public int getStartCodeAddress() {
    return dexFile.readSmallUint(tryItemOffset + CodeItem.TryItem.START_ADDRESS_OFFSET);
}
 
Example #19
Source File: DexBackedMethodImplementation.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Nonnull
private DebugInfo getDebugInfo() {
    return DebugInfo.newOrEmpty(dexFile, dexFile.readSmallUint(codeOffset + CodeItem.DEBUG_INFO_OFFSET), this);
}
 
Example #20
Source File: DexBackedTryBlock.java    From ZjDroid with Apache License 2.0 4 votes vote down vote up
@Override public int getCodeUnitCount() {
    return dexFile.readUshort(tryItemOffset + CodeItem.TryItem.CODE_UNIT_COUNT_OFFSET);
}