WIP
This commit is contained in:
parent
559ae665cf
commit
68b11dc036
5 changed files with 91 additions and 12 deletions
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
use crate::{
|
||||
CallSiteIdItem, ClassDefItem, EndianConstant, Error, FieldIdItem, HeaderItem, MapItemType,
|
||||
MapList, MethodHandleItem, MethodIdItem, ProtoIdItem, Result, Serializable, StringIdItem,
|
||||
TypeIdItem,
|
||||
MapList, MethodHandleItem, MethodIdItem, ProtoIdItem, Result, Serializable, StringDataItem,
|
||||
StringIdItem, TypeIdItem,
|
||||
};
|
||||
use std::io::{Cursor, Seek, SeekFrom};
|
||||
|
||||
|
|
@ -127,6 +127,21 @@ impl<'a> DexFileReader<'a> {
|
|||
&self.map_list
|
||||
}
|
||||
|
||||
/// Return the [`StringDataItem`] of from its idx.
|
||||
pub fn get_string(&self, idx: u32) -> Result<StringDataItem> {
|
||||
let id = self
|
||||
.string_ids
|
||||
.get(idx as usize)
|
||||
.ok_or(Error::InconsistantStruct(format!(
|
||||
"string idx {idx} is out of bound (|string_ids|={})",
|
||||
self.string_ids.len()
|
||||
)))?;
|
||||
self.get_struct_at_offset(id.string_data_off)
|
||||
.map_err(|err| {
|
||||
Error::DeserializationError(format!("Failled to parse string {idx}: {err}"))
|
||||
})
|
||||
}
|
||||
|
||||
fn sanity_check(&self) -> Result<()> {
|
||||
if self.header.magic.version != [0x30, 0x33, 0x39] {
|
||||
println!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue