some work on DexType and DexMethodType

This commit is contained in:
Jean-Marie Mineau 2023-09-04 16:36:15 +02:00
parent cc6ce1c625
commit 2ec3fe2c9d
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
4 changed files with 127 additions and 28 deletions

View file

@ -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!(