refactor: do not account for order in VideoIdPatch.injectCall (#246)

This commit is contained in:
oSumAtrIX 2022-07-29 03:20:55 +02:00 committed by GitHub
parent 50a34d587b
commit f99406eac4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,10 +39,11 @@ class VideoIdPatch : BytecodePatch(
} }
companion object { companion object {
private lateinit var result: MethodFingerprintResult private const val offset = 3 // offset so setCurrentVideoId is called before any injected call
private var videoIdRegister: Int = 0 private var videoIdRegister: Int = 0
private lateinit var result: MethodFingerprintResult
private lateinit var insertMethod: MutableMethod private lateinit var insertMethod: MutableMethod
private var offset = 2
/** /**
* Adds an invoke-static instruction, called with the new id when the video changes * Adds an invoke-static instruction, called with the new id when the video changes
@ -52,10 +53,9 @@ class VideoIdPatch : BytecodePatch(
methodDescriptor: String methodDescriptor: String
) { ) {
insertMethod.addInstructions( insertMethod.addInstructions(
result.patternScanResult!!.endIndex + offset, // after the move-result-object result.patternScanResult!!.endIndex + offset, // move-result-object offset
"invoke-static {v$videoIdRegister}, $methodDescriptor" "invoke-static {v$videoIdRegister}, $methodDescriptor"
) )
offset++ // so additional instructions get added later
} }
} }
} }