| 6 | const getMainModule = (version) => { |
| 7 | const osPlatform = getPlatform(); |
| 8 | if (osPlatform === 'windows') { |
| 9 | if (version >= 13331) { |
| 10 | return Process.findModuleByName("flue.dll"); |
| 11 | } |
| 12 | return Process.findModuleByName("WeChatAppEx.exe"); |
| 13 | } else if (osPlatform === 'linux') { |
| 14 | return Process.findModuleByName("WeChatAppEx"); |
| 15 | } else if (osPlatform === 'darwin') { |
| 16 | return Process.findModuleByName("WeChatAppEx Framework"); |
| 17 | } |
| 18 | }; |
| 19 | |
| 20 | const patchCDPFilter = (base, config) => { |
| 21 | // xref: SendToClientFilter OR devtools_message_filter_applet_webview.cc |
| 22 | const offset = config.CDPFilterHookOffset; |
| 23 | Interceptor.attach(base.add(offset), { |
| 24 | onLeave(retval_) { |
| 25 | // see https://github.com/evi0s/WMPFDebugger/pull/262 |
| 26 | const retval = getPlatform() == 'windows' |
| 27 | ? retval_.readPointer() |
| 28 | : retval_; |
| 29 | if (retval.isNull()) return; |
| 30 | try { |
| 31 | const val = retval.add(8).readU32(); |
| 32 | send(`[patch] CDP filter on leave, retval+8 = ${val}`); |
| 33 | if (val === 6) { |
| 34 | retval.add(8).writeU32(0x0); |
| 35 | send("[patch] CDP filter patched"); |
| 36 | } |
| 37 | } catch (e) { |
| 38 | send(`[patch] CDP filter error: ${e}`); |