fix of by one in static values generation
This commit is contained in:
parent
fcfe2dc6e9
commit
e0f348aecc
2 changed files with 19 additions and 7 deletions
|
|
@ -1662,13 +1662,13 @@ impl DexWriter {
|
|||
let mut static_fields: Vec<IdField> = class.static_fields.keys().cloned().collect();
|
||||
static_fields.sort();
|
||||
let mut array = vec![];
|
||||
let mut last_defined_field_idx = 0;
|
||||
let mut last_defined_field_index = 0;
|
||||
for (idx, f) in static_fields.iter().enumerate() {
|
||||
if class.static_fields.get(f).unwrap().value.is_some() {
|
||||
last_defined_field_idx = idx;
|
||||
last_defined_field_index = idx;
|
||||
}
|
||||
}
|
||||
for f in &static_fields[..last_defined_field_idx] {
|
||||
for f in &static_fields[..=last_defined_field_index] {
|
||||
let field = class.static_fields.get(f).unwrap();
|
||||
if let Some(val) = field.value.as_ref() {
|
||||
array.push(val.clone());
|
||||
|
|
|
|||
20
test.py
20
test.py
|
|
@ -67,12 +67,13 @@ classes = list(
|
|||
IdType("Lcom/example/testapplication/ui/home/HomeViewModel;"),
|
||||
IdType("Landroidx/navigation/NavDeepLink$Builder;"),
|
||||
IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"),
|
||||
IdType("Landroidx/appcompat/app/ActionBar;"),
|
||||
],
|
||||
apk.classes.keys(),
|
||||
)
|
||||
)
|
||||
for cls in classes:
|
||||
apk.remove_class(cls)
|
||||
# for cls in classes:
|
||||
# apk.remove_class(cls)
|
||||
|
||||
print("[+] Recompile")
|
||||
|
||||
|
|
@ -94,9 +95,13 @@ for dex in dex_raw:
|
|||
# apksigner=Path.home() / "Android" / "Sdk" / "build-tools" / "34.0.0" / "apksigner",
|
||||
# )
|
||||
|
||||
last_id = None
|
||||
|
||||
MAX_REQ = 1
|
||||
|
||||
|
||||
def cmp(a, b, req=0):
|
||||
if req > 6:
|
||||
if req > MAX_REQ:
|
||||
return
|
||||
if type(a) == dict:
|
||||
cmp_dict(a, b, req)
|
||||
|
|
@ -116,10 +121,15 @@ def nice_bool(b) -> str:
|
|||
def cmp_other(a, b, req=0):
|
||||
ident = " " * req
|
||||
for f in dir(a):
|
||||
if getattr(getattr(a, f), "__call__", None) is None:
|
||||
if getattr(getattr(a, f), "__call__", None) is None and (
|
||||
len(f) < 2 or f[:2] != "__"
|
||||
):
|
||||
eq = getattr(a, f) == getattr(b, f)
|
||||
print(f"{f'{ident}{f}: ':<150}{nice_bool(eq)}")
|
||||
if not eq:
|
||||
if "descriptor" in dir(a):
|
||||
global last_id
|
||||
last_id = a.descriptor
|
||||
cmp(getattr(a, f), getattr(b, f), req + 1)
|
||||
|
||||
|
||||
|
|
@ -133,6 +143,8 @@ def cmp_dict(a, b, req=0):
|
|||
eq = a[key] == b[key]
|
||||
print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}")
|
||||
if not eq:
|
||||
global last_id
|
||||
last_id = a.descriptor
|
||||
cmp(a[key], b[key], req + 1)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue