refactor: simplify casting instructions

This commit is contained in:
oSumAtrIX
2023-05-06 23:10:01 +02:00
parent 1abc929583
commit aada4d9e9b
30 changed files with 193 additions and 150 deletions

View File

@ -30,7 +30,8 @@ class ClientSpoofPatch : BytecodePatch(
UserAgentHeaderBuilderFingerprint.result?.let { result ->
val insertIndex = result.scanResult.patternScanResult!!.endIndex
result.mutableMethod.apply {
val packageNameRegister = (instruction(insertIndex) as FiveRegisterInstruction).registerD
val packageNameRegister = instruction<FiveRegisterInstruction>(insertIndex).registerD
addInstruction(insertIndex, "const-string v$packageNameRegister, \"$ORIGINAL_PACKAGE_NAME\"")
}

View File

@ -20,19 +20,17 @@ class VerticalScrollPatch : BytecodePatch(
listOf(CanScrollVerticallyFingerprint)
) {
override fun execute(context: BytecodeContext): PatchResult {
val result = CanScrollVerticallyFingerprint.result ?: return CanScrollVerticallyFingerprint.toErrorResult()
CanScrollVerticallyFingerprint.result?.let {
it.mutableMethod.apply {
val insertIndex = it.scanResult.patternScanResult!!.endIndex
val moveResultRegister = instruction<OneRegisterInstruction>(insertIndex - 1).registerA
with(result) {
val method = mutableMethod
val moveResultIndex = scanResult.patternScanResult!!.endIndex
val moveResultRegister = (method.instruction(moveResultIndex) as OneRegisterInstruction).registerA
method.addInstruction(
moveResultIndex + 1,
"const/4 v$moveResultRegister, 0x0"
)
}
addInstruction(
insertIndex,
"const/4 v$moveResultRegister, 0x0"
)
}
} ?: return CanScrollVerticallyFingerprint.toErrorResult()
return PatchResultSuccess()
}