This commit is contained in:
Jean-Marie Mineau 2024-04-15 15:13:30 +02:00
parent d47494f8f6
commit ef6a2196a7
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
6 changed files with 580 additions and 9 deletions

View file

@ -50,7 +50,9 @@ impl<'a> DexFileReader<'a> {
method_handles: vec![],
map_list: MapList { list: vec![] },
};
tmp_file.map_list = tmp_file.get_struct_at_offset(tmp_file.header.map_off)?;
if tmp_file.header.map_off != 0 {
tmp_file.map_list = tmp_file.get_struct_at_offset(tmp_file.header.map_off)?;
}
tmp_file.string_ids = tmp_file.get_item_list::<StringIdItem>(
tmp_file.header.string_ids_off,
tmp_file.header.string_ids_size,
@ -365,6 +367,9 @@ impl<'a> DexFileReader<'a> {
}
fn get_item_list<T: Serializable>(&self, offset: u32, size: u32) -> Result<Vec<T>> {
if offset == 0 {
return Ok(vec![]);
}
let mut buffer = Cursor::new(self.data);
buffer.seek(SeekFrom::Start(offset as u64)).map_err(|err| {
Error::DeserializationError(format!("Failed to seek 0x{offset:x} position: {err}"))