Harden smali hooks against branch targets and register limits #59
Labels
No labels
area/architecture
area/build-ci
area/bytecode
area/code-quality
area/docs
area/extension
area/fingerprint
area/security
area/tests
Bug report
Feature request
review
sev/low
sev/medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
midas/midas-patches#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Found in the codebase review (2026-10-11). None of these is known to be broken today (the methods look straight-line), but each would fail silently, at runtime, after an app update.
1. Hooks inserted before a
returnor invoke can be skipped by branches. PlainaddInstructions(index, ...)leaves existing labels on the original instruction, so agoto/if-*that targets that return/invoke jumps past the hook. The safe pattern is already used and documented inedition/contentfilters/ContentFilterPatches.ktandedition/preferredsource/HidePreferredSourcePatch.kt:replaceInstruction(index, "<hook invoke>"), thenaddInstructions(index + 1, "move-result ... / <original instruction>"). Sites:edition/reviewprompts/HideReviewPromptsPatch.kt(the boolean&&chain)dpg/videosdk/VideoProductionCachePatch.kt(kotlinx.serialization constructors often havegoto->return-voidpaths)kubus/markdown/CopyArticleMarkdownPatch.kt(ArticleDetailResponse.<init>, and beforeMutableStateFlow.setValue)kubus/settings/MidasSettingsPatch.kt(getSections)edition/onboarding/HideOnboardingPopupsPatch.kt(theisSuppressedreturn)2.
const/4and 35c/22c forms on parameter registers only take v0-v15. If a method grows locals, patching fails (loudly, at least). Sites:const/4 p1inedition/ads/HideAdsPatch.kt,kubus/ads/HideAdsPatch.kt,edition/update/DisableUpdatePromptsPatch.kt,videoland/ads/HideAdsPatch.kt(3x);instance-of v0, p1/invoke-static {p1}in several hooks. Useconst/16and/rangeinvokes where the register isn't guaranteed small (kubus/ads/HideAdsPatch.ktalready does).3.
edition/markdown/CopyArticleMarkdownPatch.kttakes the list fromregisterDof theaddShareActioncall, which assumes an instance method with the list as first argument. If R8 makes it static, the extension gets the toolbar object instead. Derive the register from theMethodReferenceparameter types (index ofLjava/util/List;, +1 when not static).Done when: all sites converted,
buildAndroidpasses andpatch-install.ps1 -NoInstall/check-patches.shprintAppliedfor every patch on Volkskrant, Trouw, Het Parool, the Kubus titles and Videoland; a quick device smoke test of the touched features.