| 148 | // --- Stalker.exclude: confine instrumentation ------------------------------- |
| 149 | let excludedOnce = false; |
| 150 | function excludeAllButTargetsOnce(targetMods) { |
| 151 | if (excludedOnce || !CONFIG.excludeAllButTargets) return; |
| 152 | excludedOnce = true; |
| 153 | const keepNames = new Set(targetMods.filter(Boolean)); |
| 154 | let kept = [], n = 0; |
| 155 | try { |
| 156 | for (const m of Process.enumerateModules()) { |
| 157 | const isTarget = [...keepNames].some((name) => m.name.includes(name)); |
| 158 | if (isTarget) { kept.push(m.name); continue; } |
| 159 | try { Stalker.exclude(m); n++; } catch (e) {} |
| 160 | } |
| 161 | } catch (e) {} |
| 162 | console.log(`${C.dim}[fstalk] excluded ${n} modules; instrumenting only: ${kept.join(", ") || "(none?)"}${C.reset}`); |
| 163 | |
| 164 | const FUNC_SPAN = 0x400; |
| 165 | for (const name of (CONFIG.excludeFunctions || [])) { |
| 166 | let a = null; try { a = Module.findGlobalExportByName(name); } catch (e) {} |
| 167 | if (!a) { console.log(`${C.dim}[fstalk] fn-exclude: ${name} not found${C.reset}`); continue; } |
| 168 | try { |
| 169 | Stalker.exclude({ base: a, size: FUNC_SPAN }); |
| 170 | console.log(`${C.dim}[fstalk] fn-exclude: ${name} @ ${resolve(a).text}${C.reset}`); |
| 171 | } catch (e) {} |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | // --- scope filter ----------------------------------------------------------- |
| 176 | function scopeSetFor(defaultModule) { |