org.jf.dexlib2.dexbacked.util.FixedSizeList Java Examples

The following examples show how to use org.jf.dexlib2.dexbacked.util.FixedSizeList. 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: DexBackedPackedSwitchPayload.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return firstKey + index;
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #2
Source File: DexBackedMethodReference.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    int protoIdItemOffset = getProtoIdItemOffset();
    final int parametersOffset = dexFile.readSmallUint(protoIdItemOffset + ProtoIdItem.PARAMETERS_OFFSET);
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #3
Source File: RawDexFile.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public List<MapItem> getMapItems() {
    final int mapOffset = getMapOffset();
    final int mapSize = readSmallUint(mapOffset);

    return new FixedSizeList<MapItem>() {
        @Override
        public MapItem readItem(int index) {
            int mapItemOffset = mapOffset + 4 + index * MapItem.ITEM_SIZE;
            return new MapItem(RawDexFile.this, mapItemOffset);
        }

        @Override public int size() {
            return mapSize;
        }
    };
}
 
Example #4
Source File: DexBackedMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    final int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #5
Source File: DexBackedSparseSwitchPayload.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #6
Source File: DexBackedPackedSwitchPayload.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return firstKey + index;
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #7
Source File: DexBackedMethodReference.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    int protoIdItemOffset = getProtoIdItemOffset();
    final int parametersOffset = dexFile.readSmallUint(protoIdItemOffset + ProtoIdItem.PARAMETERS_OFFSET);
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #8
Source File: RawDexFile.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
public List<MapItem> getMapItems() {
    final int mapOffset = getMapOffset();
    final int mapSize = readSmallUint(mapOffset);

    return new FixedSizeList<MapItem>() {
        @Override
        public MapItem readItem(int index) {
            int mapItemOffset = mapOffset + 4 + index * MapItem.ITEM_SIZE;
            return new MapItem(RawDexFile.this, mapItemOffset);
        }

        @Override public int size() {
            return mapSize;
        }
    };
}
 
Example #9
Source File: DexBackedMethod.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    final int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #10
Source File: DexBackedSparseSwitchPayload.java    From HeyGirl with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #11
Source File: DexBackedPackedSwitchPayload.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return firstKey + index;
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #12
Source File: DexBackedMethodReference.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    int protoIdItemOffset = getProtoIdItemOffset();
    final int parametersOffset = dexFile.readSmallUint(protoIdItemOffset + ProtoIdItem.PARAMETERS_OFFSET);
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #13
Source File: RawDexFile.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
public List<MapItem> getMapItems() {
    final int mapOffset = getMapOffset();
    final int mapSize = readSmallUint(mapOffset);

    return new FixedSizeList<MapItem>() {
        @Override
        public MapItem readItem(int index) {
            int mapItemOffset = mapOffset + 4 + index * MapItem.ITEM_SIZE;
            return new MapItem(RawDexFile.this, mapItemOffset);
        }

        @Override public int size() {
            return mapSize;
        }
    };
}
 
Example #14
Source File: DexBackedMethod.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    final int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #15
Source File: DexBackedSparseSwitchPayload.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #16
Source File: DexBackedPackedSwitchPayload.java    From zjdroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    final int firstKey = dexFile.readInt(instructionStart + FIRST_KEY_OFFSET);
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return firstKey + index;
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + TARGETS_OFFSET + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #17
Source File: DexBackedMethodReference.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    int protoIdItemOffset = getProtoIdItemOffset();
    final int parametersOffset = dexFile.readSmallUint(protoIdItemOffset + ProtoIdItem.PARAMETERS_OFFSET);
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #18
Source File: RawDexFile.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
public List<MapItem> getMapItems() {
    final int mapOffset = getMapOffset();
    final int mapSize = readSmallUint(mapOffset);

    return new FixedSizeList<MapItem>() {
        @Override
        public MapItem readItem(int index) {
            int mapItemOffset = mapOffset + 4 + index * MapItem.ITEM_SIZE;
            return new MapItem(RawDexFile.this, mapItemOffset);
        }

        @Override public int size() {
            return mapSize;
        }
    };
}
 
Example #19
Source File: DexBackedMethod.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<String> getParameterTypes() {
    final int parametersOffset = getParametersOffset();
    if (parametersOffset > 0) {
        final int parameterCount = dexFile.readSmallUint(parametersOffset + TypeListItem.SIZE_OFFSET);
        final int paramListStart = parametersOffset + TypeListItem.LIST_OFFSET;
        return new FixedSizeList<String>() {
            @Nonnull
            @Override
            public String readItem(final int index) {
                return dexFile.getType(dexFile.readUshort(paramListStart + 2*index));
            }
            @Override public int size() { return parameterCount; }
        };
    }
    return ImmutableList.of();
}
 
Example #20
Source File: DexBackedSparseSwitchPayload.java    From ZjDroid with Apache License 2.0 6 votes vote down vote up
@Nonnull
@Override
public List<? extends SwitchElement> getSwitchElements() {
    return new FixedSizeList<SwitchElement>() {
        @Nonnull
        @Override
        public SwitchElement readItem(final int index) {
            return new SwitchElement() {
                @Override
                public int getKey() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + index*4);
                }

                @Override
                public int getOffset() {
                    return dexFile.readInt(instructionStart + KEYS_OFFSET + elementCount*4 + index*4);
                }
            };
        }

        @Override public int size() { return elementCount; }
    };
}
 
Example #21
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 #22
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 #23
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 #24
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();
}