swap literal priority

This commit is contained in:
Jean-Marie 'Histausse' Mineau 2024-02-08 15:50:42 +01:00
parent f5b5957ff5
commit 93f70040fd
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
3 changed files with 121 additions and 121 deletions

View file

@ -26584,20 +26584,20 @@ impl AddIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd0,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xd8, op: 0xd8,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd0,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -26760,20 +26760,20 @@ impl RsubIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd1,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xd9, op: 0xd9,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd1,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -26936,20 +26936,20 @@ impl MulIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd2,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xda, op: 0xda,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd2,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -27112,20 +27112,20 @@ impl DivIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd3,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xdb, op: 0xdb,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd3,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -27288,20 +27288,20 @@ impl RemIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd4,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xdc, op: 0xdc,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd4,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -27464,20 +27464,20 @@ impl AndIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd5,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xdd, op: 0xdd,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd5,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -27640,20 +27640,20 @@ impl OrIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd6,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xde, op: 0xde,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd6,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }
@ -27816,20 +27816,20 @@ impl XorIntLit {
{}", {}",
self.dest, self.b, self.lit self.dest, self.b, self.lit
) )
} else if reg_on_4_bit { } else if lit_on_8_bits {
InsFormat::Format22S {
op: 0xd7,
va: self.dest,
vb: self.b,
c: self.lit,
}
} else {
InsFormat::Format22B { InsFormat::Format22B {
op: 0xdf, op: 0xdf,
va: self.dest, va: self.dest,
vb: self.b, vb: self.b,
c: self.lit as i8, c: self.lit as i8,
} }
} else {
InsFormat::Format22S {
op: 0xd7,
va: self.dest,
vb: self.b,
c: self.lit,
}
} }
} }
} }

View file

