Skip to content

Commit

Permalink
修复忘记处理 Hook 的目标方法没有参数时产生的问题。
Browse files Browse the repository at this point in the history
  • Loading branch information
IceCream-QAQ committed Jul 13, 2020
1 parent e839f38 commit 3b0a1f3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
11 changes: 9 additions & 2 deletions src/main/java/com/IceCreamQAQ/Yu/hook/YuHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,16 @@ public static byte[] checkClass(String name, byte[] bytes) {
Label catchLabel = new Label();
mv.visitTryCatchBlock(tryStart, tryEnd, catchLabel, "java/lang/Throwable");

val lastPara = paras.get(paras.size() - 1);

int stack = lastPara.stackNum + lastPara.stackSize - 1;
int stack;
if (paras.size() == 0)
if (isStatic) stack = -1;
else stack = 0;
else {
val lastPara = paras.get(paras.size() - 1);
stack = lastPara.stackNum + lastPara.stackSize - 1;
}

int hookMethodStack;
int paraStack;

Expand Down
10 changes: 7 additions & 3 deletions src/test/kotlin/com/icecreamqaq/test/yu/TestClassLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@ fun main(args: Array<String>) {
val tac = appClassLoader.loadClass("com.icecreamqaq.test.yu.Ta")
val ta = tac.newInstance()

val g = tac.getMethod("g", Int::class.java, Long::class.java)
val g = tac.getMethod("g")
// val g = tac.getMethod("g", Int::class.java, Int::class.java)

println(g.invoke(ta, 1.1, 12.2))
println(g.invoke(ta))
}

class Ta {
fun g(tt: Float, i: Double) = (i + tt)
// companion object{
// @JvmStatic
//
// }
fun g() = 2.toLong()
}


Expand Down

0 comments on commit 3b0a1f3

Please sign in to comment.