add item related to class

This commit is contained in:
Jean-Marie Mineau 2023-08-25 19:05:05 +02:00
parent 42698cc8d7
commit 9ed99594cc
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
4 changed files with 293 additions and 6 deletions

View file

@ -1,11 +1,13 @@
//! The items structures.
use crate as androscalpel_serializer;
use crate::Serializable;
use crate::{EncodedArray, Serializable};
pub mod class;
pub mod header;
pub mod map;
pub use class::*;
pub use header::*;
pub use map::*;
@ -34,7 +36,7 @@ pub struct ProtoIdItem {
pub shorty_idx: u32,
/// Index of a [`TypeIdItem`] in `type_ids`.
pub return_type_idx: u32,
/// 0 if no parameter, else offset to a [`TypeList`.
/// 0 if no parameter, else offset to a [`TypeList`].
pub parameters_off: u32,
}
@ -42,7 +44,7 @@ pub struct ProtoIdItem {
/// alignment: 4 bytes
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
pub struct FieldIdItem {
/// Index of a [`TypeIdItem`] in `type_ids`], must be a class.
/// Index of a [`TypeIdItem`] in `type_ids`, must be a class.
pub class_idx: u16,
/// Index of a [`TypeIdItem`] in `type_ids`.
pub type_idx: u16,
@ -54,10 +56,42 @@ pub struct FieldIdItem {
/// alignment: 4 bytes
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
pub struct MethodIdItem {
/// Index of a [`TypeIdItem`] in `type_ids`], must be a class.
/// Index of a [`TypeIdItem`] in `type_ids`, must be a class.
pub class_idx: u16,
/// Index of a [`ProtoIdItem`] in `proto_ids`.
pub proto_idx: u16,
/// Index of a [`StringIdItem`] in [`HeaderItem.string_ids`].
pub name_idx: u32,
}
/// https://source.android.com/docs/core/runtime/dex-format#call-site-id-item
/// alignment: 4 bytes
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
pub struct CallSiteIdItem {
/// Offset to a [`CallSiteItem`].
pub call_site_off: u32,
}
/// https://source.android.com/docs/core/runtime/dex-format#encoded-array-item
/// alignment: none
#[derive(Serializable, Debug, Clone, PartialEq, Eq)]
pub struct EncodedArrayItem {
pub value: EncodedArray,
}
/// https://source.android.com/docs/core/runtime/dex-format#call-site-item
///
/// The call_site_item is an encoded_array_item whose elements correspond to
/// the arguments provided to a bootstrap linker method.
///
/// The first three arguments are:
/// - A method handle representing the bootstrap linker method ([`EncodedValue::MethodHandle`])
/// - A method name that the bootstrap linker should resolve ([`EncodedValue::String`])
/// - A method type corresponding to the type of the method name to be resolved
/// ([`EncodedValue::MethodType`])
///
/// Any additional arguments are constant values passed to the bootstrap linker method.
/// These arguments are passed in order and without any type conversions.
///
///
pub type CallSiteItem = EncodedArrayItem;