Skip to content

Commit

Permalink
fix(custom-video-buffer): use correct offset for getMaxBuffer call …
Browse files Browse the repository at this point in the history
…injection
  • Loading branch information
oSumAtrIX committed Sep 21, 2022
1 parent 8a9ec13 commit cbc3aa6
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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 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)
Expand Down

0 comments on commit cbc3aa6

Please sign in to comment.