From 52447aef425d018b3172ca457b965611e0e402fa Mon Sep 17 00:00:00 2001 From: Jean-Marie Mineau Date: Fri, 25 Aug 2023 14:41:39 +0200 Subject: [PATCH] add header item --- androscalpel_serializer/src/items/header.rs | 33 +++++++++++++++++++++ androscalpel_serializer/src/items/mod.rs | 7 +++++ 2 files changed, 40 insertions(+) create mode 100644 androscalpel_serializer/src/items/header.rs create mode 100644 androscalpel_serializer/src/items/mod.rs diff --git a/androscalpel_serializer/src/items/header.rs b/androscalpel_serializer/src/items/header.rs new file mode 100644 index 0000000..36557f6 --- /dev/null +++ b/androscalpel_serializer/src/items/header.rs @@ -0,0 +1,33 @@ +//! The header item: https://source.android.com/docs/core/runtime/dex-format#header-item + +use crate::{DexFileMagic, EndianConstant}; + +/// The header item: https://source.android.com/docs/core/runtime/dex-format#header-item +#[derive(Serializable, PartialEq, Eq, Debug)] +pub struct UserItem { + pub magic: DexFileMagic, + pub checksum: u32, + pub signature: [u8; 20], + pub file_size: u32, + pub header_size: u32, // should be = 0x70 + pub endian_tag: EndianConstant, + pub link_size: u32, // should be 0 + pub link_off: u32, // should be 0 + pub map_off: u32, + pub string_ids_size: u32, + pub string_ids_off: u32, + pub type_ids_size: u32, // At most 0xffff + pub type_ids_off: u32, + pub proto_ids_size: u32, // At most 0xffff + pub proto_ids_off: u32, + pub field_ids_size: u32, + pub field_ids_off: u32, + pub method_ids_size: u32, + pub method_ids_off: u32, + pub class_defs_size: u32, + pub class_defs_off: u32, + pub data_size: u32, // Must be an even multiple of sizeof(uint) -> % 8 = 0 + pub data_off: u32, +} + +// TODO: add checks diff --git a/androscalpel_serializer/src/items/mod.rs b/androscalpel_serializer/src/items/mod.rs new file mode 100644 index 0000000..5e5b83d --- /dev/null +++ b/androscalpel_serializer/src/items/mod.rs @@ -0,0 +1,7 @@ +//! The items structures. + +pub mod header; +pub mod map; + +pub use header::*; +pub use map::*;