some work on DexType and DexMethodType
This commit is contained in:
parent
cc6ce1c625
commit
2ec3fe2c9d
4 changed files with 127 additions and 28 deletions
|
|
@ -143,7 +143,7 @@ impl<'a> DexFileReader<'a> {
|
|||
})
|
||||
}
|
||||
|
||||
/// Return a [`&TypeIdItem`] from its idx.
|
||||
/// Return a [`TypeIdItem`] reference from its idx.
|
||||
pub fn get_type_id(&self, idx: usize) -> Result<&TypeIdItem> {
|
||||
self.type_ids
|
||||
.get(idx)
|
||||
|
|
@ -154,7 +154,7 @@ impl<'a> DexFileReader<'a> {
|
|||
)))
|
||||
}
|
||||
|
||||
/// Return a [`&FieldIdItem`] from its idx.
|
||||
/// Return a [`FieldIdItem`] reference from its idx.
|
||||
pub fn get_field_id(&self, idx: usize) -> Result<&FieldIdItem> {
|
||||
self.field_ids
|
||||
.get(idx)
|
||||
|
|
@ -164,6 +164,16 @@ impl<'a> DexFileReader<'a> {
|
|||
)))
|
||||
}
|
||||
|
||||
/// Return a [`ProtoIdItem`] reference from its idx.
|
||||
pub fn get_proto_id(&self, idx: usize) -> Result<&ProtoIdItem> {
|
||||
self.proto_ids
|
||||
.get(idx)
|
||||
.ok_or(Error::InconsistantStruct(format!(
|
||||
"prototype idx {idx} is out of bound (|proto_ids|={})",
|
||||
self.proto_ids.len()
|
||||
)))
|
||||
}
|
||||
|
||||
fn sanity_check(&self) -> Result<()> {
|
||||
if self.header.magic.version != [0x30, 0x33, 0x39] {
|
||||
warn!(
|
||||
|
|
|
|||
|
|
@ -14,12 +14,19 @@ pub enum EncodedValue {
|
|||
Long(i64),
|
||||
Float(f32),
|
||||
Double(f64),
|
||||
/// Index of a [`crate::ProtoIdItem`] in `proto_ids`
|
||||
MethodType(u32),
|
||||
/// Index of a [`crate::MethodHandleItem`] in `method_handles`
|
||||
MethodHandle(u32),
|
||||
/// Index of a [`crate::StringIdItem`] in `string_ids`
|
||||
String(u32),
|
||||
/// Index of a [`crate::TypeIdItem`] in `type_ids`
|
||||
Type(u32),
|
||||
/// Index of a [`crate::FieldIdItem`] in `field_ids`
|
||||
Field(u32),
|
||||
/// Index of a [`crate::MethodIdItem`] in `method_ids`
|
||||
Method(u32),
|
||||
/// Index of a [`crate::FieldIdItem`] in `field_ids` representing an enum.
|
||||
Enum(u32),
|
||||
Array(EncodedArray),
|
||||
Annotation(EncodedAnnotation),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue