diff --git a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt index d21803dd..ef1f3718 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/misc/videobuffer/patch/CustomVideoBufferPatch.kt @@ -86,7 +86,7 @@ class CustomVideoBufferPatch : BytecodePatch( } private fun execMaxBuffer() { - val (method, result) = MaxBufferFingerprint.unwrap() + val (method, result) = MaxBufferFingerprint.unwrap(true, -1) val (index, register) = result method.addInstructions( @@ -121,10 +121,15 @@ class CustomVideoBufferPatch : BytecodePatch( ) } - private fun MethodFingerprint.unwrap(): Pair> { + private fun MethodFingerprint.unwrap( + forEndIndex: Boolean = false, + offset: Int = 0 + ): Pair> { val result = this.result!! val method = result.mutableMethod - val index = result.scanResult.patternScanResult!!.startIndex + val scanResult = result.scanResult.patternScanResult!! + val index = (if (forEndIndex) scanResult.endIndex else scanResult.startIndex) + offset + val register = (method.instruction(index) as OneRegisterInstruction).registerA return method to (index to register)