clean doc
This commit is contained in:
parent
b5ae8c5088
commit
df2a441148
13 changed files with 84 additions and 80 deletions
|
|
@ -4,25 +4,25 @@ use crate as androscalpel_serializer;
|
|||
use crate::{ReadSeek, Result, Serializable, Uleb128};
|
||||
use std::io::Write;
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#class-def-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#class-def-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ClassDefItem {
|
||||
/// Index of a [`TypeIdItem`] in `type_ids`, must be a class.
|
||||
/// Index of a [`crate::TypeIdItem`] in `type_ids`, must be a class.
|
||||
pub class_idx: u32,
|
||||
/// See [access-flags](https://source.android.com/docs/core/runtime/dex-format#access-flags)
|
||||
/// See <https://source.android.com/docs/core/runtime/dex-format#access-flags>
|
||||
pub access_flags: u32,
|
||||
/// Either index of a [`TypeIdItem`] in `type_ids`, must be a class or NO_INDEX
|
||||
/// Either index of a [`crate::TypeIdItem`] in `type_ids`, must be a class or NO_INDEX
|
||||
pub superclass_idx: u32,
|
||||
/// 0 if no interfaces, else offset to a [`TypeList`].
|
||||
/// 0 if no interfaces, else offset to a [`crate::TypeList`].
|
||||
pub interfaces_off: u32,
|
||||
/// Index of a [`StringIdItem`] in `string_ids` or NO_INDEX.
|
||||
/// Index of a [`crate::StringIdItem`] in `string_ids` or [`crate::NO_INDEX`].
|
||||
pub source_file_idx: u32,
|
||||
/// 0 if no annotation, else offset to a [`AnnotationDirectoryItem`].
|
||||
/// 0 if no annotation, else offset to a [`crate::AnnotationDirectoryItem`].
|
||||
pub annotations_off: u32,
|
||||
/// 0 if no data for this class, else offset to a [`ClassDataItem`].
|
||||
/// 0 if no data for this class, else offset to a [`crate::ClassDataItem`].
|
||||
pub class_data_off: u32,
|
||||
/// 0 if no static fields, else offset to an [`EncodedArrayItem`].
|
||||
/// 0 if no static fields, else offset to an [`crate::EncodedArrayItem`].
|
||||
///
|
||||
/// Notes:
|
||||
///
|
||||
|
|
@ -36,7 +36,7 @@ pub struct ClassDefItem {
|
|||
pub static_values_off: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#method-handle-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#method-handle-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct MethodHandleItem {
|
||||
|
|
@ -46,7 +46,7 @@ pub struct MethodHandleItem {
|
|||
pub unused2: u16,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#method-handle-type-codes
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#method-handle-type-codes>
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[prefix_type(u16)]
|
||||
pub enum MethodHandleType {
|
||||
|
|
@ -70,7 +70,7 @@ pub enum MethodHandleType {
|
|||
InvokeInterface,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#class-data-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#class-data-item>
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ClassDataItem {
|
||||
// pub static_fields_size: Uleb128,
|
||||
|
|
@ -180,7 +180,7 @@ impl Serializable for ClassDataItem {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-field-format
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#encoded-field-format>
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct EncodedField {
|
||||
/// Index into the `field_ids` list for the identity of this field
|
||||
|
|
@ -191,7 +191,7 @@ pub struct EncodedField {
|
|||
pub access_flags: Uleb128,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-method
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#encoded-method>
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct EncodedMethod {
|
||||
/// Index into the `method_ids list` for the identity of this method
|
||||
|
|
@ -200,11 +200,11 @@ pub struct EncodedMethod {
|
|||
/// first element in a list is represented directly.
|
||||
pub method_idx_diff: Uleb128,
|
||||
pub access_flags: Uleb128,
|
||||
/// 0 if abstract or native, else offset to a [`CodeItem`].
|
||||
/// 0 if abstract or native, else offset to a [`crate::CodeItem`].
|
||||
pub code_off: Uleb128,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#type-list
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#type-list>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TypeList {
|
||||
|
|
@ -244,7 +244,7 @@ impl Serializable for TypeList {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#type-item-format
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#type-item-format>
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct TypeItem {
|
||||
/// Index into the `type_ids` list.
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate as androscalpel_serializer;
|
|||
use crate::{Error, ReadSeek, Result, Serializable, Sleb128, Uleb128};
|
||||
use std::io::Write;
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#code-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#code-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct CodeItem {
|
||||
|
|
@ -12,7 +12,7 @@ pub struct CodeItem {
|
|||
pub ins_size: u16,
|
||||
pub outs_size: u16,
|
||||
// pub tries_size: u16,
|
||||
/// 0 if no debug info, else offset to a [`DebugInfoItem`].
|
||||
/// 0 if no debug info, else offset to a [`crate::DebugInfoItem`].
|
||||
pub debug_info_off: u32,
|
||||
// pub insns_size: u32,
|
||||
pub insns: Vec<u16>,
|
||||
|
|
@ -166,7 +166,7 @@ impl Serializable for CodeItem {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#type-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#type-item>
|
||||
#[derive(Serializable, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct TryItem {
|
||||
/// Start address of the block of code covered. It's a count of 16-bit code unit to the
|
||||
|
|
@ -179,7 +179,7 @@ pub struct TryItem {
|
|||
pub handler_off: u16,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-catch-handlerlist
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#encoded-catch-handlerlist>
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct EncodedCatchHandlerList {
|
||||
// pub size: Uleb128,
|
||||
|
|
@ -191,9 +191,9 @@ impl EncodedCatchHandlerList {
|
|||
Uleb128(self.list.len() as u32)
|
||||
}
|
||||
|
||||
/// Return a reference to the [`EncodedCatchHandler`] located at `offset` bytes after
|
||||
/// the begining of the [`EncodedCatchHandlerList`]. Expected to be used to lookup
|
||||
/// the value refered to by [`TryItem.handler_off`].
|
||||
/// Return a reference to the [`crate::EncodedCatchHandler`] located at `offset` bytes after
|
||||
/// the begining of the [`crate::EncodedCatchHandlerList`]. Expected to be used to lookup
|
||||
/// the value refered to by [`crate::TryItem.handler_off`].
|
||||
pub fn get_handler_at_offset(&self, offset: u16) -> Result<&EncodedCatchHandler> {
|
||||
let offset = offset as usize;
|
||||
let mut current_offset = 0;
|
||||
|
|
@ -238,7 +238,7 @@ impl Serializable for EncodedCatchHandlerList {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-catch-handler
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#encoded-catch-handler>
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct EncodedCatchHandler {
|
||||
// pub size: Sleb128,
|
||||
|
|
@ -313,10 +313,10 @@ impl Serializable for EncodedCatchHandler {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-type-addr-pair
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#encoded-type-addr-pair>
|
||||
#[derive(Serializable, Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct EncodedTypeAddrPair {
|
||||
/// Index of the [`TypeId`] in `type_ids`
|
||||
/// Index of the [`crate::TypeIdItem`] in `type_ids`
|
||||
pub type_idx: Uleb128,
|
||||
/// Bytecode address of the exception handler
|
||||
pub addr: Uleb128,
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
//! The header item: https://source.android.com/docs/core/runtime/dex-format#header-item
|
||||
//! The header item: <https://source.android.com/docs/core/runtime/dex-format#header-item>
|
||||
|
||||
use crate as androscalpel_serializer;
|
||||
use crate::{DexFileMagic, EndianConstant, Serializable};
|
||||
|
||||
/// The header item: https://source.android.com/docs/core/runtime/dex-format#header-item
|
||||
///
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#header-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, PartialEq, Eq, Debug)]
|
||||
pub struct UserItem {
|
||||
pub struct HeaderItem {
|
||||
pub magic: DexFileMagic,
|
||||
pub checksum: u32,
|
||||
pub signature: [u8; 20],
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate as androscalpel_serializer;
|
|||
use crate::{Error, ReadSeek, Result, Serializable, Uleb128};
|
||||
use std::io::{Cursor, Write};
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#hiddenapi-class-data-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#hiddenapi-class-data-item>
|
||||
/// Hard to serialize/deserialize without additional data like the number of classes
|
||||
/// or the method/field of the classes.
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
//! The map item: https://source.android.com/docs/core/runtime/dex-format#map-list
|
||||
//! The map item: <https://source.android.com/docs/core/runtime/dex-format#map-list>
|
||||
|
||||
use crate as androscalpel_serializer;
|
||||
use crate::core::{ReadSeek, Result, Serializable};
|
||||
use std::io::Write;
|
||||
|
||||
/// The map item: https://source.android.com/docs/core/runtime/dex-format#map-list
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#map-list>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Clone, PartialEq, Eq, Debug)]
|
||||
pub struct MapList {
|
||||
|
|
@ -12,7 +12,7 @@ pub struct MapList {
|
|||
pub list: Vec<MapItem>,
|
||||
}
|
||||
|
||||
/// The location and size of an item: https://source.android.com/docs/core/runtime/dex-format#map-item
|
||||
/// The location and size of an item: <https://source.android.com/docs/core/runtime/dex-format#map-item>
|
||||
#[derive(Serializable, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct MapItem {
|
||||
pub type_: MapItemType,
|
||||
|
|
@ -21,7 +21,7 @@ pub struct MapItem {
|
|||
pub offset: u32,
|
||||
}
|
||||
|
||||
/// The type of the items refered by a [`MapItem`]: https://source.android.com/docs/core/runtime/dex-format#type-codes
|
||||
/// The type of the items refered by a [`MapItem`]: <https://source.android.com/docs/core/runtime/dex-format#type-codes>
|
||||
#[derive(Serializable, Clone, Copy, PartialEq, Eq, Debug)]
|
||||
#[prefix_type(u16)]
|
||||
pub enum MapItemType {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ pub use header::*;
|
|||
pub use hiddenapi::*;
|
||||
pub use map::*;
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#string-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#string-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct StringIdItem {
|
||||
|
|
@ -24,7 +24,7 @@ pub struct StringIdItem {
|
|||
|
||||
pub use crate::StringDataItem;
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#type-id-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#type-id-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct TypeIdItem {
|
||||
|
|
@ -32,7 +32,7 @@ pub struct TypeIdItem {
|
|||
pub descriptor_idx: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#proto-id-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#proto-id-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ProtoIdItem {
|
||||
|
|
@ -44,7 +44,7 @@ pub struct ProtoIdItem {
|
|||
pub parameters_off: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#field-id-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#field-id-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct FieldIdItem {
|
||||
|
|
@ -56,7 +56,7 @@ pub struct FieldIdItem {
|
|||
pub name_idx: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#method-id-item
|
||||
/// <https://source.android.com/docs/core/runtime/dex-format#method-id-item>
|
||||
/// alignment: 4 bytes
|
||||
#[derive(Serializable, Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct MethodIdItem {
|
||||
|
|
@ -68,7 +68,7 @@ pub struct MethodIdItem {
|
|||
pub name_idx: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#call-site-id-item
|
||||
/// <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 {
|
||||
|
|
@ -76,23 +76,23 @@ pub struct CallSiteIdItem {
|
|||
pub call_site_off: u32,
|
||||
}
|
||||
|
||||
/// https://source.android.com/docs/core/runtime/dex-format#encoded-array-item
|
||||
/// <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
|
||||
/// <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 handle representing the bootstrap linker method ([`crate::EncodedValue::MethodHandle`])
|
||||
/// - A method name that the bootstrap linker should resolve ([`crate::EncodedValue::String`])
|
||||
/// - A method type corresponding to the type of the method name to be resolved
|
||||
/// ([`EncodedValue::MethodType`])
|
||||
/// ([`crate::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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue