Convert CDP message directly to JSON without filtering - #262
Conversation
|
I see. I might see the issue here. In your address offset config, the btw, your workaround should indeed work and look pretty intuitive, but since currently we've already had so many versions behind, adding this would introduce different patching strategy in code. My intuition is keeping the code as simple as possible, without adding major structural changes. Thanks for your understanding. |
|
Oh, I see. That explains everything. I tested your method, and it seems to be working fine for now. However, it should be clarified that The CDP format library used by Chromium, but I'm not sure if Please let me know your thoughts! |
|
Gotcha, that makes sense. Then the current patching strategy is actually tricking the filter function to believe the incoming message is a specific type, which triggers the short-circuit path (please correct me if I'm wrong). I checked the cross-refs of that function and I indeed found three more references. In fact, there's another filter function I previously haven't noticed before ( Anyways, personally I'm still not convinced to make this structural change, since there's saying that, if it works, don't touch it. This's also the reason that the previous PR for macOS adaptation wasn't merged at the beginning, because the structural changes were not sound enough, until your last PR (thanks again btw!). Hope you could understand that. Someday, if WMPF introduced more related code causing the existing patching strategy broken, we can then pivot to other patching strategies like your proposed one. Thanks again for your effort and understanding. |
|
Okay, I agree with you. I'll update the code later today. I have one more question: Does the macOS logic work on Windows? Placing the return value as the first input parameter is a compiler optimization (RVO); generally, the return value and the first input parameter point to the same thing, so I’d like you to test this. If it works, we can remove some of the conditional checks. Thanks for your patience and participation! |
|
Thanks so much for your understanding!
This makes perfectly sense. I just removed the check and tested it, and it worked! However, there's still a difference that, the value on Windows is passed by pointer (of a stack variable), so you'll need to use |
|
The documentation looked a bit outdated, so I updated it. Please check to see if it works properly on Windows; I think this PR is ready to be merged. |
|
Looks fantastic! Thank you again for your contribution!! |
* hook.js: CDPFilter patch method migrated to function replacing. credit @Redbeanw44602, PR #262 * hook.js: structural changes. more necessary offsets are introduced, including remotedebug mode, and back connecting URL * platform win32: version extraction method update * deps: bump frida to the latest * TODO: auto-detect should be updated * TODO: docs should be updated as well
|
looks like this day has come already which is much faster than I thought. I've migrated the win32's CDP patch method to yours and tested, but seems like win32's calling convention is probably different with darwin or linux. could you please test the latest CDP patch method on linux if you are available? really appreciated! |
|
Hello, I'd be happy to help. But the WeChat on my Linux has already been updated to 4.1.13.9, so it seems we don't have the latest WMPF support yet (the latest internal version is #272 looks like something AI-assisted; I'm not sure if it's usable, but I'll submit a patch tomorrow. |
|
thank you so much for your help!
right, and i reviewed the code but the author wasn’t responding. we probably need another way to detect the WMPF version on linux; windows also has similar changes of version detection btw since the WeChatAppEx binary was moved out from the runtime directory of each version (commit 2970a6c). |



I submitted the Linux support yesterday: #261
But I later discovered that it seemed to have some issues, such as: no network events, inability to view the source code, and the console constantly displaying “access violation” errors:
After printing
inputValue, I noticed that in some cases it appears to point to an invalid memory address.To figure out the cause, I looked into the
SendToClientFilterfunction, but it’s too complex. I think it’s a filter designed to help WeChat prevent debuggers from seeing certain specific things, but I don’t know why it causes*a1to be written to an invalid address.But I discovered something else interesting: under certain circumstances, messages aren't passed through the filter but are converted directly to JSON.
So I tried converting the message directly to JSON and returning it without filtering it first, and it worked great!
I don't think it's harmful to leave it unfiltered. 😏
In addition, I noticed changes to the
patchCDPFilterfunction. Please note that Linux uses the SysV ABI, and the first two integer parameters are passed via RDI/RSI. I recommend using Frida’s cross-platform method for accessing parameters.If you have any ideas, please let me know!