-
Notifications
You must be signed in to change notification settings - Fork 9
/
ScriptSignalConnectCallBack.go
43 lines (40 loc) · 1.04 KB
/
ScriptSignalConnectCallBack.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package frida_go
import (
"github.com/a97077088/frida-go/cfrida"
jsoniter "github.com/json-iterator/go"
)
func script_onDestroyedCallBack(sc uintptr, userdata uintptr) uintptr {
v,ok:=script_onDestroyedCallbackTable.Load(int64(userdata))
if !ok{
return 0
}
h:=v.(ScriptOnDestroyedEventFunc)
h()
return 0
}
func script_onMessageCallBack(sc uintptr, rawjson uintptr, rawdata uintptr, userdata uintptr) uintptr {
sjson := cfrida.CStrToGoStr(rawjson)
jjson := jsoniter.Get([]byte(sjson))
data := cfrida.G_bytes_to_bytes_and_unref(rawdata)
tp := jjson.Get("type").ToString()
if tp != "send" {
v,ok:=script_onMessageCallbackTable.Load(int64(userdata))
if !ok{
return 0
}
h:=v.(ScriptOnMessageEventFunc)
h(jjson,data)
} else {
if (jjson.Get("payload").ValueType()==jsoniter.ArrayValue)==false || jjson.Get("payload").Size() < 4 {
v,ok:=script_onMessageCallbackTable.Load(int64(userdata))
if !ok{
return 0
}
h:=v.(ScriptOnMessageEventFunc)
h(jjson,data)
} else {
rpcCallbackFunc(jjson.Get("payload"))
}
}
return 0
}