Skip to content

Commit

Permalink
fix: CustomWatermark hook failed (by StarVoyager)
Browse files Browse the repository at this point in the history
Signed-off-by: mu7220 <[email protected]>
  • Loading branch information
lingqiqi5211 committed Feb 13, 2024
1 parent bb242a4 commit 514f534
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* This file is part of HyperCeiler.
* HyperCeiler is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
Expand All @@ -18,23 +18,42 @@
*/
package com.sevtinge.hyperceiler.module.hook.mediaeditor

import android.annotation.SuppressLint
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHooks
import com.github.kyuubiran.ezxhelper.finders.MethodFinder.`-Static`.methodFinder
import com.github.kyuubiran.ezxhelper.EzXHelper
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.sevtinge.hyperceiler.module.base.BaseHook
import com.sevtinge.hyperceiler.utils.api.LazyClass.SystemProperties
import com.sevtinge.hyperceiler.module.base.dexkit.DexKit.dexKitBridge
import org.luckypray.dexkit.query.enums.StringMatchType
import java.lang.reflect.Modifier

@SuppressLint("StaticFieldLeak")
object CustomWatermark : BaseHook() {
private val name by lazy {
mPrefsMap.getString("mediaeditor_custom_watermark", "")
}

override fun init(){
SystemProperties.methodFinder()
// by StarVoyager
val search = dexKitBridge.findMethod {
matcher {
addUsingString("K30 Pro Zoom E", StringMatchType.Equals)
modifiers = Modifier.FINAL
returnType = "java.lang.String"
paramCount = 2
}
}.single().getMethodInstance(EzXHelper.classLoader)

logE(TAG, "[CustomWatermark] search method is $search")
search.createHook {
// 当前只能修改后缀
returnConstant(name)
}

/*SystemProperties.methodFinder()
.filterByParamCount(2)
.filterByParamTypes(String::class.java, String::class.java)
.toList().createHooks {
before {
if (it.args[0] == "ro.product.marketname") {
it.args[1] = mPrefsMap.getString("mediaeditor_custom_watermark", "")
it.args[1] = name
}
}
}
Expand All @@ -45,9 +64,9 @@ object CustomWatermark : BaseHook() {
.toList().createHooks {
before {
if (it.args[0] == "ro.product.marketname") {
it.result = mPrefsMap.getString("mediaeditor_custom_watermark", "")
it.result = name
}
}
}
}*/
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object UnlockCustomPhotoFrames : BaseHook() {
dexKitBridge.findMethod {
matcher {
// find 徕卡定制画框 && redmi 定制画框 && poco 定制画框 && 迪斯尼定制画框 && 新春定制画框
// 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() b() d() f() g() i())
// 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() b() d() f() h() i())
// b() 是新春定制画框,前置条件需要符合定制画框类型(徕卡定制画框 或 redmi 定制画框)
// h() 是 Redmi 中的 其中一个联名定制画框
// 如果都返回 true 的话,按照原代码逻辑,只会解锁徕卡定制画框
Expand All @@ -64,7 +64,7 @@ object UnlockCustomPhotoFrames : BaseHook() {
private val publicA by lazy {
dexKitBridge.findMethod {
matcher {
// 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() d() f() h() i()
// 搜索符合条件的方法(1.6.3.5 举例,以下条件筛选完还有 a() d() f() h())
addCall {
declaredClass {
modifiers = Modifier.FINAL or Modifier.PUBLIC
Expand Down Expand Up @@ -128,7 +128,7 @@ object UnlockCustomPhotoFrames : BaseHook() {
differentItems.forEach { method ->
// debug 用
logI(TAG, "Public Spring name is $method")
springFestival(method)
other(method) // 1.6.0.5.2 新增限时新春定制画框
}
}

Expand Down Expand Up @@ -173,11 +173,4 @@ object UnlockCustomPhotoFrames : BaseHook() {
returnConstant(true)
}
}

private fun springFestival(name: Method) {
// 1.6.0.5.2 新增限时新春定制画框
name.createHook {
returnConstant(true)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ object BlurButton : BaseHook() {

@RequiresApi(Build.VERSION_CODES.S)
override fun init() {
// by StarVoyager
if (isMoreHyperOSVersion(1f)) {
loadClassOrNull(
"com.android.keyguard.injector.KeyguardBottomAreaInjector"
Expand Down

0 comments on commit 514f534

Please sign in to comment.