@jshookmcp/jshook 0.2.8 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. package/README.md +36 -5
  2. package/README.zh.md +36 -5
  3. package/dist/{AntiCheatDetector-S8VRj-dD.mjs → AntiCheatDetector-BNk-EoBt.mjs} +3 -3
  4. package/dist/{CodeInjector-4Z3ngPoX.mjs → CodeInjector-Cq8q01kp.mjs} +5 -5
  5. package/dist/ConsoleMonitor-CPVQW1Y-.mjs +2201 -0
  6. package/dist/{DarwinAPI-B8hg_yhz.mjs → DarwinAPI-BNPxu0RH.mjs} +1 -1
  7. package/dist/DetailedDataManager-BQQcxh64.mjs +217 -0
  8. package/dist/EventBus-DgPmwpeu.mjs +141 -0
  9. package/dist/EvidenceGraphBridge-SFesNera.mjs +153 -0
  10. package/dist/{ExtensionManager-D5-bO9D8.mjs → ExtensionManager-CWYgw0YW.mjs} +13 -6
  11. package/dist/{FingerprintManager-BVxFJL2-.mjs → FingerprintManager-gzWtkKuf.mjs} +1 -1
  12. package/dist/{HardwareBreakpoint-DK1yjWkV.mjs → HardwareBreakpoint-B9gZCdFP.mjs} +3 -3
  13. package/dist/{HeapAnalyzer-CEbo10xU.mjs → HeapAnalyzer-BLDH0dCv.mjs} +4 -4
  14. package/dist/HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs +639 -0
  15. package/dist/InstrumentationSession-CvPC7Jwy.mjs +244 -0
  16. package/dist/{MemoryController-DdtnBdD4.mjs → MemoryController-CbVdCIJF.mjs} +3 -3
  17. package/dist/{MemoryScanSession-RMixN3bX.mjs → MemoryScanSession-BsDZbLYm.mjs} +81 -78
  18. package/dist/{MemoryScanner-QjK4ld0B.mjs → MemoryScanner-Bcpml6II.mjs} +44 -18
  19. package/dist/{NativeMemoryManager.impl-CB6gJ0NM.mjs → NativeMemoryManager.impl-dZtA1ZGn.mjs} +14 -53
  20. package/dist/{NativeMemoryManager.utils-BML4q1ry.mjs → NativeMemoryManager.utils-B-FjA2mJ.mjs} +1 -1
  21. package/dist/{PEAnalyzer-CK0xe0Fs.mjs → PEAnalyzer-D1lzJ_VG.mjs} +2 -2
  22. package/dist/PageController-Bqm2kZ_X.mjs +417 -0
  23. package/dist/{PointerChainEngine-Cd73qu5b.mjs → PointerChainEngine-BOhyVsjx.mjs} +4 -4
  24. package/dist/PrerequisiteError-Dl33Svkz.mjs +20 -0
  25. package/dist/ResponseBuilder-D3iFYx2N.mjs +143 -0
  26. package/dist/ReverseEvidenceGraph-Dlsk94LC.mjs +269 -0
  27. package/dist/ScriptManager-aHHq0X7U.mjs +3000 -0
  28. package/dist/{Speedhack-CeF0XmEz.mjs → Speedhack-CqdIFlQl.mjs} +2 -2
  29. package/dist/{StructureAnalyzer-D4GkMduU.mjs → StructureAnalyzer-DhFaPvRO.mjs} +3 -3
  30. package/dist/ToolCatalog-C0JGZoOm.mjs +582 -0
  31. package/dist/ToolError-jh9whhMd.mjs +15 -0
  32. package/dist/ToolProbe-oC7aPrkv.mjs +45 -0
  33. package/dist/ToolRegistry-BjaF4oNz.mjs +131 -0
  34. package/dist/ToolRouter.policy-BWV67ZK-.mjs +304 -0
  35. package/dist/TraceRecorder-DgxyVbdQ.mjs +519 -0
  36. package/dist/{Win32API-Bc0QnQsN.mjs → Win32API-CePkipZY.mjs} +1 -1
  37. package/dist/{Win32Debug-DUHt9XUn.mjs → Win32Debug-BvKs-gxc.mjs} +2 -2
  38. package/dist/WorkflowEngine-CuvkZtWu.mjs +598 -0
  39. package/dist/analysis-CL9uACt9.mjs +463 -0
  40. package/dist/antidebug-CqDTB_uk.mjs +1081 -0
  41. package/dist/artifactRetention-CFEprwPw.mjs +591 -0
  42. package/dist/artifacts-Bk2-_uPq.mjs +59 -0
  43. package/dist/betterSqlite3-0pqusHHH.mjs +74 -0
  44. package/dist/binary-instrument-CXfpx6fT.mjs +979 -0
  45. package/dist/bind-helpers-xFfRF-qm.mjs +22 -0
  46. package/dist/boringssl-inspector-BH2D3VKc.mjs +180 -0
  47. package/dist/browser-BpOr5PEx.mjs +4082 -0
  48. package/dist/concurrency-Bt0yv1kJ.mjs +41 -0
  49. package/dist/{constants-CCvsN80K.mjs → constants-B0OANIBL.mjs} +88 -46
  50. package/dist/coordination-qUbyF8KU.mjs +259 -0
  51. package/dist/debugger-gnKxRSN0.mjs +1271 -0
  52. package/dist/definitions-6M-eejaT.mjs +53 -0
  53. package/dist/definitions-B18eyf0B.mjs +18 -0
  54. package/dist/definitions-B3QdlrHv.mjs +34 -0
  55. package/dist/definitions-B4rAvHNZ.mjs +63 -0
  56. package/dist/definitions-BB_4jnmy.mjs +37 -0
  57. package/dist/definitions-BMfYXoNC.mjs +43 -0
  58. package/dist/definitions-Beid2EB3.mjs +27 -0
  59. package/dist/definitions-C1UvM5Iy.mjs +126 -0
  60. package/dist/definitions-CXEI7QC72.mjs +216 -0
  61. package/dist/definitions-C_4r7Fo-2.mjs +14 -0
  62. package/dist/definitions-CkFDALoa.mjs +26 -0
  63. package/dist/definitions-Cke7zEb8.mjs +94 -0
  64. package/dist/definitions-ClJLzsJQ.mjs +25 -0
  65. package/dist/definitions-Cq-zroAU.mjs +28 -0
  66. package/dist/definitions-Cy3Sl6gV.mjs +34 -0
  67. package/dist/definitions-D3VsGcvz.mjs +47 -0
  68. package/dist/definitions-DVGfrn7y.mjs +96 -0
  69. package/dist/definitions-LKpC3-nL.mjs +9 -0
  70. package/dist/definitions-bAhHQJq9.mjs +359 -0
  71. package/dist/encoding-Bvz5jLRv.mjs +1065 -0
  72. package/dist/evidence-graph-bridge-C_fv9PuC.mjs +135 -0
  73. package/dist/{factory-CibqTNC8.mjs → factory-DxlGh9Xf.mjs} +37 -52
  74. package/dist/graphql-DYWzJ29s.mjs +1026 -0
  75. package/dist/handlers-9sAbfIg-.mjs +2552 -0
  76. package/dist/handlers-Bl8zkwz1.mjs +2716 -0
  77. package/dist/handlers-C67ktuRN.mjs +710 -0
  78. package/dist/handlers-C87g8oCe.mjs +276 -0
  79. package/dist/handlers-CTsDAO6p.mjs +681 -0
  80. package/dist/handlers-Cgyg6c0U.mjs +645 -0
  81. package/dist/handlers-D6j6yka7.mjs +2124 -0
  82. package/dist/handlers-DdFzXLvF.mjs +446 -0
  83. package/dist/handlers-DeLOCd5m.mjs +799 -0
  84. package/dist/handlers-DlCJN4Td.mjs +757 -0
  85. package/dist/handlers-DxGIq15_2.mjs +917 -0
  86. package/dist/handlers-U6L4xhuF.mjs +585 -0
  87. package/dist/handlers-tB9Mp9ZK.mjs +84 -0
  88. package/dist/handlers-tiy7EIBp.mjs +572 -0
  89. package/dist/handlers.impl-DS0d9fUw.mjs +761 -0
  90. package/dist/hooks-CzCWByww.mjs +898 -0
  91. package/dist/index.mjs +377 -155
  92. package/dist/{logger-BmWzC2lM.mjs → logger-Dh_xb7_2.mjs} +14 -6
  93. package/dist/maintenance-P7ePRXQC.mjs +830 -0
  94. package/dist/manifest-2ToTpjv8.mjs +106 -0
  95. package/dist/manifest-3g71z6Bg.mjs +79 -0
  96. package/dist/manifest-82baTv4U.mjs +45 -0
  97. package/dist/manifest-B3QVVeBS.mjs +82 -0
  98. package/dist/manifest-BB2J8IMJ.mjs +149 -0
  99. package/dist/manifest-BKbgbSiY.mjs +60 -0
  100. package/dist/manifest-Bcf-TJzH.mjs +848 -0
  101. package/dist/manifest-BmtZzQiQ2.mjs +45 -0
  102. package/dist/manifest-Bnd7kqEY.mjs +55 -0
  103. package/dist/manifest-BqQX6OQC2.mjs +65 -0
  104. package/dist/manifest-BqrQ4Tpj.mjs +81 -0
  105. package/dist/manifest-Br4RPFt5.mjs +370 -0
  106. package/dist/manifest-C5qDjysN.mjs +107 -0
  107. package/dist/manifest-C9RT5nk32.mjs +34 -0
  108. package/dist/manifest-CAhOuvSl.mjs +204 -0
  109. package/dist/manifest-CBYWCUBJ.mjs +51 -0
  110. package/dist/manifest-CFADCRa1.mjs +37 -0
  111. package/dist/manifest-CQVhavRF.mjs +114 -0
  112. package/dist/manifest-CT7zZBV1.mjs +48 -0
  113. package/dist/manifest-CV12bcrF.mjs +121 -0
  114. package/dist/manifest-CXsRWjjI.mjs +224 -0
  115. package/dist/manifest-CZLUCfG02.mjs +95 -0
  116. package/dist/manifest-D6phHKFd.mjs +131 -0
  117. package/dist/manifest-DCyjf4n2.mjs +294 -0
  118. package/dist/manifest-DHsnKgP6.mjs +60 -0
  119. package/dist/manifest-Df_dliIe.mjs +55 -0
  120. package/dist/manifest-Dh8WBmEW.mjs +129 -0
  121. package/dist/manifest-DhKRAT8_.mjs +92 -0
  122. package/dist/manifest-DlpTj4ic2.mjs +193 -0
  123. package/dist/manifest-DrbmZcFl2.mjs +253 -0
  124. package/dist/manifest-DuwHjUa5.mjs +70 -0
  125. package/dist/manifest-DzwvxPJX.mjs +38 -0
  126. package/dist/manifest-NXctwWQq.mjs +68 -0
  127. package/dist/manifest-Sc_0JQ13.mjs +418 -0
  128. package/dist/manifest-gZ4s_UtG.mjs +96 -0
  129. package/dist/manifest-qSleDqdO.mjs +1023 -0
  130. package/dist/modules-C184v-S9.mjs +11365 -0
  131. package/dist/mojo-ipc-B_H61Afw.mjs +525 -0
  132. package/dist/network-671Cw6hV.mjs +3346 -0
  133. package/dist/{artifacts-BbdOMET5.mjs → outputPaths-B1uGmrWZ.mjs} +219 -212
  134. package/dist/parse-args-BlRjqlkL.mjs +39 -0
  135. package/dist/platform-WmNn8Sxb.mjs +2070 -0
  136. package/dist/process-QcbIy5Zq.mjs +1401 -0
  137. package/dist/proxy-DqNs0bAd.mjs +170 -0
  138. package/dist/registry-D-6e18lB.mjs +34 -0
  139. package/dist/response-BQVP-xUn.mjs +28 -0
  140. package/dist/server/plugin-api.mjs +2 -2
  141. package/dist/shared-state-board-DV-dpHFJ.mjs +586 -0
  142. package/dist/sourcemap-Dq8ez8vS.mjs +650 -0
  143. package/dist/ssrf-policy-ZaUfvhq7.mjs +166 -0
  144. package/dist/streaming-BUQ0VJsg.mjs +725 -0
  145. package/dist/tool-builder-DCbIC5Eo.mjs +186 -0
  146. package/dist/transform-CiYJfNX0.mjs +1007 -0
  147. package/dist/types-Bx92KJfT.mjs +4 -0
  148. package/dist/wasm-DQTnHDs4.mjs +531 -0
  149. package/dist/workflow-f3xJOcjx.mjs +725 -0
  150. package/package.json +16 -16
  151. package/dist/ExtensionManager-CPTJhHFg.mjs +0 -2
  152. package/dist/ToolCatalog-Bq4V2sbJ.mjs +0 -67201
  153. package/dist/{CacheAdapters-CzFNpD9a.mjs → CacheAdapters-CDe5WPSV.mjs} +0 -0
  154. package/dist/{StealthVerifier-BzBCFiwx.mjs → StealthVerifier-Bo4T3bz8.mjs} +0 -0
  155. package/dist/{VersionDetector-CNXcvD46.mjs → VersionDetector-CwVLVdDM.mjs} +0 -0
  156. package/dist/{formatAddress-ChCSIRWT.mjs → formatAddress-DVkj9kpI.mjs} +0 -0
  157. package/dist/{types-BBjOqye-.mjs → types-CPhOReNX.mjs} +1 -1
