implement a label normalization for compring code

This commit is contained in:
Jean-Marie Mineau 2024-02-07 14:23:11 +01:00
parent e0f348aecc
commit 4755dd995d
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
2 changed files with 364 additions and 7 deletions

28
test.py
View file

@ -68,12 +68,13 @@ classes = list(
IdType("Landroidx/navigation/NavDeepLink$Builder;"),
IdType("Landroidx/constraintlayout/core/widgets/ConstraintWidget$1;"),
IdType("Landroidx/appcompat/app/ActionBar;"),
IdType("Landroidx/constraintlayout/core/state/WidgetFrame;"),
],
apk.classes.keys(),
)
)
# for cls in classes:
# apk.remove_class(cls)
for cls in classes:
apk.remove_class(cls)
print("[+] Recompile")
@ -144,7 +145,7 @@ def cmp_dict(a, b, req=0):
print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}")
if not eq:
global last_id
last_id = a.descriptor
last_id = key
cmp(a[key], b[key], req + 1)
@ -177,4 +178,23 @@ if not apk_eq:
# )
# m = apk.classes[mid.class_].direct_methods[mid]
# nm = new_apk.classes[mid.class_].direct_methods[mid]
#
mid = IdMethod(
"setValue",
IdMethodType(
IdType("Z"),
[
IdType("Ljava/lang/String;"),
IdType("Landroidx/constraintlayout/core/parser/CLElement;"),
],
),
IdType("Landroidx/constraintlayout/core/state/WidgetFrame;"),
)
m = apk.classes[mid.class_].virtual_methods[mid]
nm = new_apk.classes[mid.class_].virtual_methods[mid]
c = m.code
nc = nm.code
cc = c.with_normalized_labels()
ncc = nc.with_normalized_labels()