forked from ReVanced/revanced-patches-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(infinityforreddit): add
change-oauth-client-id
patch (ReVanced…
…#2452) Co-authored-by: oSumAtrIX <[email protected]>
- Loading branch information
1 parent
8a6c5c3
commit 9efd790
Showing
7 changed files
with
112 additions
and
40 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
12 changes: 12 additions & 0 deletions
12
...es/reddit/customclients/infinityforreddit/api/fingerprints/AbstractClientIdFingerprint.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints | ||
|
||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
|
||
abstract class AbstractClientIdFingerprint(classTypeSuffix: String, methodName: String) : MethodFingerprint( | ||
strings = listOf("NOe2iKrPPzwscA"), | ||
customFingerprint = custom@{ methodDef, classDef -> | ||
if (!classDef.type.endsWith(classTypeSuffix)) return@custom false | ||
|
||
methodDef.name == methodName | ||
} | ||
) |
6 changes: 6 additions & 0 deletions
6
...dit/customclients/infinityforreddit/api/fingerprints/GetHTTPBasicAuthHeaderFingerprint.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints | ||
|
||
object GetHTTPBasicAuthHeaderFingerprint : AbstractClientIdFingerprint( | ||
"APIUtils;", | ||
"getHTTPBasicAuthHeader" | ||
) |
6 changes: 6 additions & 0 deletions
6
...ddit/customclients/infinityforreddit/api/fingerprints/LoginActivityOnCreateFingerprint.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints | ||
|
||
object LoginActivityOnCreateFingerprint : AbstractClientIdFingerprint( | ||
"LoginActivity;", | ||
"onCreate" | ||
) |
43 changes: 43 additions & 0 deletions
43
...nced/patches/reddit/customclients/infinityforreddit/api/patch/ChangeOAuthClientIdPatch.kt
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package app.revanced.patches.reddit.customclients.infinityforreddit.api.patch | ||
|
||
import app.revanced.patcher.annotation.* | ||
import app.revanced.patcher.data.BytecodeContext | ||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction | ||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprintResult | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.reddit.customclients.AbstractChangeOAuthClientIdPatch | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.GetHTTPBasicAuthHeaderFingerprint | ||
import app.revanced.patches.reddit.customclients.infinityforreddit.api.fingerprints.LoginActivityOnCreateFingerprint | ||
import org.jf.dexlib2.iface.instruction.OneRegisterInstruction | ||
|
||
@Patch | ||
@Name("change-oauth-client-id") | ||
@Description("Changes the OAuth client ID.") | ||
@Compatibility([Package("ml.docilealligator.infinityforreddit")]) | ||
@Version("0.0.1") | ||
class ChangeOAuthClientIdPatch : AbstractChangeOAuthClientIdPatch( | ||
"infinity://localhost", | ||
Options, | ||
listOf(GetHTTPBasicAuthHeaderFingerprint, LoginActivityOnCreateFingerprint) | ||
) { | ||
override fun List<MethodFingerprintResult>.patch(context: BytecodeContext): PatchResult { | ||
forEach { | ||
val clientIdIndex = it.scanResult.stringsScanResult!!.matches.first().index | ||
it.mutableMethod.apply { | ||
val oAuthClientIdRegister = getInstruction<OneRegisterInstruction>(clientIdIndex).registerA | ||
|
||
replaceInstruction( | ||
clientIdIndex, | ||
"const-string v$oAuthClientIdRegister, \"$clientId\"" | ||
) | ||
} | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
companion object Options : AbstractChangeOAuthClientIdPatch.Options.ChangeOAuthClientIdOptionsContainer() | ||
} |
This file contains 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