Skip to content

Fix oat_hook for recent Android versions#387

Merged
JingMatrix merged 2 commits intomasterfrom
oat
Aug 9, 2025
Merged

Fix oat_hook for recent Android versions#387
JingMatrix merged 2 commits intomasterfrom
oat

Conversation

@JingMatrix
Copy link
Copy Markdown
Owner

We used to hook functions OatHeader::GetKeyValueStore and OatHeader::GetKeyValueStoreSize to clean the dex2oat trace introduced by LSPosed. However, in recent versions of Android, these two functions are no longer exported. Moreover, the OatHeader structure has changed, which now sets certain entries to have fixed length by padding zeros.

To address these two changes, we hook OatHeader::ComputeChecksum as an entrypoint (fallback), and then employ the header file of OatHeader copied from AOSP to precisely locate its fields. Using this strategy, we modify key_value_store in memory, depending on whether the entry dex2oat-cmdline is padded.

We used to hook functions `OatHeader::GetKeyValueStore` and `OatHeader::GetKeyValueStoreSize` to clean the `dex2oat` trace introduced by LSPosed. However, in recent versions of Android, these two functions are no longer exported. Moreover, the `OatHeader` structure has changed, which now sets certain entries to have fixed length by padding zeros.

To address these two changes, we hook `OatHeader::ComputeChecksum` as an entrypoint (fallback), and then employ the header file of `OatHeader` copied from AOSP to precisely locate its fields. Using this strategy, we modify `key_value_store` in memory, depending on whether the entry `dex2oat-cmdline` is padded.
@JingMatrix JingMatrix linked an issue Aug 8, 2025 that may be closed by this pull request
1 task
Otherwise, uint32_t is shown as negative numbers in logs.
@JingMatrix JingMatrix merged commit 6703b45 into master Aug 9, 2025
1 check passed
lshwjgpt25 pushed a commit to lshwjgpt25/LSPosed that referenced this pull request Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dex2oat failed in recent Android versions

1 participant