1
+ package com.qihoo360.replugin.config
2
+
3
+ /* *
4
+ * author:gaoguanling
5
+ * date:2021/11/15
6
+ * time:17:53
7
+
8
+ * link:
9
+ */
10
+ open class TargetMethod (var name : String ) {
11
+ var className: String = " com/qihoo360/replugin/base/method/Origin"
12
+ var methodName: String = " f"
13
+ var methodDesc: String = " (Lcom/qihoo360/replugin/base/method/A;Lcom/qihoo360/replugin/base/method/B;)Lcom/qihoo360/replugin/base/method/R"
14
+ var targetClassName: String = " com/qihoo360/replugin/base/method/Target"
15
+ var targetMethodName: String = " f"
16
+ var targetMethodDesc: String = " (Lcom/qihoo360/replugin/base/method/A;Lcom/qihoo360/replugin/base/method/B;)Lcom/qihoo360/replugin/base/method/R"
17
+ var hookType: Int = HookType .DEFINE_NORMAL_BEFORE_METHOD .value
18
+
19
+ constructor (
20
+ name: String ,
21
+ className: String , methodName: String , methodDesc: String ,
22
+ targetClassName: String , targetMethodName: String , targetMethodDesc: String ,
23
+ hookType: Int
24
+ ) : this (name) {
25
+ this .className = className
26
+ this .methodName = methodName
27
+ this .methodDesc = methodDesc
28
+ this .targetClassName = targetClassName
29
+ this .targetMethodName = targetMethodName
30
+ this .targetMethodDesc = targetMethodDesc
31
+ this .hookType = hookType
32
+ }
33
+
34
+ enum class HookType (val value : Int ) {
35
+ DEFINE_NORMAL_BEFORE_METHOD (0x01 ),
36
+ DEFINE_NORMAL_AFTER_METHOD (0x02 ),
37
+ DEFINE_NORMAL_REPLACE_METHOD (0x03 ),
38
+ DEFINE_STATIC_BEFORE_METHOD (0x04 ),
39
+ DEFINE_STATIC_AFTER_METHOD (0x05 ),
40
+ DEFINE_STATIC_REPLACE_METHOD (0x06 ),
41
+ CALL_NORMAL_BEFORE_METHOD (0x07 ),
42
+ CALL_NORMAL_AFTER_METHOD (0x08 ),
43
+ CALL_NORMAL_REPLACE_METHOD (0x09 ),
44
+ CALL_STATIC_BEFORE_METHOD (0x0a ),
45
+ CALL_STATIC_AFTER_METHOD (0x0b ),
46
+ CALL_STATIC_REPLACE_METHOD (0x0c )
47
+ }
48
+
49
+ companion object {
50
+ fun getHookTypeByValue (value : Int ): HookType {
51
+ return when (value) {
52
+ 0x01 ->
53
+ HookType .DEFINE_NORMAL_BEFORE_METHOD
54
+ 0x02 ->
55
+ HookType .DEFINE_NORMAL_AFTER_METHOD
56
+ 0x03 ->
57
+ HookType .DEFINE_NORMAL_REPLACE_METHOD
58
+ 0x04 ->
59
+ HookType .DEFINE_STATIC_BEFORE_METHOD
60
+ 0x05 ->
61
+ HookType .DEFINE_STATIC_AFTER_METHOD
62
+ 0x06 ->
63
+ HookType .DEFINE_STATIC_REPLACE_METHOD
64
+ 0x07 ->
65
+ HookType .CALL_NORMAL_BEFORE_METHOD
66
+ 0x08 ->
67
+ HookType .CALL_NORMAL_AFTER_METHOD
68
+ 0x09 ->
69
+ HookType .CALL_NORMAL_REPLACE_METHOD
70
+ 0x0a ->
71
+ HookType .CALL_STATIC_BEFORE_METHOD
72
+ 0x0b ->
73
+ HookType .CALL_STATIC_AFTER_METHOD
74
+ 0x0c ->
75
+ HookType .CALL_STATIC_REPLACE_METHOD
76
+ else ->
77
+ HookType .DEFINE_NORMAL_BEFORE_METHOD
78
+ }
79
+ }
80
+ }
81
+
82
+ override fun toString (): String {
83
+ return " TargetMethod(name='$name ', className='$className ', methodName='$methodName ', methodDesc='$methodDesc ', targetClassName='$targetClassName ', targetMethodName='$targetMethodName ', targetMethodDesc='$targetMethodDesc ', hookType=$hookType )"
84
+ }
85
+ }
0 commit comments