fix encoded value sign extention

This commit is contained in:
Jean-Marie Mineau 2024-02-07 17:31:09 +01:00
parent e950b77475
commit abe7fb6a50
Signed by: histausse
GPG key ID: B66AEEDA9B645AD2
2 changed files with 164 additions and 24 deletions

47
test.py
View file

@ -73,8 +73,8 @@ classes = list(
apk.classes.keys(),
)
)
for cls in classes:
apk.remove_class(cls)
# for cls in classes:
# apk.remove_class(cls)
print("[+] Recompile")
@ -140,13 +140,18 @@ def cmp_dict(a, b, req=0):
keys_b = set(b.keys())
if keys_a != keys_b:
print(f"{ident}a.keys() != b.keys()")
tot = 0
nb_failed = 0
for key in keys_a & keys_b:
eq = a[key] == b[key]
print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}")
tot += 1
if not eq:
nb_failed += 1
print(f"{f'{ident}{str(key)}: ':<150}{nice_bool(eq)}")
global last_id
last_id = key
cmp(a[key], b[key], req + 1)
print(f"\033[32m{tot-nb_failed}\033[0m + \033[31m{nb_failed}\033[0m = {tot}")
def cmp_list(a, b, req=0):
@ -180,21 +185,21 @@ if not apk_eq:
# 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()
# 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()