fix(custom-video-buffer): use correct offset for getMaxBuffer call injection

This commit is contained in:
oSumAtrIX 2022-09-21 16:44:25 +02:00
parent 54f947d3d6
commit 6773122d0b
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -86,7 +86,7 @@ class CustomVideoBufferPatch : BytecodePatch(
} }
private fun execMaxBuffer() { private fun execMaxBuffer() {
val (method, result) = MaxBufferFingerprint.unwrap() val (method, result) = MaxBufferFingerprint.unwrap(true, -1)
val (index, register) = result val (index, register) = result
method.addInstructions( method.addInstructions(
@ -121,10 +121,15 @@ class CustomVideoBufferPatch : BytecodePatch(
) )
} }
private fun MethodFingerprint.unwrap(): Pair<MutableMethod, Pair<Int, Int>> { private fun MethodFingerprint.unwrap(
forEndIndex: Boolean = false,
offset: Int = 0
): Pair<MutableMethod, Pair<Int, Int>> {
val result = this.result!! val result = this.result!!
val method = result.mutableMethod 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 val register = (method.instruction(index) as OneRegisterInstruction).registerA
return method to (index to register) return method to (index to register)