From d8b966dd1e6ab0cb2423731988521e83294ec880 Mon Sep 17 00:00:00 2001 From: GuGuMur <2221533105@qq.com> Date: Sun, 6 Sep 2026 13:42:32 +0800 Subject: [PATCH 1/2] [platform] fix linux findWmpfProcess to select root process --- src/platform/linux.ts | 44 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 27 deletions(-) diff --git a/src/platform/linux.ts b/src/platform/linux.ts index d1316b6..23845c0 100644 --- a/src/platform/linux.ts +++ b/src/platform/linux.ts @@ -18,34 +18,24 @@ export class LinuxPlatform implements IPlatform { const processes = await localDevice.enumerateProcesses({ scope: frida.Scope.Metadata, }); - const wmpfProcesses = processes.filter( - (process) => process.name === "WeChatAppEx", - ); - const wmpfPids = wmpfProcesses.map((p) => - p.parameters.ppid ? p.parameters.ppid : 0, - ); - // find the parent process - const wmpfPid = wmpfPids - .sort( - (a, b) => - wmpfPids.filter((v) => v === a).length - - wmpfPids.filter((v) => v === b).length, - ) - .pop(); - if (wmpfPid === undefined) { - throw new Error("[frida] WeChatAppEx process not found"); + const allWmpf = processes.filter(p => p.name === "WeChatAppEx"); + for (const proc of allWmpf) { + const ppid = proc.parameters.ppid; + if (!ppid) continue; + const parent = processes.find(p => p.pid === ppid); + if (parent && parent.name !== "WeChatAppEx") { + const wmpfProcessPath = proc.parameters.path as string | undefined; + const wmpfVersion = wmpfProcessPath + ? searchWmpfVersionInFile(wmpfProcessPath) + : 0; + if (wmpfVersion === 0) { + throw new Error("[frida] error in find wmpf version"); + } + return { pid: proc.pid, version: wmpfVersion }; + } } - const wmpfProcess = processes.filter( - (process) => process.pid === wmpfPid, - )[0]; - const wmpfProcessPath = wmpfProcess.parameters.path as string | undefined; - const wmpfVersion = wmpfProcessPath - ? searchWmpfVersionInFile(wmpfProcessPath) - : 0; - if (wmpfVersion === 0) { - throw new Error("[frida] error in find wmpf version"); - } - return { pid: Number(wmpfPid), version: wmpfVersion }; + + throw new Error("[frida] WeChatAppEx root process not found"); } } From 22f6d0c5eaee5ef253491b33743f39ebafa36f7e Mon Sep 17 00:00:00 2001 From: GuGuMur <2221533105@qq.com> Date: Sun, 6 Sep 2026 14:16:19 +0800 Subject: [PATCH 2/2] [platform] fix linux process detection with PID map --- src/platform/linux.ts | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/platform/linux.ts b/src/platform/linux.ts index 23845c0..d490588 100644 --- a/src/platform/linux.ts +++ b/src/platform/linux.ts @@ -18,24 +18,25 @@ export class LinuxPlatform implements IPlatform { const processes = await localDevice.enumerateProcesses({ scope: frida.Scope.Metadata, }); + const pidMap = new Map(processes.map(p => [p.pid, p])); + const rootWmpf = processes.find(p => { + if (p.name !== "WeChatAppEx") return false; + const ppid = Number(p.parameters.ppid); + if (!ppid) return false; + return pidMap.get(ppid)?.name !== "WeChatAppEx"; + }); - const allWmpf = processes.filter(p => p.name === "WeChatAppEx"); - for (const proc of allWmpf) { - const ppid = proc.parameters.ppid; - if (!ppid) continue; - const parent = processes.find(p => p.pid === ppid); - if (parent && parent.name !== "WeChatAppEx") { - const wmpfProcessPath = proc.parameters.path as string | undefined; - const wmpfVersion = wmpfProcessPath - ? searchWmpfVersionInFile(wmpfProcessPath) - : 0; - if (wmpfVersion === 0) { - throw new Error("[frida] error in find wmpf version"); - } - return { pid: proc.pid, version: wmpfVersion }; - } + if (!rootWmpf) { + throw new Error("[frida] WeChatAppEx root process not found"); } - throw new Error("[frida] WeChatAppEx root process not found"); + const wmpfProcessPath = rootWmpf.parameters.path as string | undefined; + const wmpfVersion = wmpfProcessPath + ? searchWmpfVersionInFile(wmpfProcessPath) + : 0; + if (wmpfVersion === 0) { + throw new Error("[frida] error in find wmpf version"); + } + return { pid: rootWmpf.pid, version: wmpfVersion }; } }