Update __init__.py

fix 4-byte aligned padding
This commit is contained in:
backtohuman 2024-03-08 18:29:38 +09:00 committed by GitHub
parent 913c2cd907
commit 025aaa243c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -376,7 +376,8 @@ def determineNext(i, cur_idx, m):
# "the instructions must be located on even-numbered bytecode offsets (that is, 4-byte aligned).
# In order to meet this requirement, dex generation tools must
# emit an extra nop instruction as a spacer if such an instruction would otherwise be unaligned."
padding = (off + cur_idx) % 4
remaining = (off + cur_idx) % 4
padding = 0 if remaining == 0 else (4 - remaining)
if padding != 0:
logger.warning("Switch payload not aligned, assume stuff and add {} bytes...".format(padding))
data = code.get_ins_off(off + cur_idx + padding)