MCPcopy Create free account
hub / github.com/cinit/TMoe / beforeHookedMethod

Function beforeHookedMethod

app/src/main/java/cc/ioctl/tmoe/td/RequestInterceptor.kt:46–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44 }
45 val hookCallback = object : XC_MethodHook() {
46 override fun beforeHookedMethod(params: MethodHookParam) {
47 val request = kTLObject.cast(params.args[0] ?: return)
48 val onComplete = params.args[1] ?: return
49 kRequestDelegate.cast(onComplete)
50 val klass = onComplete.javaClass
51 if (klass.name.startsWith("\$Proxy")) {
52 // don't hook proxy
53 return
54 }
55 if (klass.classLoader == RequestInterceptor::class.java.classLoader) {
56 // don't hook request made by ourselves
57 return
58 }
59 if (isInterestedRequest(request.javaClass)) {
60 if (!mHookedClasses.contains(klass)) {
61 val run = klass.getDeclaredMethod("run", kTLObject, kTL_error)
62 synchronized(mRuntimeHookLock) {
63 if (!mHookedClasses.contains(klass)) {
64 XposedBridge.hookMethod(run, mHookedOnCompleteInterceptor)
65 mHookedClasses.add(klass)
66 }
67 }
68 }
69 val pair = Pair(WeakReference(request), WeakReference(onComplete))
70 synchronized(mCallbackSetLock) {
71 mRequestCallbacks.add(pair)
72 }
73 }
74 }
75 }
76 XposedBridge.hookMethod(sendRequest9, hookCallback)
77 mInitialized = true

Callers

nothing calls this directly

Calls 10

isInterestedRequestFunction · 0.85
dispatchRequestResultFunction · 0.85
containsMethod · 0.80
iteratorMethod · 0.80
hasNextMethod · 0.80
nextMethod · 0.80
wMethod · 0.80
addMethod · 0.45
getMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected