add DexString::conctatenate and Idype::class_from_dex_string
This commit is contained in:
parent
4c4940e6b1
commit
fce80fe019
4 changed files with 29 additions and 2 deletions
|
|
@ -54,7 +54,7 @@ impl MethodCFG<'_> {
|
|||
return HashMap::new();
|
||||
}
|
||||
// Initialize the entry block from function signature:
|
||||
let mut i = (code.registers_size - code.ins_size(&self.method)) as usize;
|
||||
let mut i = (code.registers_size - code.ins_size(self.method)) as usize;
|
||||
if !self.method.is_static {
|
||||
end_block_reg_tys[0][i] = RegType::Object; // 'this'
|
||||
i += 1;
|
||||
|
|
|
|||
|
|
@ -428,6 +428,17 @@ impl IdType {
|
|||
Self(format!("L{name};").into())
|
||||
}
|
||||
|
||||
/// Return the type for the class of fully qualified name `name`.
|
||||
/// Same as [`IdType::class`] but with a [`DexString`] name.
|
||||
#[cfg_attr(feature = "python", staticmethod)]
|
||||
pub fn class_from_dex_string(name: &DexString) -> Self {
|
||||
let mut repr = name.clone();
|
||||
repr.0.utf16_size.0 += 2;
|
||||
repr.0.data.insert(0, b'L');
|
||||
repr.0.data.push(b';');
|
||||
Self(repr)
|
||||
}
|
||||
|
||||
/// Return the type for an array of the specify `type_`
|
||||
#[cfg_attr(feature = "python", staticmethod)]
|
||||
pub fn array(type_: &IdType) -> Self {
|
||||
|
|
|
|||
|
|
@ -210,4 +210,20 @@ impl DexString {
|
|||
strings.insert(self.clone());
|
||||
strings
|
||||
}
|
||||
|
||||
/// Build the concatenation of two string.
|
||||
pub fn conctatenate(&self, other: &Self) -> Self {
|
||||
let Self(androscalpel_serializer::StringDataItem {
|
||||
utf16_size: androscalpel_serializer::Uleb128(size1),
|
||||
data: data1,
|
||||
}) = self.clone();
|
||||
let Self(androscalpel_serializer::StringDataItem {
|
||||
utf16_size: androscalpel_serializer::Uleb128(size2),
|
||||
data: data2,
|
||||
}) = other.clone();
|
||||
Self(androscalpel_serializer::StringDataItem {
|
||||
utf16_size: androscalpel_serializer::Uleb128(size1 + size2),
|
||||
data: data1.into_iter().chain(data2).collect(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -424,7 +424,7 @@ impl DexWriter {
|
|||
.unwrap()
|
||||
};
|
||||
let code = method.code.as_ref().unwrap().clone();
|
||||
let ins_size = code.ins_size(&method);
|
||||
let ins_size = code.ins_size(method);
|
||||
let outs_size = code.outs_size();
|
||||
// Estimate instructions addresses
|
||||
let mut min_addr = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue