Repository navigation
fix(meta-loader): repackage obfuscated classes to prevent namespace collisions in inject mode - #122
Open
s1ddhants1 wants to merge 1 commit into
Open
s1ddhants1 wants to merge 1 commit into
s1ddhants1 wants to merge 1 commit into
Conversation
…ollision in multi-dex inject mode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When patching an application with
--injectdex(injectDex = true),metaloader.dexis appended asclasses(N+1).dexalongside the target application's original DEX files.Because
meta-loader/proguard-rules.proonly keptLSPAppComponentFactoryStubwithout specifying-repackageclasses, R8/ProGuard shrinks and obfuscates internal dependencies (HiddenApiBypass,projects.share.java) into single-letter classes in the default root package (La;,Lb;,Lc;,Ld;,Le;,Lf;,Lg;,Lh;,Li;).If the target application is also compiled with R8/ProGuard, its primary
classes.dexoften already contains classesLa;throughLi;. When Android'sPathClassLoaderattempts to resolveHiddenApiBypasshelper classes (such as dummy stub classg.classused to computeartMethodandartFieldoffsets), Android resolves the target app's unrelated class fromclasses.dexinstead of the loader's class inclasses(N+1).dex.This causes a
NoSuchMethodExceptionduring<clinit>, causingHiddenApiBypassto fail withExceptionInInitializerError. As a result,LSPAppComponentFactoryStubfails to queryIPackageManagerand crashes immediately on launch with:Solution
-repackageclasses org.lsposed.lspatch.metaloadertometa-loader/proguard-rules.pro.org.lsposed.lspatch.metaloadernamespace, preventing collisions with root-level classes in target multi-dex APKs.Validation
./gradlew :meta-loader:assembleReleaseand inspected the resultingclasses.dexwithdexdump. Verified all classes reside strictly underLorg/lsposed/lspatch/metaloader/*:Lorg/lsposed/lspatch/metaloader/LSPAppComponentFactoryStub;Lorg/lsposed/lspatch/metaloader/a;..i;injectDex = true. The loader bootstraps successfully without the previousIllegalStateException/ collision crash.