@@ -0,0 +1,761 @@
1
+ import { Lt as MEMORY_SCAN_MAX_RESULTS } from "./constants-B0OANIBL.mjs";
2
+ //#region src/server/domains/memory/handlers/session.ts
3
+ function toTextResponse$6(payload) {
4
+ return { content: [{
5
+ type: "text",
6
+ text: JSON.stringify(payload, null, 2)
7
+ }] };
8
+ }
9
+ function toErrorResponse$6(tool, error) {
10
+ return toTextResponse$6({
11
+ success: false,
12
+ tool,
13
+ error: error instanceof Error ? error.message : String(error)
14
+ });
15
+ }
16
+ var SessionHandlers = class {
17
+ constructor(sessionManager) {
18
+ this.sessionManager = sessionManager;
19
+ }
20
+ async handleScanList(_args) {
21
+ try {
22
+ const sessions = this.sessionManager.listSessions();
23
+ return toTextResponse$6({
24
+ success: true,
25
+ sessions,
26
+ count: sessions.length
27
+ });
28
+ } catch (error) {
29
+ return toErrorResponse$6("memory_scan_list", error);
30
+ }
31
+ }
32
+ async handleScanDelete(args) {
33
+ try {
34
+ return toTextResponse$6({
35
+ success: true,
36
+ deleted: this.sessionManager.deleteSession(args.sessionId)
37
+ });
38
+ } catch (error) {
39
+ return toErrorResponse$6("memory_scan_delete", error);
40
+ }
41
+ }
42
+ async handleScanExport(args) {
43
+ try {
44
+ return toTextResponse$6({
45
+ success: true,
46
+ exportedData: this.sessionManager.exportSession(args.sessionId)
47
+ });
48
+ } catch (error) {
49
+ return toErrorResponse$6("memory_scan_export", error);
50
+ }
51
+ }
52
+ };
53
+ //#endregion
54
+ //#region src/server/domains/memory/handlers/scan.ts
55
+ /** SECURITY: Cap user-supplied maxResults to prevent OOM */
56
+ function capMaxResults(value) {
57
+ if (value === void 0 || !Number.isFinite(value) || value <= 0) return MEMORY_SCAN_MAX_RESULTS;
58
+ return Math.min(value, MEMORY_SCAN_MAX_RESULTS);
59
+ }
60
+ function toTextResponse$5(payload) {
61
+ return { content: [{
62
+ type: "text",
63
+ text: JSON.stringify(payload, null, 2)
64
+ }] };
65
+ }
66
+ function toErrorResponse$5(tool, error) {
67
+ return toTextResponse$5({
68
+ success: false,
69
+ tool,
70
+ error: error instanceof Error ? error.message : String(error)
71
+ });
72
+ }
73
+ var ScanHandlers = class {
74
+ constructor(scanner, eventBus) {
75
+ this.scanner = scanner;
76
+ this.eventBus = eventBus;
77
+ }
78
+ async handleFirstScan(args) {
79
+ try {
80
+ const options = {
81
+ valueType: args.valueType,
82
+ alignment: args.alignment,
83
+ maxResults: capMaxResults(args.maxResults),
84
+ regionFilter: args.regionFilter,
85
+ onProgress: args.onProgress
86
+ };
87
+ const result = await this.scanner.firstScan(args.pid, args.value, options);
88
+ this.eventBus?.emit("memory:scan_completed", {
89
+ scanType: "first",
90
+ resultCount: result.totalMatches ?? 0,
91
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
92
+ });
93
+ return toTextResponse$5({
94
+ success: true,
95
+ ...result,
96
+ hint: result.totalMatches > 0 ? `Found ${result.totalMatches} matches. Use memory_next_scan with sessionId "${result.sessionId}" to narrow down.` : "No matches found. Try a different value or type."
97
+ });
98
+ } catch (error) {
99
+ return toErrorResponse$5("memory_first_scan", error);
100
+ }
101
+ }
102
+ async handleNextScan(args) {
103
+ try {
104
+ const result = await this.scanner.nextScan(args.sessionId, args.mode, args.value, args.value2);
105
+ return toTextResponse$5({
106
+ success: true,
107
+ ...result,
108
+ hint: result.totalMatches <= 10 ? "Few matches remaining — inspect these addresses." : `${result.totalMatches} matches remain. Continue narrowing with memory_next_scan.`
109
+ });
110
+ } catch (error) {
111
+ return toErrorResponse$5("memory_next_scan", error);
112
+ }
113
+ }
114
+ async handleUnknownScan(args) {
115
+ try {
116
+ const options = {
117
+ valueType: args.valueType,
118
+ alignment: args.alignment,
119
+ maxResults: capMaxResults(args.maxResults),
120
+ regionFilter: args.regionFilter,
121
+ onProgress: args.onProgress
122
+ };
123
+ const result = await this.scanner.unknownInitialScan(args.pid, options);
124
+ return toTextResponse$5({
125
+ success: true,
126
+ ...result,
127
+ hint: `Captured ${result.totalMatches} addresses. Use memory_next_scan with changed/unchanged/increased/decreased to narrow.`
128
+ });
129
+ } catch (error) {
130
+ return toErrorResponse$5("memory_unknown_scan", error);
131
+ }
132
+ }
133
+ async handlePointerScan(args) {
134
+ try {
135
+ return toTextResponse$5({
136
+ success: true,
137
+ ...await this.scanner.pointerScan(args.pid, args.targetAddress, {
138
+ maxResults: capMaxResults(args.maxResults),
139
+ moduleOnly: args.moduleOnly
140
+ })
141
+ });
142
+ } catch (error) {
143
+ return toErrorResponse$5("memory_pointer_scan", error);
144
+ }
145
+ }
146
+ async handleGroupScan(args) {
147
+ try {
148
+ return toTextResponse$5({
149
+ success: true,
150
+ ...await this.scanner.groupScan(args.pid, args.pattern, {
151
+ alignment: args.alignment,
152
+ maxResults: capMaxResults(args.maxResults)
153
+ })
154
+ });
155
+ } catch (error) {
156
+ return toErrorResponse$5("memory_group_scan", error);
157
+ }
158
+ }
159
+ };
160
+ //#endregion
161
+ //#region src/server/domains/memory/handlers/pointer-chain.ts
162
+ function toTextResponse$4(payload) {
163
+ return { content: [{
164
+ type: "text",
165
+ text: JSON.stringify(payload, null, 2)
166
+ }] };
167
+ }
168
+ function toErrorResponse$4(tool, error) {
169
+ return toTextResponse$4({
170
+ success: false,
171
+ tool,
172
+ error: error instanceof Error ? error.message : String(error)
173
+ });
174
+ }
175
+ var PointerChainHandlers = class {
176
+ constructor(ptrEngine) {
177
+ this.ptrEngine = ptrEngine;
178
+ }
179
+ async handlePointerChainScan(args) {
180
+ try {
181
+ const result = await this.ptrEngine.scan(args.pid, args.targetAddress, {
182
+ maxDepth: args.maxDepth,
183
+ maxOffset: args.maxOffset,
184
+ staticOnly: args.staticOnly,
185
+ modules: args.modules,
186
+ maxResults: args.maxResults
187
+ });
188
+ return toTextResponse$4({
189
+ success: true,
190
+ ...result,
191
+ hint: result.totalFound > 0 ? `Found ${result.totalFound} pointer chains. Static chains survive process restarts.` : "No pointer chains found. Try increasing maxDepth or maxOffset."
192
+ });
193
+ } catch (error) {
194
+ return toErrorResponse$4("memory_pointer_chain_scan", error);
195
+ }
196
+ }
197
+ async handlePointerChainValidate(args) {
198
+ try {
199
+ const chains = JSON.parse(args.chains);
200
+ const results = await this.ptrEngine.validateChains(args.pid, chains);
201
+ return toTextResponse$4({
202
+ success: true,
203
+ results,
204
+ validCount: results.filter((r) => r.isValid).length,
205
+ totalChecked: chains.length
206
+ });
207
+ } catch (error) {
208
+ return toErrorResponse$4("memory_pointer_chain_validate", error);
209
+ }
210
+ }
211
+ async handlePointerChainResolve(args) {
212
+ try {
213
+ const chain = JSON.parse(args.chain);
214
+ const resolved = await this.ptrEngine.resolveChain(args.pid, chain);
215
+ return toTextResponse$4({
216
+ success: true,
217
+ chainId: chain.id,
218
+ resolvedAddress: resolved,
219
+ isResolvable: resolved !== null
220
+ });
221
+ } catch (error) {
222
+ return toErrorResponse$4("memory_pointer_chain_resolve", error);
223
+ }
224
+ }
225
+ async handlePointerChainExport(args) {
226
+ try {
227
+ const chains = JSON.parse(args.chains);
228
+ return toTextResponse$4({
229
+ success: true,
230
+ exportedData: this.ptrEngine.exportChains(chains),
231
+ chainCount: chains.length
232
+ });
233
+ } catch (error) {
234
+ return toErrorResponse$4("memory_pointer_chain_export", error);
235
+ }
236
+ }
237
+ };
238
+ //#endregion
239
+ //#region src/server/domains/memory/handlers/structure.ts
240
+ function toTextResponse$3(payload) {
241
+ return { content: [{
242
+ type: "text",
243
+ text: JSON.stringify(payload, null, 2)
244
+ }] };
245
+ }
246
+ function toErrorResponse$3(tool, error) {
247
+ return toTextResponse$3({
248
+ success: false,
249
+ tool,
250
+ error: error instanceof Error ? error.message : String(error)
251
+ });
252
+ }
253
+ var StructureHandlers = class {
254
+ constructor(structAnalyzer) {
255
+ this.structAnalyzer = structAnalyzer;
256
+ }
257
+ async handleStructureAnalyze(args) {
258
+ try {
259
+ const result = await this.structAnalyzer.analyzeStructure(args.pid, args.address, {
260
+ size: args.size,
261
+ otherInstances: args.otherInstances,
262
+ parseRtti: args.parseRtti
263
+ });
264
+ return toTextResponse$3({
265
+ success: true,
266
+ ...result,
267
+ hint: result.className ? `Detected class: ${result.className}${result.baseClasses?.length ? ` (inherits: ${result.baseClasses.join(" → ")})` : ""}` : `Inferred ${result.fields.length} fields. Use memory_structure_export_c to export as C struct.`
268
+ });
269
+ } catch (error) {
270
+ return toErrorResponse$3("memory_structure_analyze", error);
271
+ }
272
+ }
273
+ async handleVtableParse(args) {
274
+ try {
275
+ return toTextResponse$3({
276
+ success: true,
277
+ ...await this.structAnalyzer.parseVtable(args.pid, args.vtableAddress)
278
+ });
279
+ } catch (error) {
280
+ return toErrorResponse$3("memory_vtable_parse", error);
281
+ }
282
+ }
283
+ async handleStructureExportC(args) {
284
+ try {
285
+ const structure = JSON.parse(args.structure);
286
+ return toTextResponse$3({
287
+ success: true,
288
+ ...this.structAnalyzer.exportToCStruct(structure, args.name)
289
+ });
290
+ } catch (error) {
291
+ return toErrorResponse$3("memory_structure_export_c", error);
292
+ }
293
+ }
294
+ async handleStructureCompare(args) {
295
+ try {
296
+ const result = await this.structAnalyzer.compareInstances(args.pid, args.address1, args.address2, args.size);
297
+ return toTextResponse$3({
298
+ success: true,
299
+ matchingFieldCount: result.matching.length,
300
+ differingFieldCount: result.differing.length,
301
+ ...result
302
+ });
303
+ } catch (error) {
304
+ return toErrorResponse$3("memory_structure_compare", error);
305
+ }
306
+ }
307
+ };
308
+ //#endregion
309
+ //#region src/server/domains/memory/handlers/hooks.ts
310
+ function toTextResponse$2(payload) {
311
+ return { content: [{
312
+ type: "text",
313
+ text: JSON.stringify(payload, null, 2)
314
+ }] };
315
+ }
316
+ function toErrorResponse$2(tool, error) {
317
+ return toTextResponse$2({
318
+ success: false,
319
+ tool,
320
+ error: error instanceof Error ? error.message : String(error)
321
+ });
322
+ }
323
+ var HookHandlers = class {
324
+ constructor(bpEngine, injector) {
325
+ this.bpEngine = bpEngine;
326
+ this.injector = injector;
327
+ }
328
+ async handleBreakpointSet(args) {
329
+ try {
330
+ return toTextResponse$2({
331
+ success: true,
332
+ ...await this.bpEngine.setBreakpoint(args.pid, args.address, args.access, args.size ?? 4),
333
+ hint: `Hardware breakpoint set on DR register. Use memory_breakpoint_trace to collect hits.`
334
+ });
335
+ } catch (error) {
336
+ return toErrorResponse$2("memory_breakpoint_set", error);
337
+ }
338
+ }
339
+ async handleBreakpointRemove(args) {
340
+ try {
341
+ return toTextResponse$2({
342
+ success: true,
343
+ removed: await this.bpEngine.removeBreakpoint(args.breakpointId)
344
+ });
345
+ } catch (error) {
346
+ return toErrorResponse$2("memory_breakpoint_remove", error);
347
+ }
348
+ }
349
+ async handleBreakpointList(_args) {
350
+ try {
351
+ const bps = this.bpEngine.listBreakpoints();
352
+ return toTextResponse$2({
353
+ success: true,
354
+ breakpoints: bps,
355
+ count: bps.length
356
+ });
357
+ } catch (error) {
358
+ return toErrorResponse$2("memory_breakpoint_list", error);
359
+ }
360
+ }
361
+ async handleBreakpointTrace(args) {
362
+ try {
363
+ const hits = await this.bpEngine.traceAccess(args.pid, args.address, args.access, args.maxHits, args.timeoutMs);
364
+ return toTextResponse$2({
365
+ success: true,
366
+ hits,
367
+ hitCount: hits.length,
368
+ hint: hits.length > 0 ? `${hits.length} accesses captured. Check instructionAddress to find the code accessing this address.` : "No hits captured within timeout."
369
+ });
370
+ } catch (error) {
371
+ return toErrorResponse$2("memory_breakpoint_trace", error);
372
+ }
373
+ }
374
+ async handlePatchBytes(args) {
375
+ try {
376
+ const patch = await this.injector.patchBytes(args.pid, args.address, args.bytes);
377
+ return toTextResponse$2({
378
+ success: true,
379
+ ...patch,
380
+ hint: `Patch applied. Use memory_patch_undo with patchId "${patch.id}" to restore.`
381
+ });
382
+ } catch (error) {
383
+ return toErrorResponse$2("memory_patch_bytes", error);
384
+ }
385
+ }
386
+ async handlePatchNop(args) {
387
+ try {
388
+ return toTextResponse$2({
389
+ success: true,
390
+ ...await this.injector.nopBytes(args.pid, args.address, args.count),
391
+ hint: `${args.count} bytes NOP'd. Use memory_patch_undo to restore.`
392
+ });
393
+ } catch (error) {
394
+ return toErrorResponse$2("memory_patch_nop", error);
395
+ }
396
+ }
397
+ async handlePatchUndo(args) {
398
+ try {
399
+ return toTextResponse$2({
400
+ success: true,
401
+ restored: await this.injector.unpatch(args.patchId)
402
+ });
403
+ } catch (error) {
404
+ return toErrorResponse$2("memory_patch_undo", error);
405
+ }
406
+ }
407
+ async handleCodeCaves(args) {
408
+ try {
409
+ const caves = await this.injector.findCodeCaves(args.pid, args.minSize);
410
+ return toTextResponse$2({
411
+ success: true,
412
+ caves,
413
+ count: caves.length
414
+ });
415
+ } catch (error) {
416
+ return toErrorResponse$2("memory_code_caves", error);
417
+ }
418
+ }
419
+ };
420
+ //#endregion
421
+ //#region src/server/domains/memory/handlers/readwrite.ts
422
+ function toTextResponse$1(payload) {
423
+ return { content: [{
424
+ type: "text",
425
+ text: JSON.stringify(payload, null, 2)
426
+ }] };
427
+ }
428
+ function toErrorResponse$1(tool, error) {
429
+ return toTextResponse$1({
430
+ success: false,
431
+ tool,
432
+ error: error instanceof Error ? error.message : String(error)
433
+ });
434
+ }
435
+ var ReadWriteHandlers = class {
436
+ constructor(memCtrl) {
437
+ this.memCtrl = memCtrl;
438
+ }
439
+ async handleWriteValue(args) {
440
+ try {
441
+ return toTextResponse$1({
442
+ success: true,
443
+ ...await this.memCtrl.writeValue(args.pid, args.address, args.value, args.valueType),
444
+ hint: "Use memory_write_undo to revert."
445
+ });
446
+ } catch (error) {
447
+ return toErrorResponse$1("memory_write_value", error);
448
+ }
449
+ }
450
+ async handleFreeze(args) {
451
+ try {
452
+ const entry = await this.memCtrl.freeze(args.pid, args.address, args.value, args.valueType, args.intervalMs);
453
+ return toTextResponse$1({
454
+ success: true,
455
+ ...entry,
456
+ hint: `Frozen. Use memory_unfreeze with freezeId "${entry.id}" to stop.`
457
+ });
458
+ } catch (error) {
459
+ return toErrorResponse$1("memory_freeze", error);
460
+ }
461
+ }
462
+ async handleUnfreeze(args) {
463
+ try {
464
+ return toTextResponse$1({
465
+ success: true,
466
+ unfrozen: await this.memCtrl.unfreeze(args.freezeId)
467
+ });
468
+ } catch (error) {
469
+ return toErrorResponse$1("memory_unfreeze", error);
470
+ }
471
+ }
472
+ async handleDump(args) {
473
+ try {
474
+ return toTextResponse$1({
475
+ success: true,
476
+ dump: await this.memCtrl.dumpMemoryHex(args.pid, args.address, args.size ?? 256)
477
+ });
478
+ } catch (error) {
479
+ return toErrorResponse$1("memory_dump", error);
480
+ }
481
+ }
482
+ async handleWriteUndo(_args) {
483
+ try {
484
+ const entry = await this.memCtrl.undo();
485
+ return toTextResponse$1({
486
+ success: true,
487
+ undone: entry !== null,
488
+ entry
489
+ });
490
+ } catch (error) {
491
+ return toErrorResponse$1("memory_write_undo", error);
492
+ }
493
+ }
494
+ async handleWriteRedo(_args) {
495
+ try {
496
+ const entry = await this.memCtrl.redo();
497
+ return toTextResponse$1({
498
+ success: true,
499
+ redone: entry !== null,
500
+ entry
501
+ });
502
+ } catch (error) {
503
+ return toErrorResponse$1("memory_write_redo", error);
504
+ }
505
+ }
506
+ };
507
+ //#endregion
508
+ //#region src/server/domains/memory/handlers/integrity.ts
509
+ function toTextResponse(payload) {
510
+ return { content: [{
511
+ type: "text",
512
+ text: JSON.stringify(payload, null, 2)
513
+ }] };
514
+ }
515
+ function toErrorResponse(tool, error) {
516
+ return toTextResponse({
517
+ success: false,
518
+ tool,
519
+ error: error instanceof Error ? error.message : String(error)
520
+ });
521
+ }
522
+ var IntegrityHandlers = class {
523
+ constructor(speedhackEngine, heapAnalyzer, peAnalyzer, antiCheatDetector) {
524
+ this.speedhackEngine = speedhackEngine;
525
+ this.heapAnalyzer = heapAnalyzer;
526
+ this.peAnalyzer = peAnalyzer;
527
+ this.antiCheatDetector = antiCheatDetector;
528
+ }
529
+ async handleSpeedhackApply(args) {
530
+ try {
531
+ return toTextResponse({
532
+ ...await this.speedhackEngine.apply(args.pid, args.speed),
533
+ success: true,
534
+ hint: `Speedhack active (${args.speed}x). Use memory_speedhack({ action: 'set' }) to adjust.`
535
+ });
536
+ } catch (error) {
537
+ return toErrorResponse("memory_speedhack", error);
538
+ }
539
+ }
540
+ async handleSpeedhackSet(args) {
541
+ try {
542
+ return toTextResponse({
543
+ success: true,
544
+ updated: await this.speedhackEngine.setSpeed(args.pid, args.speed),
545
+ newSpeed: args.speed
546
+ });
547
+ } catch (error) {
548
+ return toErrorResponse("memory_speedhack", error);
549
+ }
550
+ }
551
+ async handleHeapEnumerate(args) {
552
+ try {
553
+ const result = await this.heapAnalyzer.enumerateHeaps(args.pid);
554
+ return toTextResponse({
555
+ success: true,
556
+ ...result,
557
+ hint: `Enumerated ${result.heaps.length} heaps. Use memory_heap_stats for statistics or memory_heap_anomalies to check for issues.`
558
+ });
559
+ } catch (error) {
560
+ return toErrorResponse("memory_heap_enumerate", error);
561
+ }
562
+ }
563
+ async handleHeapStats(args) {
564
+ try {
565
+ return toTextResponse({
566
+ success: true,
567
+ ...await this.heapAnalyzer.getStats(args.pid)
568
+ });
569
+ } catch (error) {
570
+ return toErrorResponse("memory_heap_stats", error);
571
+ }
572
+ }
573
+ async handleHeapAnomalies(args) {
574
+ try {
575
+ const anomalies = await this.heapAnalyzer.detectAnomalies(args.pid);
576
+ return toTextResponse({
577
+ success: true,
578
+ anomalies,
579
+ count: anomalies.length,
580
+ hint: anomalies.length > 0 ? `Found ${anomalies.length} anomalies — inspect types for spray, UAF, or suspicious patterns.` : "No heap anomalies detected."
581
+ });
582
+ } catch (error) {
583
+ return toErrorResponse("memory_heap_anomalies", error);
584
+ }
585
+ }
586
+ async handlePEHeaders(args) {
587
+ try {
588
+ return toTextResponse({
589
+ success: true,
590
+ ...await this.peAnalyzer.parseHeaders(args.pid, args.moduleBase)
591
+ });
592
+ } catch (error) {
593
+ return toErrorResponse("memory_pe_headers", error);
594
+ }
595
+ }
596
+ async handlePEImportsExports(args) {
597
+ try {
598
+ const table = args.table || "both";
599
+ const base = args.moduleBase;
600
+ const pid = args.pid;
601
+ const result = { success: true };
602
+ if (table === "imports" || table === "both") result.imports = await this.peAnalyzer.parseImports(pid, base);
603
+ if (table === "exports" || table === "both") result.exports = await this.peAnalyzer.parseExports(pid, base);
604
+ return toTextResponse(result);
605
+ } catch (error) {
606
+ return toErrorResponse("memory_pe_imports_exports", error);
607
+ }
608
+ }
609
+ async handleInlineHookDetect(args) {
610
+ try {
611
+ const hooks = await this.peAnalyzer.detectInlineHooks(args.pid, args.moduleName);
612
+ return toTextResponse({
613
+ success: true,
614
+ hooks,
615
+ count: hooks.length,
616
+ hint: hooks.length > 0 ? `Detected ${hooks.length} inline hooks — check hookType and jumpTarget for each.` : "No inline hooks detected — exports match disk bytes."
617
+ });
618
+ } catch (error) {
619
+ return toErrorResponse("memory_inline_hook_detect", error);
620
+ }
621
+ }
622
+ async handleAntiCheatDetect(args) {
623
+ try {
624
+ const detections = await this.antiCheatDetector.detect(args.pid);
625
+ return toTextResponse({
626
+ success: true,
627
+ detections,
628
+ count: detections.length,
629
+ hint: detections.length > 0 ? `Found ${detections.length} anti-debug mechanisms. Each includes a bypassSuggestion.` : "No anti-debug mechanisms detected in imports."
630
+ });
631
+ } catch (error) {
632
+ return toErrorResponse("memory_anticheat_detect", error);
633
+ }
634
+ }
635
+ async handleGuardPages(args) {
636
+ try {
637
+ const pages = await this.antiCheatDetector.findGuardPages(args.pid);
638
+ return toTextResponse({
639
+ success: true,
640
+ guardPages: pages,
641
+ count: pages.length,
642
+ hint: pages.length > 0 ? `Found ${pages.length} guard page regions — these may indicate anti-tampering.` : "No guard pages found."
643
+ });
644
+ } catch (error) {
645
+ return toErrorResponse("memory_guard_pages", error);
646
+ }
647
+ }
648
+ async handleIntegrityCheck(args) {
649
+ try {
650
+ const results = await this.antiCheatDetector.checkIntegrity(args.pid, args.moduleName);
651
+ const modified = results.filter((r) => r.isModified);
652
+ return toTextResponse({
653
+ success: true,
654
+ sections: results,
655
+ totalChecked: results.length,
656
+ modifiedCount: modified.length,
657
+ hint: modified.length > 0 ? `${modified.length} section(s) modified — code may have been patched or hooked.` : "All checked sections match disk — no runtime modifications detected."
658
+ });
659
+ } catch (error) {
660
+ return toErrorResponse("memory_integrity_check", error);
661
+ }
662
+ }
663
+ };
664
+ //#endregion
665
+ //#region src/server/domains/memory/handlers.impl.ts
666
+ var MemoryScanHandlers = class {
667
+ sessions;
668
+ scans;
669
+ ptrChains;
670
+ structures;
671
+ hooks;
672
+ readwrite;
673
+ integrity;
674
+ constructor(scanner, sessionManager, ptrEngine, structAnalyzer, bpEngine, injector, memCtrl, speedhackEngine, heapAnalyzer, peAnalyzer, antiCheatDetector, eventBus) {
675
+ this.sessions = new SessionHandlers(sessionManager);
676
+ this.scans = new ScanHandlers(scanner, eventBus);
677
+ this.ptrChains = new PointerChainHandlers(ptrEngine);
678
+ this.structures = new StructureHandlers(structAnalyzer);
679
+ this.hooks = new HookHandlers(bpEngine, injector);
680
+ this.readwrite = new ReadWriteHandlers(memCtrl);
681
+ this.integrity = new IntegrityHandlers(speedhackEngine, heapAnalyzer, peAnalyzer, antiCheatDetector);
682
+ }
683
+ handleScanSessionDispatch(args) {
684
+ switch (String(args["action"] ?? "")) {
685
+ case "delete": return this.sessions.handleScanDelete(args);
686
+ case "export": return this.sessions.handleScanExport(args);
687
+ default: return this.sessions.handleScanList(args);
688
+ }
689
+ }
690
+ handleScanList = (args) => this.sessions.handleScanList(args);
691
+ handleScanDelete = (args) => this.sessions.handleScanDelete(args);
692
+ handleScanExport = (args) => this.sessions.handleScanExport(args);
693
+ handleFirstScan = (args) => this.scans.handleFirstScan(args);
694
+ handleNextScan = (args) => this.scans.handleNextScan(args);
695
+ handleUnknownScan = (args) => this.scans.handleUnknownScan(args);
696
+ handlePointerScan = (args) => this.scans.handlePointerScan(args);
697
+ handleGroupScan = (args) => this.scans.handleGroupScan(args);
698
+ handlePointerChainDispatch(args) {
699
+ switch (String(args["action"] ?? "")) {
700
+ case "validate": return this.ptrChains.handlePointerChainValidate(args);
701
+ case "resolve": return this.ptrChains.handlePointerChainResolve(args);
702
+ case "export": return this.ptrChains.handlePointerChainExport(args);
703
+ default: return this.ptrChains.handlePointerChainScan(args);
704
+ }
705
+ }
706
+ handlePointerChainScan = (args) => this.ptrChains.handlePointerChainScan(args);
707
+ handlePointerChainValidate = (args) => this.ptrChains.handlePointerChainValidate(args);
708
+ handlePointerChainResolve = (args) => this.ptrChains.handlePointerChainResolve(args);
709
+ handlePointerChainExport = (args) => this.ptrChains.handlePointerChainExport(args);
710
+ handleStructureAnalyze = (args) => this.structures.handleStructureAnalyze(args);
711
+ handleVtableParse = (args) => this.structures.handleVtableParse(args);
712
+ handleStructureExportC = (args) => this.structures.handleStructureExportC(args);
713
+ handleStructureCompare = (args) => this.structures.handleStructureCompare(args);
714
+ handleBreakpointDispatch(args) {
715
+ switch (String(args["action"] ?? "")) {
716
+ case "remove": return this.hooks.handleBreakpointRemove(args);
717
+ case "list": return this.hooks.handleBreakpointList(args);
718
+ case "trace": return this.hooks.handleBreakpointTrace(args);
719
+ default: return this.hooks.handleBreakpointSet(args);
720
+ }
721
+ }
722
+ handleBreakpointSet = (args) => this.hooks.handleBreakpointSet(args);
723
+ handleBreakpointRemove = (args) => this.hooks.handleBreakpointRemove(args);
724
+ handleBreakpointList = (args) => this.hooks.handleBreakpointList(args);
725
+ handleBreakpointTrace = (args) => this.hooks.handleBreakpointTrace(args);
726
+ handlePatchBytes = (args) => this.hooks.handlePatchBytes(args);
727
+ handlePatchNop = (args) => this.hooks.handlePatchNop(args);
728
+ handlePatchUndo = (args) => this.hooks.handlePatchUndo(args);
729
+ handleCodeCaves = (args) => this.hooks.handleCodeCaves(args);
730
+ handleFreezeDispatch(args) {
731
+ if (String(args["action"] ?? "") === "unfreeze") return this.readwrite.handleUnfreeze(args);
732
+ return this.readwrite.handleFreeze(args);
733
+ }
734
+ handleWriteHistoryDispatch(args) {
735
+ if (String(args["action"] ?? "") === "redo") return this.readwrite.handleWriteRedo(args);
736
+ return this.readwrite.handleWriteUndo(args);
737
+ }
738
+ handleWriteValue = (args) => this.readwrite.handleWriteValue(args);
739
+ handleFreeze = (args) => this.readwrite.handleFreeze(args);
740
+ handleUnfreeze = (args) => this.readwrite.handleUnfreeze(args);
741
+ handleDump = (args) => this.readwrite.handleDump(args);
742
+ handleWriteUndo = (args) => this.readwrite.handleWriteUndo(args);
743
+ handleWriteRedo = (args) => this.readwrite.handleWriteRedo(args);
744
+ handleSpeedhackDispatch(args) {
745
+ if (String(args["action"] ?? "") === "set") return this.integrity.handleSpeedhackSet(args);
746
+ return this.integrity.handleSpeedhackApply(args);
747
+ }
748
+ handleSpeedhackApply = (args) => this.integrity.handleSpeedhackApply(args);
749
+ handleSpeedhackSet = (args) => this.integrity.handleSpeedhackSet(args);
750
+ handleHeapEnumerate = (args) => this.integrity.handleHeapEnumerate(args);
751
+ handleHeapStats = (args) => this.integrity.handleHeapStats(args);
752
+ handleHeapAnomalies = (args) => this.integrity.handleHeapAnomalies(args);
753
+ handlePEHeaders = (args) => this.integrity.handlePEHeaders(args);
754
+ handlePEImportsExports = (args) => this.integrity.handlePEImportsExports(args);
755
+ handleInlineHookDetect = (args) => this.integrity.handleInlineHookDetect(args);
756
+ handleAntiCheatDetect = (args) => this.integrity.handleAntiCheatDetect(args);
757
+ handleGuardPages = (args) => this.integrity.handleGuardPages(args);
758
+ handleIntegrityCheck = (args) => this.integrity.handleIntegrityCheck(args);
759
+ };
760
+ //#endregion
761
+ export { MemoryScanHandlers };