add method handle

This really needs more checks
This commit is contained in:
Jean-Marie Mineau 2023-10-02 17:55:17 +02:00
parent 77be653786
commit feff847310
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
6 changed files with 351 additions and 36 deletions

View file

@ -184,6 +184,16 @@ impl<'a> DexFileReader<'a> {
)))
}
/// Return a [`MethodHandleItem`] reference from its idx.
pub fn get_method_handle(&self, idx: usize) -> Result<&MethodHandleItem> {
self.method_handles
.get(idx)
.ok_or(Error::InconsistantStruct(format!(
"method handle {idx} is out of bound (|method_handles|={})",
self.method_handles.len()
)))
}
fn sanity_check(&self) -> Result<()> {
if self.header.magic.version != [0x30, 0x33, 0x39] {
warn!(