diff --git a/TODO.md b/TODO.md index bf07a08..6fce29f 100644 --- a/TODO.md +++ b/TODO.md @@ -1,11 +1,8 @@ -- method (what's left to do except code?) - generate .dex -- code - edditable code format - json serialize with serde - sanity checks - tests -- PyRef https://pyo3.rs/v0.20.0/faq.html#pyo3get-clones-my-field - https://source.android.com/docs/core/runtime/dex-format#system-annotation diff --git a/androscalpel/src/annotation.rs b/androscalpel/src/annotation.rs index d3cb821..816c3df 100644 --- a/androscalpel/src/annotation.rs +++ b/androscalpel/src/annotation.rs @@ -13,17 +13,17 @@ use crate::{ pub struct DexAnnotationItem { // TODO: the get/set will probably be wonky on the python side when edditing /// The actual annotation - #[pyo3(get, set)] + #[pyo3(get)] pub annotation: DexAnnotation, // TODO: enforce exclusivity /// If the annotation visibility is set to build - #[pyo3(get, set)] + #[pyo3(get)] pub visibility_build: bool, /// If the annotation visibility is set to runtime - #[pyo3(get, set)] + #[pyo3(get)] pub visibility_runtime: bool, /// If the annotation visibility is set to system - #[pyo3(get, set)] + #[pyo3(get)] pub visibility_system: bool, } @@ -101,11 +101,11 @@ impl DexAnnotationItem { pub struct DexAnnotation { // TODO: check the relation between type and encoded_value. /// The type of the annotation. - #[pyo3(get, set)] + #[pyo3(get)] pub type_: IdType, // TODO: the get/set will probably be wonky on the python side when edditing /// The annotation elements. - #[pyo3(get, set)] + #[pyo3(get)] pub elements: HashMap, // TODO: check MemberName syntax? } diff --git a/androscalpel/src/apk.rs b/androscalpel/src/apk.rs index bf97a4c..41581b9 100644 --- a/androscalpel/src/apk.rs +++ b/androscalpel/src/apk.rs @@ -17,7 +17,7 @@ use androscalpel_serializer::*; #[pyclass] #[derive(Debug, Clone)] pub struct Apk { - #[pyo3(get, set)] + #[pyo3(get)] pub classes: HashMap, } diff --git a/androscalpel/src/class.rs b/androscalpel/src/class.rs index 844d151..df90a33 100644 --- a/androscalpel/src/class.rs +++ b/androscalpel/src/class.rs @@ -16,60 +16,60 @@ use androscalpel_serializer::consts::*; pub struct Class { /// Type, format described at /// - #[pyo3(get, set)] + #[pyo3(get)] pub descriptor: IdType, /// If the class is visible everywhere - #[pyo3(get, set)] + #[pyo3(get)] pub is_public: bool, /// If the class is subclassable - #[pyo3(get, set)] + #[pyo3(get)] pub is_final: bool, /// If the class is a 'multipy-implementable abstract class' AKA an interface - #[pyo3(get, set)] + #[pyo3(get)] pub is_interface: bool, /// If the class is instanciable - #[pyo3(get, set)] + #[pyo3(get)] pub is_abstract: bool, /// If the class is not directly defined in the source code - #[pyo3(get, set)] + #[pyo3(get)] pub is_synthetic: bool, /// If the class is an annotation - #[pyo3(get, set)] + #[pyo3(get)] pub is_annotation: bool, /// If the class is an enum - #[pyo3(get, set)] + #[pyo3(get)] pub is_enum: bool, /// Name of the superclass, format described at /// - #[pyo3(get, set)] + #[pyo3(get)] pub superclass: Option, /// List of the interfaces that class implement, format of the interfaces /// name is discribed at /// - #[pyo3(get, set)] + #[pyo3(get)] pub interfaces: Vec, /// Name of the source file where this class is defined. - #[pyo3(get, set)] + #[pyo3(get)] pub source_file: Option, /// The static fields - #[pyo3(get, set)] + #[pyo3(get)] pub static_fields: HashMap, /// The instance fields - #[pyo3(get, set)] + #[pyo3(get)] pub instance_fields: HashMap, /// The direct (static, private or constructor) methods of the class - #[pyo3(get, set)] + #[pyo3(get)] pub direct_methods: HashMap, /// The virtual (ie non direct) methods of the class - #[pyo3(get, set)] + #[pyo3(get)] pub virtual_methods: HashMap, // Do we need to distinguish direct and virtual (all the other) methods? // Maybe overlapping descriptor (same name, class and proto?) /// The annotation related to this class (note: this does not include the /// methods/field/parameters annotations, they are stored in the methods and fields /// structutres) - #[pyo3(get, set)] + #[pyo3(get)] pub annotations: Vec, } diff --git a/androscalpel/src/code.rs b/androscalpel/src/code.rs index 05cd306..6c3f9da 100644 --- a/androscalpel/src/code.rs +++ b/androscalpel/src/code.rs @@ -16,22 +16,22 @@ use crate::{ins::Instruction, DexString, IdField, IdMethod, IdMethodType, IdType pub struct Code { // TODO: remove and compute this value from code? /// The number of registers used by the code - #[pyo3(get, set)] + #[pyo3(get)] pub registers_size: u16, // TODO: what does it means? is it computable? /// The number of words of incoming arguments to the method - #[pyo3(get, set)] + #[pyo3(get)] pub ins_size: u16, // TODO: what does it means? is it computable? /// The number of words of outgoing argument space - #[pyo3(get, set)] + #[pyo3(get)] pub outs_size: u16, // TODO: implement /// The debug info - #[pyo3(get, set)] + #[pyo3(get)] pub debug_info: Vec, /// The instructions. - #[pyo3(get, set)] + #[pyo3(get)] pub insns: Vec, } diff --git a/androscalpel/src/dex_id.rs b/androscalpel/src/dex_id.rs index 6911d83..a35a9b4 100644 --- a/androscalpel/src/dex_id.rs +++ b/androscalpel/src/dex_id.rs @@ -430,13 +430,13 @@ impl IdType { pub struct IdField { /// The name of the field, format described at /// - #[pyo3(get, set)] + #[pyo3(get)] pub name: DexString, /// The type of the field. - #[pyo3(get, set)] + #[pyo3(get)] pub type_: IdType, /// The class that own the field. - #[pyo3(get, set)] + #[pyo3(get)] pub class_: IdType, } @@ -525,13 +525,13 @@ impl PartialOrd for IdField { #[derive(Debug, Clone, PartialEq, Eq, Hash)] pub struct IdMethod { /// The class containing the method. - #[pyo3(get, set)] + #[pyo3(get)] pub class_: IdType, /// The prototype (aka type or signature) of the method. - #[pyo3(get, set)] + #[pyo3(get)] pub proto: IdMethodType, /// The name of the method. - #[pyo3(get, set)] + #[pyo3(get)] pub name: DexString, } diff --git a/androscalpel/src/field.rs b/androscalpel/src/field.rs index b7aa377..2e97fff 100644 --- a/androscalpel/src/field.rs +++ b/androscalpel/src/field.rs @@ -14,33 +14,33 @@ use androscalpel_serializer::consts::*; #[derive(Debug, Clone)] pub struct Field { /// The structure used to reference this field. - #[pyo3(get, set)] + #[pyo3(get)] pub descriptor: IdField, /// The field visibility - #[pyo3(get, set)] + #[pyo3(get)] pub visibility: FieldVisibility, /// If the field is defined for the class globally - #[pyo3(get, set)] + #[pyo3(get)] pub is_static: bool, /// If the field is immutable after construction - #[pyo3(get, set)] + #[pyo3(get)] pub is_final: bool, /// For thread safety - #[pyo3(get, set)] + #[pyo3(get)] pub is_volatile: bool, /// If the field should **not** be saved by default serialization - #[pyo3(get, set)] + #[pyo3(get)] pub is_transient: bool, /// If the field is not defined in the source code - #[pyo3(get, set)] + #[pyo3(get)] pub is_synthetic: bool, /// If the field is an enumerated value - #[pyo3(get, set)] + #[pyo3(get)] pub is_enum: bool, /// The default value of this field pub value: Option, /// The annotations for this field - #[pyo3(get, set)] + #[pyo3(get)] pub annotations: Vec, } diff --git a/androscalpel/src/instructions.rs b/androscalpel/src/instructions.rs index 5d57141..7f6150d 100644 --- a/androscalpel/src/instructions.rs +++ b/androscalpel/src/instructions.rs @@ -3463,13 +3463,13 @@ impl IntoPy for Instruction { #[pyclass] #[derive(Debug, Clone)] pub struct CallSite { - #[pyo3(get, set)] + #[pyo3(get)] pub method_handle: MethodHandle, - #[pyo3(get, set)] + #[pyo3(get)] pub name: DexString, - #[pyo3(get, set)] + #[pyo3(get)] pub type_: IdMethodType, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -3696,9 +3696,9 @@ impl Nop { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Move { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u16, - #[pyo3(get, set)] + #[pyo3(get)] pub to: u16, } @@ -3815,9 +3815,9 @@ impl Move { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveWide { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u16, - #[pyo3(get, set)] + #[pyo3(get)] pub to: u16, } @@ -3933,9 +3933,9 @@ impl MoveWide { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveObject { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u16, - #[pyo3(get, set)] + #[pyo3(get)] pub to: u16, } @@ -4044,7 +4044,7 @@ impl MoveObject { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveResult { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -4140,7 +4140,7 @@ impl MoveResult { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveResultWide { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -4236,7 +4236,7 @@ impl MoveResultWide { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveResultObject { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -4332,7 +4332,7 @@ impl MoveResultObject { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MoveException { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -4524,7 +4524,7 @@ impl ReturnVoid { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Return { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -4620,7 +4620,7 @@ impl Return { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ReturnWide { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -4716,7 +4716,7 @@ impl ReturnWide { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ReturnObject { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -4820,9 +4820,9 @@ impl ReturnObject { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Const { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: i32, } @@ -4944,9 +4944,9 @@ impl Const { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ConstWide { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: i64, } @@ -5066,9 +5066,9 @@ impl ConstWide { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct ConstString { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: DexString, } @@ -5167,9 +5167,9 @@ impl ConstString { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct ConstClass { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: IdType, } @@ -5272,7 +5272,7 @@ impl ConstClass { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MonitorEnter { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -5368,7 +5368,7 @@ impl MonitorEnter { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct MonitorExit { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -5465,9 +5465,9 @@ impl MonitorExit { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct CheckCast { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: IdType, } @@ -5571,11 +5571,11 @@ impl CheckCast { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InstanceOf { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: IdType, } @@ -5704,9 +5704,9 @@ impl InstanceOf { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct ArrayLength { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, } @@ -5821,9 +5821,9 @@ impl ArrayLength { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct NewInstance { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: IdType, } @@ -5926,11 +5926,11 @@ impl NewInstance { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct NewArray { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub size_reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub lit: IdType, } @@ -6067,9 +6067,9 @@ impl NewArray { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct FilledNewArray { - #[pyo3(get, set)] + #[pyo3(get)] pub type_: IdType, - #[pyo3(get, set)] + #[pyo3(get)] pub reg_values: Vec, } @@ -6279,11 +6279,11 @@ impl FilledNewArray { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct FillArrayData { - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub elt_width: u16, - #[pyo3(get, set)] + #[pyo3(get)] pub data: Vec, } @@ -6437,7 +6437,7 @@ impl FillArrayData { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct Throw { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, } @@ -6533,7 +6533,7 @@ impl Throw { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct Goto { - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -6673,9 +6673,9 @@ impl Goto { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct Switch { - #[pyo3(get, set)] + #[pyo3(get)] pub reg: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub branches: HashMap, } @@ -6800,11 +6800,11 @@ impl Switch { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CmpLFloat { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub c: u8, } @@ -6910,11 +6910,11 @@ impl CmpLFloat { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CmpGFloat { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub c: u8, } @@ -7020,11 +7020,11 @@ impl CmpGFloat { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CmpLDouble { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub c: u8, } @@ -7130,11 +7130,11 @@ impl CmpLDouble { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CmpGDouble { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub c: u8, } @@ -7239,11 +7239,11 @@ impl CmpGDouble { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct CmpLong { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub c: u8, } @@ -7344,11 +7344,11 @@ impl CmpLong { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfEq { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -7466,11 +7466,11 @@ impl IfEq { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfNe { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -7589,11 +7589,11 @@ impl IfNe { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfLt { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -7712,11 +7712,11 @@ impl IfLt { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfGe { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -7835,11 +7835,11 @@ impl IfGe { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfGt { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -7958,11 +7958,11 @@ impl IfGt { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfLe { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub b: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8081,9 +8081,9 @@ impl IfLe { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfEqZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8184,9 +8184,9 @@ impl IfEqZ { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfNeZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8287,9 +8287,9 @@ impl IfNeZ { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfLtZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8390,9 +8390,9 @@ impl IfLtZ { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfGeZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8493,9 +8493,9 @@ impl IfGeZ { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfGtZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8596,9 +8596,9 @@ impl IfGtZ { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IfLeZ { - #[pyo3(get, set)] + #[pyo3(get)] pub a: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub label: String, } @@ -8699,11 +8699,11 @@ impl IfLeZ { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGet { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -8804,11 +8804,11 @@ impl AGet { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetWide { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -8909,11 +8909,11 @@ impl AGetWide { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetObject { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9014,11 +9014,11 @@ impl AGetObject { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9119,11 +9119,11 @@ impl AGetBoolean { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetByte { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9224,11 +9224,11 @@ impl AGetByte { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetChar { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9329,11 +9329,11 @@ impl AGetChar { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct AGetShort { - #[pyo3(get, set)] + #[pyo3(get)] pub dest: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9434,11 +9434,11 @@ impl AGetShort { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APut { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9539,11 +9539,11 @@ impl APut { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutWide { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9644,11 +9644,11 @@ impl APutWide { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutObject { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9749,11 +9749,11 @@ impl APutObject { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9854,11 +9854,11 @@ impl APutBoolean { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutByte { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -9959,11 +9959,11 @@ impl APutByte { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutChar { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -10064,11 +10064,11 @@ impl APutChar { #[pyclass] #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct APutShort { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub arr: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub idx: u8, } @@ -10171,11 +10171,11 @@ impl APutShort { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGet { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10303,11 +10303,11 @@ impl IGet { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetWide { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10439,11 +10439,11 @@ impl IGetWide { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetObject { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10575,11 +10575,11 @@ impl IGetObject { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10712,11 +10712,11 @@ impl IGetBoolean { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetByte { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10848,11 +10848,11 @@ impl IGetByte { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetChar { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -10984,11 +10984,11 @@ impl IGetChar { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IGetShort { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11120,11 +11120,11 @@ impl IGetShort { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPut { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11252,11 +11252,11 @@ impl IPut { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutWide { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11388,11 +11388,11 @@ impl IPutWide { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutObject { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11524,11 +11524,11 @@ impl IPutObject { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11660,11 +11660,11 @@ impl IPutBoolean { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutByte { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11796,11 +11796,11 @@ impl IPutByte { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutChar { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -11932,11 +11932,11 @@ impl IPutChar { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct IPutShort { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub obj: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12066,9 +12066,9 @@ impl IPutShort { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGet { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12169,9 +12169,9 @@ impl SGet { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetWide { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12276,9 +12276,9 @@ impl SGetWide { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetObject { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12383,9 +12383,9 @@ impl SGetObject { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12490,9 +12490,9 @@ impl SGetBoolean { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetByte { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12597,9 +12597,9 @@ impl SGetByte { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetChar { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12704,9 +12704,9 @@ impl SGetChar { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SGetShort { - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12811,9 +12811,9 @@ impl SGetShort { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPut { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -12919,9 +12919,9 @@ impl SPut { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutWide { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13026,9 +13026,9 @@ impl SPutWide { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutObject { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13133,9 +13133,9 @@ impl SPutObject { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutBoolean { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13240,9 +13240,9 @@ impl SPutBoolean { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutByte { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13347,9 +13347,9 @@ impl SPutByte { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutChar { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13454,9 +13454,9 @@ impl SPutChar { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct SPutShort { - #[pyo3(get, set)] + #[pyo3(get)] pub from: u8, - #[pyo3(get, set)] + #[pyo3(get)] pub field: IdField, } @@ -13561,9 +13561,9 @@ impl SPutShort { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokeVirtual { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -13768,9 +13768,9 @@ impl InvokeVirtual { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokeSuper { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -13975,9 +13975,9 @@ impl InvokeSuper { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokeDirect { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -14182,9 +14182,9 @@ impl InvokeDirect { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokeStatic { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -14389,9 +14389,9 @@ impl InvokeStatic { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokeInterface { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -25722,11 +25722,11 @@ impl UshrIntLit { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct InvokePolymorphic { - #[pyo3(get, set)] + #[pyo3(get)] pub method: IdMethod, - #[pyo3(get, set)] + #[pyo3(get)] pub proto: IdMethodType, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -25950,9 +25950,9 @@ impl InvokePolymorphic { #[pyclass] #[derive(Debug, Clone)] pub struct InvokeCustom { - #[pyo3(get, set)] + #[pyo3(get)] pub call_site: CallSite, - #[pyo3(get, set)] + #[pyo3(get)] pub args: Vec, } @@ -26155,9 +26155,9 @@ impl InvokeCustom { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct ConstMethodHandle { - #[pyo3(get, set)] + #[pyo3(get)] pub handle: MethodHandle, - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -26260,9 +26260,9 @@ impl ConstMethodHandle { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct ConstMethodType { - #[pyo3(get, set)] + #[pyo3(get)] pub proto: IdMethodType, - #[pyo3(get, set)] + #[pyo3(get)] pub to: u8, } @@ -26367,7 +26367,7 @@ impl ConstMethodType { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct Try { - #[pyo3(get, set)] + #[pyo3(get)] pub end_label: String, /// The list of exceptions and their associated handler label. /// @@ -26375,9 +26375,9 @@ pub struct Try { /// /// The handler are sorted: if severat Exception Type match an exceptions, the /// the handler used is the first in the list. - #[pyo3(get, set)] + #[pyo3(get)] pub handlers: Vec<(IdType, String)>, - #[pyo3(get, set)] + #[pyo3(get)] pub default_handler: Option, } @@ -26504,7 +26504,7 @@ impl Try { #[pyclass] #[derive(Debug, Clone, PartialEq, Eq)] pub struct Label { - #[pyo3(get, set)] + #[pyo3(get)] pub name: String, } diff --git a/androscalpel/src/method.rs b/androscalpel/src/method.rs index 9820749..0c91295 100644 --- a/androscalpel/src/method.rs +++ b/androscalpel/src/method.rs @@ -14,55 +14,55 @@ use androscalpel_serializer::consts::*; #[derive(Debug, Clone)] pub struct Method { /// The structure used to reference this method. - #[pyo3(get, set)] + #[pyo3(get)] pub descriptor: IdMethod, /// The field visibility. - #[pyo3(get, set)] + #[pyo3(get)] pub visibility: MethodVisibility, /// Static methods do not take this in argument. - #[pyo3(get, set)] + #[pyo3(get)] pub is_static: bool, /// Final methods are not averridable. - #[pyo3(get, set)] + #[pyo3(get)] pub is_final: bool, /// Synchronized method automatically acquire their associated lock around call. /// Can only be set in native method, (`[Self::is_native] = true`). - #[pyo3(get, set)] + #[pyo3(get)] pub is_synchronized: bool, /// Bridge are automatically added by the compiler as a type-safe bridge. - #[pyo3(get, set)] + #[pyo3(get)] pub is_bridge: bool, /// If the last argument should be treated as a "rest" argument by compiler /// (for method of variable number of argument). - #[pyo3(get, set)] + #[pyo3(get)] pub is_varargs: bool, /// If the method is a native method. - #[pyo3(get, set)] + #[pyo3(get)] pub is_native: bool, /// Abstract methods are not implemented by the class. - #[pyo3(get, set)] + #[pyo3(get)] pub is_abstract: bool, /// If the method must use strict rules for floating point arithmetic. - #[pyo3(get, set)] + #[pyo3(get)] pub is_strictfp: bool, /// Synthetic method are not directly defined in the source code. - #[pyo3(get, set)] + #[pyo3(get)] pub is_synthetic: bool, /// If the method is a constructor. - #[pyo3(get, set)] + #[pyo3(get)] pub is_constructor: bool, /// If the method is declared as synchronize (just indicatif) - #[pyo3(get, set)] + #[pyo3(get)] pub is_declared_syncrhonized: bool, /// The annotations for this method - #[pyo3(get, set)] + #[pyo3(get)] pub annotations: Vec, /// The annotations for the parameters of this method method - #[pyo3(get, set)] + #[pyo3(get)] pub parameters_annotations: Vec>, /// The code of the method - #[pyo3(get, set)] + #[pyo3(get)] pub code: Option, } diff --git a/test.py b/test.py index 0f14568..553135f 100644 --- a/test.py +++ b/test.py @@ -37,13 +37,13 @@ new_insns = [] for i in code.insns: if isinstance(i, asc.ins.ConstString): if i.lit == "Hello": - i.lit = DexString("Degemer Mat") + i = asc.ins.ConstString(i.reg, DexString("Degemer Mat")) elif i.lit == "Bye": - i.lit = DexString("Kenavo") + i = asc.ins.ConstString(i.reg, DexString("Kenavo")) new_insns.append(i) # This need improving! -code.insns = new_insns +code = asc.Code(code.registers_size, code.ins_size, code.outs_size, new_insns) apk.set_method_code(method_id, code) # apk.set_method_code(method.descriptor, code) @@ -57,5 +57,19 @@ for i in code.insns: dex_raw = apk.gen_raw_dex() assert len(dex_raw) == 1 -with open(DEX_NAME + ".out", "wb") as file: +with open(DEX_NAME, "wb") as file: file.write(dex_raw[0]) + + +with open(DEX_NAME, "rb") as file: + dex = file.read() +new_apk = asc.Apk() +new_apk.add_dex_file(dex) + +clazz = new_apk.classes[clazz_id] +method = clazz.virtual_methods[method_id] +code = method.code + +print(f"Code of {method_id} in new apk") +for i in code.insns: + print(i)