@ -229,7 +229,7 @@ impl Instruction {
if v != 0 { if v != 0 {
// TODO: is it enforced on actual android system? // TODO: is it enforced on actual android system?
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '10x' (00|op) \ "Dalvik instruction format for op 0x{op:x}: '10x' (00|op) \
requires the first byte to be 0 found {v}" requires the first byte to be 0 found {v}"
))); )));
} }
@ -277,7 +277,7 @@ impl Instruction {
if v != 0 { if v != 0 {
// TODO: is it enforced on actual android system? // TODO: is it enforced on actual android system?
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '20t' (00|op AAAA) \ "Dalvik instruction format for op 0x{op:x}: '20t' (00|op AAAA) \
requires the first byte to be 0 found {v}" requires the first byte to be 0 found {v}"
))); )));
} }
@ -385,7 +385,7 @@ impl Instruction {
if v != 0 { if v != 0 {
// TODO: is it enforced on actual android system? // TODO: is it enforced on actual android system?
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '30t' (00|op AAAA AAAA) \ "Dalvik instruction format for op 0x{op:x}: '30t' (00|op AAAA AAAA) \
requires the first byte to be 0 found {v}" requires the first byte to be 0 found {v}"
))); )));
} }
@ -403,7 +403,7 @@ impl Instruction {
if v != 0 { if v != 0 {
// TODO: is it enforced on actual android system? // TODO: is it enforced on actual android system?
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '32x' (00|op AAAA BBBB) \ "Dalvik instruction format for op 0x{op:x}: '32x' (00|op AAAA BBBB) \
requires the first byte to be 0 found {v}" requires the first byte to be 0 found {v}"
))); )));
} }
@ -452,7 +452,7 @@ impl Instruction {
let vg = val & 0b0000_1111; let vg = val & 0b0000_1111;
if a > 5 { if a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
@ -485,7 +485,7 @@ impl Instruction {
let vg = val & 0b0000_1111; let vg = val & 0b0000_1111;
if a > 5 { if a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
@ -518,7 +518,7 @@ impl Instruction {
let vg = val & 0b0000_1111; let vg = val & 0b0000_1111;
if a > 5 { if a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
@ -575,7 +575,7 @@ impl Instruction {
let vg = val & 0b0000_1111; let vg = val & 0b0000_1111;
if a > 5 { if a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C HHHH) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C HHHH) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
@ -673,13 +673,13 @@ impl Serializable for Instruction {
Self::Format12X { vb, va, op } => { Self::Format12X { vb, va, op } => {
if vb & 0b1111_0000 != 0 { if vb & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '12x' (B|A|op) \ "Dalvik instruction format for op 0x{op:x}: '12x' (B|A|op) \
requires B to be between 0 and 15, found {vb}" requires B to be between 0 and 15, found {vb}"
))); )));
} }
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '12x' (B|A|op) \ "Dalvik instruction format for op 0x{op:x}: '12x' (B|A|op) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -690,14 +690,14 @@ impl Serializable for Instruction {
Self::Format11N { b, va, op } => { Self::Format11N { b, va, op } => {
if *b < -8 || *b > 7 { if *b < -8 || *b > 7 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '11n' (B|A|op) \ "Dalvik instruction format for op 0x{op:x}: '11n' (B|A|op) \
requires B to be between -8 and 7, found {b}" requires B to be between -8 and 7, found {b}"
))); )));
} }
let b = b.to_be_bytes()[0] & 0b0000_1111; let b = b.to_be_bytes()[0] & 0b0000_1111;
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '11n' (B|A|op) \ "Dalvik instruction format for op 0x{op:x}: '11n' (B|A|op) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -763,13 +763,13 @@ impl Serializable for Instruction {
Self::Format22T { vb, va, op, c } => { Self::Format22T { vb, va, op, c } => {
if vb & 0b1111_0000 != 0 { if vb & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22t' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22t' (B|A|op CCCC) \
requires B to be between 0 and 15, found {vb}" requires B to be between 0 and 15, found {vb}"
))); )));
} }
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22t' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22t' (B|A|op CCCC) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -781,13 +781,13 @@ impl Serializable for Instruction {
Self::Format22S { vb, va, op, c } => { Self::Format22S { vb, va, op, c } => {
if vb & 0b1111_0000 != 0 { if vb & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22s' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22s' (B|A|op CCCC) \
requires B to be between 0 and 15, found {vb}" requires B to be between 0 and 15, found {vb}"
))); )));
} }
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22s' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22s' (B|A|op CCCC) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -800,13 +800,13 @@ impl Serializable for Instruction {
Self::Format22C { vb, va, op, c } => { Self::Format22C { vb, va, op, c } => {
if vb & 0b1111_0000 != 0 { if vb & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22c' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22c' (B|A|op CCCC) \
requires B to be between 0 and 15, found {vb}" requires B to be between 0 and 15, found {vb}"
))); )));
} }
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22c' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22c' (B|A|op CCCC) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -818,13 +818,13 @@ impl Serializable for Instruction {
Self::Format22CS { vb, va, op, c } => { Self::Format22CS { vb, va, op, c } => {
if vb & 0b1111_0000 != 0 { if vb & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22cs' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22cs' (B|A|op CCCC) \
requires B to be between 0 and 15, found {vb}" requires B to be between 0 and 15, found {vb}"
))); )));
} }
if va & 0b1111_0000 != 0 { if va & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '22cs' (B|A|op CCCC) \ "Dalvik instruction format for op 0x{op:x}: '22cs' (B|A|op CCCC) \
requires A to be between 0 and 15, found {va}" requires A to be between 0 and 15, found {va}"
))); )));
} }
@ -887,37 +887,37 @@ impl Serializable for Instruction {
} => { } => {
if *a > 5 { if *a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
if vg & 0b1111_0000 != 0 { if vg & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires G to be between 0 and 15, found {vg}" requires G to be between 0 and 15, found {vg}"
))); )));
} }
if vf & 0b1111_0000 != 0 { if vf & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires F to be between 0 and 15, found {vf}" requires F to be between 0 and 15, found {vf}"
))); )));
} }
if ve & 0b1111_0000 != 0 { if ve & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires E to be between 0 and 15, found {ve}" requires E to be between 0 and 15, found {ve}"
))); )));
} }
if vd & 0b1111_0000 != 0 { if vd & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires D to be between 0 and 15, found {vd}" requires D to be between 0 and 15, found {vd}"
))); )));
} }
if vc & 0b1111_0000 != 0 { if vc & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35c' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35c' (A|G|op BBBB F|E|D|C) \
requires C to be between 0 and 15, found {vc}" requires C to be between 0 and 15, found {vc}"
))); )));
} }
@ -942,37 +942,37 @@ impl Serializable for Instruction {
} => { } => {
if *a > 5 { if *a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
if vg & 0b1111_0000 != 0 { if vg & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires G to be between 0 and 15, found {vg}" requires G to be between 0 and 15, found {vg}"
))); )));
} }
if vf & 0b1111_0000 != 0 { if vf & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires F to be between 0 and 15, found {vf}" requires F to be between 0 and 15, found {vf}"
))); )));
} }
if ve & 0b1111_0000 != 0 { if ve & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires E to be between 0 and 15, found {ve}" requires E to be between 0 and 15, found {ve}"
))); )));
} }
if vd & 0b1111_0000 != 0 { if vd & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires D to be between 0 and 15, found {vd}" requires D to be between 0 and 15, found {vd}"
))); )));
} }
if vc & 0b1111_0000 != 0 { if vc & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35ms' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35ms' (A|G|op BBBB F|E|D|C) \
requires C to be between 0 and 15, found {vc}" requires C to be between 0 and 15, found {vc}"
))); )));
} }
@ -997,37 +997,37 @@ impl Serializable for Instruction {
} => { } => {
if *a > 5 { if *a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
if vg & 0b1111_0000 != 0 { if vg & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires G to be between 0 and 15, found {vg}" requires G to be between 0 and 15, found {vg}"
))); )));
} }
if vf & 0b1111_0000 != 0 { if vf & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires F to be between 0 and 15, found {vf}" requires F to be between 0 and 15, found {vf}"
))); )));
} }
if ve & 0b1111_0000 != 0 { if ve & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires E to be between 0 and 15, found {ve}" requires E to be between 0 and 15, found {ve}"
))); )));
} }
if vd & 0b1111_0000 != 0 { if vd & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires D to be between 0 and 15, found {vd}" requires D to be between 0 and 15, found {vd}"
))); )));
} }
if vc & 0b1111_0000 != 0 { if vc & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '35mi' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '35mi' (A|G|op BBBB F|E|D|C) \
requires C to be between 0 and 15, found {vc}" requires C to be between 0 and 15, found {vc}"
))); )));
} }
@ -1071,37 +1071,37 @@ impl Serializable for Instruction {
} => { } => {
if *a > 5 { if *a > 5 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires A to be between 0 and 5, found {a}" requires A to be between 0 and 5, found {a}"
))); )));
} }
if vg & 0b1111_0000 != 0 { if vg & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires G to be between 0 and 15, found {vg}" requires G to be between 0 and 15, found {vg}"
))); )));
} }
if vf & 0b1111_0000 != 0 { if vf & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires F to be between 0 and 15, found {vf}" requires F to be between 0 and 15, found {vf}"
))); )));
} }
if ve & 0b1111_0000 != 0 { if ve & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires E to be between 0 and 15, found {ve}" requires E to be between 0 and 15, found {ve}"
))); )));
} }
if vd & 0b1111_0000 != 0 { if vd & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires D to be between 0 and 15, found {vd}" requires D to be between 0 and 15, found {vd}"
))); )));
} }
if vc & 0b1111_0000 != 0 { if vc & 0b1111_0000 != 0 {
return Err(Error::InconsistantStruct(format!( return Err(Error::InconsistantStruct(format!(
"Dalvik instruction format '45cc' (A|G|op BBBB F|E|D|C) \ "Dalvik instruction format for op 0x{op:x}: '45cc' (A|G|op BBBB F|E|D|C) \
requires C to be between 0 and 15, found {vc}" requires C to be between 0 and 15, found {vc}"
))); )));
} }

26
test.py
View file

@ -85,16 +85,16 @@ for dex in dex_raw:
new_apk.add_dex_file(dex) new_apk.add_dex_file(dex)
# print("[+] Repackage") print("[+] Repackage")
#
# utils.replace_dex( utils.replace_dex(
# APK_NAME, APK_NAME,
# APK_NAME.parent / (APK_NAME.name.removesuffix(".apk") + "-instrumented.apk"), APK_NAME.parent / (APK_NAME.name.removesuffix(".apk") + "-instrumented.apk"),
# dex_raw, dex_raw,
# Path().parent / "my-release-key.jks", Path().parent / "my-release-key.jks",
# zipalign=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "zipalign", zipalign=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "zipalign",
# apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner", apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner",
# ) )
last_id = None last_id = None
@ -168,9 +168,9 @@ def cmp_list(a, b, req=0):
apk_eq = new_apk == apk apk_eq = new_apk == apk
print(f"apk are equals: {apk_eq}") print(f"[+] apk are equals: {nice_bool(apk_eq)}")
if not apk_eq: # if not apk_eq:
cmp(new_apk, apk) # cmp(new_apk, apk)
# Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;.<clinit>()V # Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;.<clinit>()V
# mid = IdMethod( # mid = IdMethod(