@jshookmcp/jshook 0.2.9 → 0.3.0
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.
- package/README.md +2 -2
- package/README.zh.md +2 -2
- package/dist/{AntiCheatDetector-BNk-EoBt.mjs → AntiCheatDetector-CqGDXmfc.mjs} +159 -53
- package/dist/{CodeInjector-Cq8q01kp.mjs → CodeInjector-BdjRfNx7.mjs} +5 -5
- package/dist/{ConsoleMonitor-CPVQW1Y-.mjs → ConsoleMonitor-DykL3IAw.mjs} +85 -17
- package/dist/{DetailedDataManager-BQQcxh64.mjs → DetailedDataManager-HT49OrvF.mjs} +1 -1
- package/dist/{ExtensionManager-CWYgw0YW.mjs → ExtensionManager-BDMsY2Dz.mjs} +15 -8
- package/dist/{HardwareBreakpoint-B9gZCdFP.mjs → HardwareBreakpoint-Cc2AFq1Y.mjs} +3 -3
- package/dist/{HeapAnalyzer-BLDH0dCv.mjs → HeapAnalyzer-DruMgsgj.mjs} +20 -20
- package/dist/{HookGeneratorBuilders.core.generators.storage-CtcdK78Q.mjs → HookGeneratorBuilders.core.generators.storage-CTbB4Lcx.mjs} +1 -74
- package/dist/{InstrumentationSession-CvPC7Jwy.mjs → InstrumentationSession-DLH0vd-z.mjs} +2 -2
- package/dist/{MemoryController-CbVdCIJF.mjs → MemoryController-CMtviNW_.mjs} +3 -3
- package/dist/{MemoryScanSession-BsDZbLYm.mjs → MemoryScanSession-ITgb_NMi.mjs} +2 -2
- package/dist/{MemoryScanner-Bcpml6II.mjs → MemoryScanner-CiL7Z3ey.mjs} +12 -9
- package/dist/{NativeMemoryManager.impl-dZtA1ZGn.mjs → NativeMemoryManager.impl-D9Lkovvn.mjs} +13 -10
- package/dist/{NativeMemoryManager.utils-B-FjA2mJ.mjs → NativeMemoryManager.utils-BBlAixF5.mjs} +1 -1
- package/dist/{PEAnalyzer-D1lzJ_VG.mjs → PEAnalyzer-DMQ44gen.mjs} +15 -15
- package/dist/{PageController-Bqm2kZ_X.mjs → PageController-BPJNqqBN.mjs} +18 -4
- package/dist/{PointerChainEngine-BOhyVsjx.mjs → PointerChainEngine-K7wN8Z-w.mjs} +10 -7
- package/dist/ProcessRegistry-zGg12QbE.mjs +74 -0
- package/dist/{ResponseBuilder-D3iFYx2N.mjs → ResponseBuilder-CJXWmWNw.mjs} +10 -10
- package/dist/{ScriptManager-aHHq0X7U.mjs → ScriptManager-ZuWD-0Jg.mjs} +195 -192
- package/dist/{Speedhack-CqdIFlQl.mjs → Speedhack-D-z0umeT.mjs} +2 -2
- package/dist/{StructureAnalyzer-DhFaPvRO.mjs → StructureAnalyzer-Cav5AVSL.mjs} +9 -6
- package/dist/{ToolCatalog-C0JGZoOm.mjs → ToolCatalog-5OJdMiF0.mjs} +81 -81
- package/dist/{ToolProbe-oC7aPrkv.mjs → ToolProbe-DbCFGyrg.mjs} +1 -1
- package/dist/{ToolRegistry-BjaF4oNz.mjs → ToolRegistry-B9krbTtI.mjs} +51 -2
- package/dist/{ToolRouter.policy-BWV67ZK-.mjs → ToolRouter.policy-BGDAGyeH.mjs} +60 -20
- package/dist/TraceRecorder-B41Z5XBj.mjs +1286 -0
- package/dist/{Win32API-CePkipZY.mjs → Win32API-C2kjj0ze.mjs} +18 -12
- package/dist/{Win32Debug-BvKs-gxc.mjs → Win32Debug-CKrGOTpo.mjs} +2 -2
- package/dist/{WorkflowEngine-CuvkZtWu.mjs → WorkflowEngine-DJ6M4opp.mjs} +226 -255
- package/dist/analysis-BHeJW2Nb.mjs +1234 -0
- package/dist/{antidebug-CqDTB_uk.mjs → antidebug-BRKeyt27.mjs} +3 -3
- package/dist/{artifactRetention-CFEprwPw.mjs → artifactRetention-CPXkUJXp.mjs} +13 -6
- package/dist/{artifacts-Bk2-_uPq.mjs → artifacts-DkfosXH3.mjs} +1 -1
- package/dist/authorization-schema-DRqyJMSk.mjs +31 -0
- package/dist/{binary-instrument-CXfpx6fT.mjs → binary-instrument--V3MAhJ4.mjs} +19 -27
- package/dist/bind-helpers-ClV34xdn.mjs +42 -0
- package/dist/{boringssl-inspector-BH2D3VKc.mjs → boringssl-inspector-Bo_LOLaS.mjs} +1 -1
- package/dist/{browser-BpOr5PEx.mjs → browser-Dx3_S2cG.mjs} +324 -37
- package/dist/capabilities-CcHlvWgK.mjs +33 -0
- package/dist/{constants-B0OANIBL.mjs → constants-CDZLOoVv.mjs} +18 -3
- package/dist/{coordination-qUbyF8KU.mjs → coordination-DgItD9DL.mjs} +2 -2
- package/dist/{debugger-gnKxRSN0.mjs → debugger-RS3RSAqs.mjs} +30 -13
- package/dist/definitions-BEoYofW5.mjs +47 -0
- package/dist/{definitions-bAhHQJq9.mjs → definitions-BRaefg3u.mjs} +11 -5
- package/dist/{definitions-DVGfrn7y.mjs → definitions-BbkvZkiv.mjs} +2 -2
- package/dist/definitions-BtWSHJ3o.mjs +17 -0
- package/dist/{definitions-BMfYXoNC.mjs → definitions-C1gCHO0i.mjs} +1 -1
- package/dist/{definitions-C1UvM5Iy.mjs → definitions-CDOg_b-l.mjs} +14 -2
- package/dist/definitions-CVPD9hzZ.mjs +54 -0
- package/dist/{definitions-Cke7zEb8.mjs → definitions-Cea8Lgl7.mjs} +1 -1
- package/dist/definitions-DAgIyjxM.mjs +10 -0
- package/dist/{definitions-B4rAvHNZ.mjs → definitions-DJA27nsL.mjs} +12 -9
- package/dist/{definitions-ClJLzsJQ.mjs → definitions-DKPFU3LW.mjs} +1 -1
- package/dist/{definitions-D3VsGcvz.mjs → definitions-DPRpZQ96.mjs} +7 -7
- package/dist/{definitions-B18eyf0B.mjs → definitions-DUE5gmdn.mjs} +1 -1
- package/dist/definitions-DYVjOtxa.mjs +26 -0
- package/dist/{definitions-BB_4jnmy.mjs → definitions-DcYLVLCo.mjs} +1 -1
- package/dist/{definitions-Beid2EB3.mjs → definitions-Pp5LI2H4.mjs} +1 -1
- package/dist/definitions-j9KdHVNR.mjs +14 -0
- package/dist/definitions-uzkjBwa7.mjs +258 -0
- package/dist/{definitions-Cq-zroAU.mjs → definitions-va-AnLuQ.mjs} +4 -4
- package/dist/{encoding-Bvz5jLRv.mjs → encoding-DJeqHmpd.mjs} +18 -4
- package/dist/{evidence-graph-bridge-C_fv9PuC.mjs → evidence-graph-bridge-DcYizFk2.mjs} +1 -0
- package/dist/{factory-DxlGh9Xf.mjs → factory-C90tBff6.mjs} +6 -6
- package/dist/flat-target-session-Dgax2Cy3.mjs +29 -0
- package/dist/{graphql-DYWzJ29s.mjs → graphql-CoHrhweh.mjs} +205 -34
- package/dist/{handlers-C67ktuRN.mjs → handlers-4jmR0nMs.mjs} +220 -32
- package/dist/{handlers-DlCJN4Td.mjs → handlers-BAHPxcch.mjs} +122 -90
- package/dist/{handlers-9sAbfIg-.mjs → handlers-BOs9b907.mjs} +849 -801
- package/dist/{handlers-DxGIq15_2.mjs → handlers-BWXEy6ef.mjs} +16 -16
- package/dist/{handlers-tB9Mp9ZK.mjs → handlers-Bndn6QvE.mjs} +31 -4
- package/dist/{handlers-CTsDAO6p.mjs → handlers-BqC4bD4s.mjs} +1 -1
- package/dist/{handlers-C87g8oCe.mjs → handlers-BtYq60bM2.mjs} +1 -1
- package/dist/{handlers-DeLOCd5m.mjs → handlers-BzgcB4iv.mjs} +17 -17
- package/dist/{handlers-Cgyg6c0U.mjs → handlers-CRyRWj2b.mjs} +237 -23
- package/dist/{handlers-U6L4xhuF.mjs → handlers-CVv2H1uq.mjs} +24 -17
- package/dist/{handlers-tiy7EIBp.mjs → handlers-Dl5a7JS4.mjs} +3 -3
- package/dist/{handlers-D6j6yka7.mjs → handlers-Dx2d7jt7.mjs} +1893 -1480
- package/dist/{handlers-Bl8zkwz1.mjs → handlers-Dz9PYsCa.mjs} +95 -6
- package/dist/handlers-HujRKC3b.mjs +661 -0
- package/dist/{handlers.impl-DS0d9fUw.mjs → handlers.impl-XWXkQfyi.mjs} +70 -24
- package/dist/{hooks-CzCWByww.mjs → hooks-B1B8NRHL.mjs} +3 -3
- package/dist/index.mjs +154 -144
- package/dist/{maintenance-P7ePRXQC.mjs → maintenance-PRMkLVRW.mjs} +35 -30
- package/dist/manifest-67Bok-Si.mjs +58 -0
- package/dist/{manifest-B3QVVeBS.mjs → manifest-6lNTMZAB2.mjs} +33 -28
- package/dist/manifest-B2duEHiH.mjs +90 -0
- package/dist/manifest-B6EY9Vm8.mjs +57 -0
- package/dist/{manifest-gZ4s_UtG.mjs → manifest-B6nKSbyY.mjs} +32 -33
- package/dist/{manifest-2ToTpjv8.mjs → manifest-BL8AQNPF.mjs} +31 -31
- package/dist/{manifest-DzwvxPJX.mjs → manifest-BSZvJJmV.mjs} +23 -14
- package/dist/{manifest-Sc_0JQ13.mjs → manifest-BU7qzUyX.mjs} +23 -23
- package/dist/{manifest-CT7zZBV1.mjs → manifest-Bl62e8WK.mjs} +24 -23
- package/dist/manifest-Bo5cXjdt.mjs +82 -0
- package/dist/manifest-BpS4gtUK.mjs +1347 -0
- package/dist/manifest-Bv65_e2W.mjs +101 -0
- package/dist/manifest-BytNIF4Z.mjs +117 -0
- package/dist/{manifest-BqrQ4Tpj.mjs → manifest-C-xtsjS3.mjs} +23 -23
- package/dist/{manifest-NXctwWQq.mjs → manifest-CDYl7OhA.mjs} +36 -38
- package/dist/manifest-CRZ3xmkD.mjs +61 -0
- package/dist/manifest-CoW6u4Tp.mjs +132 -0
- package/dist/manifest-Cq5zN_8A.mjs +50 -0
- package/dist/{manifest-CAhOuvSl.mjs → manifest-D7YZM_2e.mjs} +75 -85
- package/dist/{manifest-DCyjf4n2.mjs → manifest-DE_VrAeQ.mjs} +27 -7
- package/dist/manifest-DGsXSCpT.mjs +39 -0
- package/dist/{manifest-BB2J8IMJ.mjs → manifest-DJ2vfEuW.mjs} +48 -41
- package/dist/{manifest-3g71z6Bg.mjs → manifest-DPXDYhEu.mjs} +26 -25
- package/dist/manifest-Dd4fQb0a.mjs +322 -0
- package/dist/{manifest-CXsRWjjI.mjs → manifest-Deq6opGg.mjs} +95 -96
- package/dist/{manifest-C9RT5nk32.mjs → manifest-DfJTafJK.mjs} +14 -11
- package/dist/manifest-DgOdgN_j.mjs +50 -0
- package/dist/{manifest-BmtZzQiQ2.mjs → manifest-DlbMW4v4.mjs} +17 -15
- package/dist/{manifest-DrbmZcFl2.mjs → manifest-DmVfbH0w.mjs} +212 -91
- package/dist/manifest-Dog6Ddjr.mjs +109 -0
- package/dist/manifest-DvgU5FWb.mjs +58 -0
- package/dist/manifest-HsfDBs7j.mjs +50 -0
- package/dist/manifest-I8oQHvCG.mjs +186 -0
- package/dist/manifest-NvH_a-av.mjs +786 -0
- package/dist/{manifest-Dh8WBmEW.mjs → manifest-cEJU1v0Z.mjs} +24 -24
- package/dist/manifest-wOl5XLB12.mjs +112 -0
- package/dist/{modules-C184v-S9.mjs → modules-tZozf0LQ.mjs} +130 -860
- package/dist/{mojo-ipc-B_H61Afw.mjs → mojo-ipc-DXNEXEqb.mjs} +141 -26
- package/dist/{network-671Cw6hV.mjs → network-CPVvwvFg.mjs} +1329 -823
- package/dist/{outputPaths-B1uGmrWZ.mjs → outputPaths-um7lCRY3.mjs} +4 -8
- package/dist/{platform-WmNn8Sxb.mjs → platform-CYeFoTWp.mjs} +101 -10
- package/dist/{process-QcbIy5Zq.mjs → process-BTbgcVc6.mjs} +251 -346
- package/dist/{proxy-DqNs0bAd.mjs → proxy-r8YN6nP1.mjs} +30 -8
- package/dist/{registry-D-6e18lB.mjs → registry-Bl8ZQW61.mjs} +3 -3
- package/dist/{response-BQVP-xUn.mjs → response-CWhh2aLo.mjs} +7 -1
- package/dist/{shared-state-board-DV-dpHFJ.mjs → shared-state-board-BoZnSoj-.mjs} +2 -2
- package/dist/{sourcemap-Dq8ez8vS.mjs → sourcemap-BIDHUVXy.mjs} +350 -66
- package/dist/{streaming-BUQ0VJsg.mjs → streaming-Dal6utPp.mjs} +13 -13
- package/dist/{tool-builder-DCbIC5Eo.mjs → tool-builder-BHJp32mV.mjs} +1 -1
- package/dist/{transform-CiYJfNX0.mjs → transform-DRVgGG90.mjs} +18 -14
- package/dist/wasm-BYx5UOeG.mjs +1044 -0
- package/dist/webcrack-Be0_FccV.mjs +747 -0
- package/dist/{workflow-f3xJOcjx.mjs → workflow-BpuKEtvn.mjs} +8 -8
- package/package.json +76 -43
- package/dist/TraceRecorder-DgxyVbdQ.mjs +0 -519
- package/dist/analysis-CL9uACt9.mjs +0 -463
- package/dist/bind-helpers-xFfRF-qm.mjs +0 -22
- package/dist/definitions-6M-eejaT.mjs +0 -53
- package/dist/definitions-B3QdlrHv.mjs +0 -34
- package/dist/definitions-CXEI7QC72.mjs +0 -216
- package/dist/definitions-C_4r7Fo-2.mjs +0 -14
- package/dist/definitions-CkFDALoa.mjs +0 -26
- package/dist/definitions-Cy3Sl6gV.mjs +0 -34
- package/dist/definitions-LKpC3-nL.mjs +0 -9
- package/dist/handlers-DdFzXLvF.mjs +0 -446
- package/dist/manifest-82baTv4U.mjs +0 -45
- package/dist/manifest-BKbgbSiY.mjs +0 -60
- package/dist/manifest-Bcf-TJzH.mjs +0 -848
- package/dist/manifest-Bnd7kqEY.mjs +0 -55
- package/dist/manifest-BqQX6OQC2.mjs +0 -65
- package/dist/manifest-Br4RPFt5.mjs +0 -370
- package/dist/manifest-C5qDjysN.mjs +0 -107
- package/dist/manifest-CBYWCUBJ.mjs +0 -51
- package/dist/manifest-CFADCRa1.mjs +0 -37
- package/dist/manifest-CQVhavRF.mjs +0 -114
- package/dist/manifest-CV12bcrF.mjs +0 -121
- package/dist/manifest-CZLUCfG02.mjs +0 -95
- package/dist/manifest-D6phHKFd.mjs +0 -131
- package/dist/manifest-DHsnKgP6.mjs +0 -60
- package/dist/manifest-Df_dliIe.mjs +0 -55
- package/dist/manifest-DhKRAT8_.mjs +0 -92
- package/dist/manifest-DlpTj4ic2.mjs +0 -193
- package/dist/manifest-DuwHjUa5.mjs +0 -70
- package/dist/manifest-qSleDqdO.mjs +0 -1023
- package/dist/wasm-DQTnHDs4.mjs +0 -531
- /package/dist/{CacheAdapters-CDe5WPSV.mjs → CacheAdapters-jJFy20G-.mjs} +0 -0
- /package/dist/{DarwinAPI-BNPxu0RH.mjs → DarwinAPI-ETyy0xyo.mjs} +0 -0
- /package/dist/{EventBus-DgPmwpeu.mjs → EventBus-DFKvADm3.mjs} +0 -0
- /package/dist/{EvidenceGraphBridge-SFesNera.mjs → EvidenceGraphBridge-318Oi0Lf.mjs} +0 -0
- /package/dist/{FingerprintManager-gzWtkKuf.mjs → FingerprintManager-BN4UQWnX.mjs} +0 -0
- /package/dist/{PrerequisiteError-Dl33Svkz.mjs → PrerequisiteError-TuyZIs6n.mjs} +0 -0
- /package/dist/{ReverseEvidenceGraph-Dlsk94LC.mjs → ReverseEvidenceGraph-C02-gXOh.mjs} +0 -0
- /package/dist/{StealthVerifier-Bo4T3bz8.mjs → StealthVerifier-BWmPgQsv.mjs} +0 -0
- /package/dist/{VersionDetector-CwVLVdDM.mjs → VersionDetector-K3V4vGsw.mjs} +0 -0
- /package/dist/{betterSqlite3-0pqusHHH.mjs → betterSqlite3-DLSBZodi.mjs} +0 -0
- /package/dist/{concurrency-Bt0yv1kJ.mjs → concurrency-Drev_Vz9.mjs} +0 -0
- /package/dist/{formatAddress-DVkj9kpI.mjs → formatAddress-nnMvEohD.mjs} +0 -0
- /package/dist/{parse-args-BlRjqlkL.mjs → parse-args-B4cY5Vx5.mjs} +0 -0
- /package/dist/{ssrf-policy-ZaUfvhq7.mjs → ssrf-policy-Dsqd-DTX.mjs} +0 -0
- /package/dist/{types-CPhOReNX.mjs → types-DDBWs9UP.mjs} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { t as logger } from "./logger-Dh_xb7_2.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { i as MemoryManager, r as UnifiedProcessManager } from "./modules-
|
|
4
|
-
import { o as argStringArray, r as argNumber } from "./parse-args-
|
|
5
|
-
import { i as connectPlaywrightCdpFallback } from "./ScriptManager-
|
|
6
|
-
import "./definitions-
|
|
2
|
+
import { H as ENABLE_INJECTION_TOOLS, Tt as MEMORY_AUDIT_TRAIL_CAPACITY } from "./constants-CDZLOoVv.mjs";
|
|
3
|
+
import { i as MemoryManager, r as UnifiedProcessManager } from "./modules-tZozf0LQ.mjs";
|
|
4
|
+
import { o as argStringArray, r as argNumber } from "./parse-args-B4cY5Vx5.mjs";
|
|
5
|
+
import { i as connectPlaywrightCdpFallback } from "./ScriptManager-ZuWD-0Jg.mjs";
|
|
6
|
+
import "./definitions-DJA27nsL.mjs";
|
|
7
7
|
//#region src/modules/process/memory/AuditTrail.ts
|
|
8
8
|
var MemoryAuditTrail = class {
|
|
9
9
|
buffer;
|
|
@@ -174,6 +174,15 @@ var ProcessManagementHandlers = class {
|
|
|
174
174
|
get platformValue() {
|
|
175
175
|
return this.platform;
|
|
176
176
|
}
|
|
177
|
+
exportMemoryAuditEntries() {
|
|
178
|
+
return JSON.parse(this.auditTrail.exportJson());
|
|
179
|
+
}
|
|
180
|
+
clearMemoryAuditEntries() {
|
|
181
|
+
this.auditTrail.clear();
|
|
182
|
+
}
|
|
183
|
+
getMemoryAuditCount() {
|
|
184
|
+
return this.auditTrail.size();
|
|
185
|
+
}
|
|
177
186
|
async handleProcessList(_args) {
|
|
178
187
|
try {
|
|
179
188
|
const processes = await this.processManager.findProcesses("");
|
|
@@ -444,11 +453,11 @@ var ProcessManagementHandlers = class {
|
|
|
444
453
|
var MemoryOperationHandlers = class {
|
|
445
454
|
memoryManager;
|
|
446
455
|
platform;
|
|
447
|
-
|
|
448
|
-
constructor(deps,
|
|
456
|
+
host;
|
|
457
|
+
constructor(deps, host) {
|
|
449
458
|
this.memoryManager = deps.memoryManager;
|
|
450
459
|
this.platform = deps.platform;
|
|
451
|
-
this.
|
|
460
|
+
this.host = host;
|
|
452
461
|
}
|
|
453
462
|
async handleMemoryRead(args) {
|
|
454
463
|
const startedAt = Date.now();
|
|
@@ -457,68 +466,46 @@ var MemoryOperationHandlers = class {
|
|
|
457
466
|
const address = requireString(args.address, "address");
|
|
458
467
|
const size = requirePositiveNumber(args.size, "size");
|
|
459
468
|
const availability = await this.memoryManager.checkAvailability();
|
|
460
|
-
if (!availability.available) return
|
|
461
|
-
const result = await this.memoryManager.readMemory(pid, address, size);
|
|
462
|
-
const diagnostics = !result.success ? await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
463
|
-
pid,
|
|
464
|
-
address,
|
|
465
|
-
size,
|
|
466
|
-
operation: "memory_read",
|
|
467
|
-
error: result.error
|
|
468
|
-
}) : void 0;
|
|
469
|
-
this.processMgmt.recordMemoryAudit({
|
|
469
|
+
if (!availability.available) return this.auditedUnavailableResponse({
|
|
470
470
|
operation: "memory_read",
|
|
471
471
|
pid,
|
|
472
472
|
address,
|
|
473
473
|
size,
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
474
|
+
startedAt,
|
|
475
|
+
reason: availability.reason,
|
|
476
|
+
extra: {
|
|
477
|
+
requestedAddress: address,
|
|
478
|
+
requestedSize: size
|
|
479
|
+
}
|
|
477
480
|
});
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
error: result.error,
|
|
481
|
+
const result = await this.memoryManager.readMemory(pid, address, size);
|
|
482
|
+
return this.auditedResultResponse({
|
|
483
|
+
operation: "memory_read",
|
|
482
484
|
pid,
|
|
483
485
|
address,
|
|
484
486
|
size,
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
487
|
+
startedAt,
|
|
488
|
+
result,
|
|
489
|
+
payload: {
|
|
490
|
+
success: result.success,
|
|
491
|
+
data: result.data,
|
|
492
|
+
error: result.error,
|
|
493
|
+
pid,
|
|
494
|
+
address,
|
|
495
|
+
size,
|
|
496
|
+
platform: this.platform
|
|
497
|
+
}
|
|
498
|
+
});
|
|
492
499
|
} catch (error) {
|
|
493
500
|
logger.error("Memory read failed:", error);
|
|
494
|
-
|
|
495
|
-
const pid = getOptionalPid$1(args.pid);
|
|
496
|
-
const address = getOptionalString$1(args.address);
|
|
497
|
-
const size = getOptionalPositiveNumber(args.size);
|
|
498
|
-
const diagnostics = await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
499
|
-
pid,
|
|
500
|
-
address,
|
|
501
|
-
size,
|
|
502
|
-
operation: "memory_read",
|
|
503
|
-
error: errorMessage
|
|
504
|
-
});
|
|
505
|
-
this.processMgmt.recordMemoryAudit({
|
|
501
|
+
return this.auditedExceptionResponse({
|
|
506
502
|
operation: "memory_read",
|
|
507
|
-
pid: pid ?? null,
|
|
508
|
-
address: address ?? null,
|
|
509
|
-
size: size ?? null,
|
|
510
|
-
|
|
511
|
-
error
|
|
512
|
-
durationMs: Date.now() - startedAt
|
|
503
|
+
pid: getOptionalPid$1(args.pid) ?? null,
|
|
504
|
+
address: getOptionalString$1(args.address) ?? null,
|
|
505
|
+
size: getOptionalPositiveNumber(args.size) ?? null,
|
|
506
|
+
startedAt,
|
|
507
|
+
error
|
|
513
508
|
});
|
|
514
|
-
return { content: [{
|
|
515
|
-
type: "text",
|
|
516
|
-
text: JSON.stringify({
|
|
517
|
-
success: false,
|
|
518
|
-
error: errorMessage,
|
|
519
|
-
diagnostics
|
|
520
|
-
}, null, 2)
|
|
521
|
-
}] };
|
|
522
509
|
}
|
|
523
510
|
}
|
|
524
511
|
async handleMemoryWrite(args) {
|
|
@@ -527,106 +514,53 @@ var MemoryOperationHandlers = class {
|
|
|
527
514
|
const pid = validatePid(args.pid);
|
|
528
515
|
const address = requireString(args.address, "address");
|
|
529
516
|
const data = requireString(args.data, "data");
|
|
530
|
-
const encoding = args.encoding
|
|
517
|
+
const encoding = this.normalizeEncoding(args.encoding, "encoding") ?? "hex";
|
|
531
518
|
const size = getWriteSize(data, encoding);
|
|
532
519
|
const availability = await this.memoryManager.checkAvailability();
|
|
533
|
-
if (!availability.available) {
|
|
534
|
-
|
|
535
|
-
const diagnostics = await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
536
|
-
pid,
|
|
537
|
-
address,
|
|
538
|
-
size,
|
|
539
|
-
operation: "memory_write",
|
|
540
|
-
error: errorMessage
|
|
541
|
-
});
|
|
542
|
-
this.processMgmt.recordMemoryAudit({
|
|
543
|
-
operation: "memory_write",
|
|
544
|
-
pid,
|
|
545
|
-
address,
|
|
546
|
-
size,
|
|
547
|
-
result: "failure",
|
|
548
|
-
error: errorMessage,
|
|
549
|
-
durationMs: Date.now() - startedAt
|
|
550
|
-
});
|
|
551
|
-
return { content: [{
|
|
552
|
-
type: "text",
|
|
553
|
-
text: JSON.stringify({
|
|
554
|
-
success: false,
|
|
555
|
-
message: "Memory operations not available",
|
|
556
|
-
reason: availability.reason,
|
|
557
|
-
platform: this.platform,
|
|
558
|
-
requestedAddress: address,
|
|
559
|
-
dataLength: data !== void 0 && data !== null ? data.length : 0,
|
|
560
|
-
encoding,
|
|
561
|
-
pid,
|
|
562
|
-
diagnostics
|
|
563
|
-
}, null, 2)
|
|
564
|
-
}] };
|
|
565
|
-
}
|
|
566
|
-
const result = await this.memoryManager.writeMemory(pid, address, data, encoding);
|
|
567
|
-
const diagnostics = !result.success ? await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
520
|
+
if (!availability.available) return this.auditedUnavailableResponse({
|
|
521
|
+
operation: "memory_write",
|
|
568
522
|
pid,
|
|
569
523
|
address,
|
|
570
524
|
size,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
525
|
+
startedAt,
|
|
526
|
+
reason: availability.reason,
|
|
527
|
+
extra: {
|
|
528
|
+
requestedAddress: address,
|
|
529
|
+
dataLength: data.length,
|
|
530
|
+
encoding
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
const result = await this.memoryManager.writeMemory(pid, address, data, encoding);
|
|
534
|
+
return this.auditedResultResponse({
|
|
575
535
|
operation: "memory_write",
|
|
576
536
|
pid,
|
|
577
537
|
address,
|
|
578
538
|
size,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
539
|
+
startedAt,
|
|
540
|
+
result,
|
|
541
|
+
payload: {
|
|
542
|
+
success: result.success,
|
|
543
|
+
bytesWritten: result.bytesWritten,
|
|
544
|
+
error: result.error,
|
|
545
|
+
pid,
|
|
546
|
+
address,
|
|
547
|
+
dataLength: data.length,
|
|
548
|
+
encoding,
|
|
549
|
+
platform: this.platform
|
|
550
|
+
}
|
|
582
551
|
});
|
|
583
|
-
const payload = {
|
|
584
|
-
success: result.success,
|
|
585
|
-
bytesWritten: result.bytesWritten,
|
|
586
|
-
error: result.error,
|
|
587
|
-
pid,
|
|
588
|
-
address,
|
|
589
|
-
dataLength: data.length,
|
|
590
|
-
encoding,
|
|
591
|
-
platform: this.platform
|
|
592
|
-
};
|
|
593
|
-
if (!result.success) payload.diagnostics = diagnostics;
|
|
594
|
-
return { content: [{
|
|
595
|
-
type: "text",
|
|
596
|
-
text: JSON.stringify(payload, null, 2)
|
|
597
|
-
}] };
|
|
598
552
|
} catch (error) {
|
|
599
553
|
logger.error("Memory write failed:", error);
|
|
600
|
-
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
601
|
-
const pid = getOptionalPid$1(args.pid);
|
|
602
|
-
const address = getOptionalString$1(args.address);
|
|
603
554
|
const data = getOptionalString$1(args.data);
|
|
604
|
-
const encoding = args.encoding
|
|
605
|
-
|
|
606
|
-
const diagnostics = await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
607
|
-
pid,
|
|
608
|
-
address,
|
|
609
|
-
size,
|
|
555
|
+
const encoding = this.normalizeEncoding(args.encoding, "encoding") ?? "hex";
|
|
556
|
+
return this.auditedExceptionResponse({
|
|
610
557
|
operation: "memory_write",
|
|
611
|
-
|
|
558
|
+
pid: getOptionalPid$1(args.pid) ?? null,
|
|
559
|
+
address: getOptionalString$1(args.address) ?? null,
|
|
560
|
+
size: data ? getWriteSize(data, encoding) : null,
|
|
561
|
+
startedAt,
|
|
562
|
+
error
|
|
612
563
|
});
|
|
613
|
-
this.processMgmt.recordMemoryAudit({
|
|
614
|
-
operation: "memory_write",
|
|
615
|
-
pid: pid ?? null,
|
|
616
|
-
address: address ?? null,
|
|
617
|
-
size: size ?? null,
|
|
618
|
-
result: "failure",
|
|
619
|
-
error: errorMessage,
|
|
620
|
-
durationMs: Date.now() - startedAt
|
|
621
|
-
});
|
|
622
|
-
return { content: [{
|
|
623
|
-
type: "text",
|
|
624
|
-
text: JSON.stringify({
|
|
625
|
-
success: false,
|
|
626
|
-
error: errorMessage,
|
|
627
|
-
diagnostics
|
|
628
|
-
}, null, 2)
|
|
629
|
-
}] };
|
|
630
564
|
}
|
|
631
565
|
}
|
|
632
566
|
async handleMemoryScan(args) {
|
|
@@ -637,118 +571,63 @@ var MemoryOperationHandlers = class {
|
|
|
637
571
|
const patternType = normalizePatternType(args.patternType);
|
|
638
572
|
const suspendTarget = args.suspendTarget === true;
|
|
639
573
|
const availability = await this.memoryManager.checkAvailability();
|
|
640
|
-
if (!availability.available) {
|
|
641
|
-
const errorMessage = availability.reason ?? "Memory operations not available";
|
|
642
|
-
const diagnostics = await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
643
|
-
pid,
|
|
644
|
-
operation: "memory_scan",
|
|
645
|
-
error: errorMessage
|
|
646
|
-
});
|
|
647
|
-
this.processMgmt.recordMemoryAudit({
|
|
648
|
-
operation: "memory_scan",
|
|
649
|
-
pid,
|
|
650
|
-
address: null,
|
|
651
|
-
size: null,
|
|
652
|
-
result: "failure",
|
|
653
|
-
error: errorMessage,
|
|
654
|
-
durationMs: Date.now() - startedAt
|
|
655
|
-
});
|
|
656
|
-
return { content: [{
|
|
657
|
-
type: "text",
|
|
658
|
-
text: JSON.stringify({
|
|
659
|
-
success: false,
|
|
660
|
-
message: "Memory operations not available",
|
|
661
|
-
reason: availability.reason,
|
|
662
|
-
platform: this.platform,
|
|
663
|
-
requestedPattern: pattern,
|
|
664
|
-
patternType,
|
|
665
|
-
pid,
|
|
666
|
-
diagnostics
|
|
667
|
-
}, null, 2)
|
|
668
|
-
}] };
|
|
669
|
-
}
|
|
670
|
-
const result = await this.memoryManager.scanMemory(pid, pattern, patternType, suspendTarget);
|
|
671
|
-
const diagnostics = !result.success ? await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
672
|
-
pid,
|
|
673
|
-
operation: "memory_scan",
|
|
674
|
-
error: result.error
|
|
675
|
-
}) : void 0;
|
|
676
|
-
this.processMgmt.recordMemoryAudit({
|
|
574
|
+
if (!availability.available) return this.auditedUnavailableResponse({
|
|
677
575
|
operation: "memory_scan",
|
|
678
576
|
pid,
|
|
679
577
|
address: null,
|
|
680
578
|
size: null,
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
579
|
+
startedAt,
|
|
580
|
+
reason: availability.reason,
|
|
581
|
+
extra: {
|
|
582
|
+
requestedPattern: pattern,
|
|
583
|
+
patternType
|
|
584
|
+
}
|
|
684
585
|
});
|
|
685
|
-
const
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
error: result.error,
|
|
586
|
+
const result = await this.memoryManager.scanMemory(pid, pattern, patternType, suspendTarget);
|
|
587
|
+
return this.auditedResultResponse({
|
|
588
|
+
operation: "memory_scan",
|
|
689
589
|
pid,
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
590
|
+
address: null,
|
|
591
|
+
size: null,
|
|
592
|
+
startedAt,
|
|
593
|
+
result,
|
|
594
|
+
payload: {
|
|
595
|
+
success: result.success,
|
|
596
|
+
addresses: result.addresses,
|
|
597
|
+
error: result.error,
|
|
598
|
+
pid,
|
|
599
|
+
pattern,
|
|
600
|
+
patternType,
|
|
601
|
+
platform: this.platform
|
|
602
|
+
}
|
|
603
|
+
});
|
|
699
604
|
} catch (error) {
|
|
700
605
|
logger.error("Memory scan failed:", error);
|
|
701
|
-
|
|
702
|
-
const pid = getOptionalPid$1(args.pid);
|
|
703
|
-
const diagnostics = await this.processMgmt.safeBuildMemoryDiagnostics({
|
|
704
|
-
pid,
|
|
606
|
+
return this.auditedExceptionResponse({
|
|
705
607
|
operation: "memory_scan",
|
|
706
|
-
|
|
707
|
-
});
|
|
708
|
-
this.processMgmt.recordMemoryAudit({
|
|
709
|
-
operation: "memory_scan",
|
|
710
|
-
pid: pid ?? null,
|
|
608
|
+
pid: getOptionalPid$1(args.pid) ?? null,
|
|
711
609
|
address: null,
|
|
712
610
|
size: null,
|
|
713
|
-
|
|
714
|
-
error
|
|
715
|
-
durationMs: Date.now() - startedAt
|
|
611
|
+
startedAt,
|
|
612
|
+
error
|
|
716
613
|
});
|
|
717
|
-
return { content: [{
|
|
718
|
-
type: "text",
|
|
719
|
-
text: JSON.stringify({
|
|
720
|
-
success: false,
|
|
721
|
-
error: errorMessage,
|
|
722
|
-
diagnostics
|
|
723
|
-
}, null, 2)
|
|
724
|
-
}] };
|
|
725
614
|
}
|
|
726
615
|
}
|
|
727
616
|
async handleMemoryAuditExport(args) {
|
|
728
617
|
try {
|
|
729
|
-
const
|
|
730
|
-
const entries = JSON.parse(exportedJson);
|
|
618
|
+
const entries = this.host.exportMemoryAuditEntries();
|
|
731
619
|
const clear = args.clear === true;
|
|
732
|
-
const count = this.
|
|
733
|
-
if (clear) this.
|
|
734
|
-
return {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
entries
|
|
741
|
-
}, null, 2)
|
|
742
|
-
}] };
|
|
620
|
+
const count = this.host.getMemoryAuditCount();
|
|
621
|
+
if (clear) this.host.clearMemoryAuditEntries();
|
|
622
|
+
return this.jsonResponse({
|
|
623
|
+
success: true,
|
|
624
|
+
count,
|
|
625
|
+
cleared: clear,
|
|
626
|
+
entries
|
|
627
|
+
});
|
|
743
628
|
} catch (error) {
|
|
744
629
|
logger.error("Memory audit export failed:", error);
|
|
745
|
-
return
|
|
746
|
-
type: "text",
|
|
747
|
-
text: JSON.stringify({
|
|
748
|
-
success: false,
|
|
749
|
-
error: error instanceof Error ? error.message : String(error)
|
|
750
|
-
}, null, 2)
|
|
751
|
-
}] };
|
|
630
|
+
return this.errorResponse(error);
|
|
752
631
|
}
|
|
753
632
|
}
|
|
754
633
|
async handleMemoryCheckProtection(args) {
|
|
@@ -756,83 +635,38 @@ var MemoryOperationHandlers = class {
|
|
|
756
635
|
const pid = validatePid(args.pid);
|
|
757
636
|
const address = requireString(args.address, "address");
|
|
758
637
|
const result = await this.memoryManager.checkMemoryProtection(pid, address);
|
|
759
|
-
return
|
|
760
|
-
type: "text",
|
|
761
|
-
text: JSON.stringify(result, null, 2)
|
|
762
|
-
}] };
|
|
638
|
+
return this.jsonResponse(result);
|
|
763
639
|
} catch (error) {
|
|
764
640
|
logger.error("Memory check protection failed:", error);
|
|
765
|
-
return
|
|
766
|
-
type: "text",
|
|
767
|
-
text: JSON.stringify({
|
|
768
|
-
success: false,
|
|
769
|
-
error: error instanceof Error ? error.message : String(error)
|
|
770
|
-
}, null, 2)
|
|
771
|
-
}] };
|
|
641
|
+
return this.errorResponse(error);
|
|
772
642
|
}
|
|
773
643
|
}
|
|
774
644
|
async handleMemoryScanFiltered(args) {
|
|
775
645
|
try {
|
|
776
646
|
const pid = validatePid(args.pid);
|
|
777
647
|
const pattern = requireString(args.pattern, "pattern");
|
|
778
|
-
const addresses = args.addresses;
|
|
648
|
+
const addresses = this.requireStringArray(args.addresses, "addresses");
|
|
779
649
|
const patternType = normalizePatternType(args.patternType);
|
|
780
650
|
const availability = await this.memoryManager.checkAvailability();
|
|
781
|
-
if (!availability.available) return
|
|
782
|
-
type: "text",
|
|
783
|
-
text: JSON.stringify({
|
|
784
|
-
success: false,
|
|
785
|
-
message: "Memory operations not available",
|
|
786
|
-
reason: availability.reason,
|
|
787
|
-
platform: this.platform,
|
|
788
|
-
pid
|
|
789
|
-
}, null, 2)
|
|
790
|
-
}] };
|
|
651
|
+
if (!availability.available) return this.unavailableResponse(pid, availability.reason);
|
|
791
652
|
const result = await this.memoryManager.scanMemoryFiltered(pid, pattern, addresses, patternType);
|
|
792
|
-
return
|
|
793
|
-
type: "text",
|
|
794
|
-
text: JSON.stringify(result, null, 2)
|
|
795
|
-
}] };
|
|
653
|
+
return this.jsonResponse(result);
|
|
796
654
|
} catch (error) {
|
|
797
655
|
logger.error("Memory scan filtered failed:", error);
|
|
798
|
-
return
|
|
799
|
-
type: "text",
|
|
800
|
-
text: JSON.stringify({
|
|
801
|
-
success: false,
|
|
802
|
-
error: error instanceof Error ? error.message : String(error)
|
|
803
|
-
}, null, 2)
|
|
804
|
-
}] };
|
|
656
|
+
return this.errorResponse(error);
|
|
805
657
|
}
|
|
806
658
|
}
|
|
807
659
|
async handleMemoryBatchWrite(args) {
|
|
808
660
|
try {
|
|
809
661
|
const pid = validatePid(args.pid);
|
|
810
|
-
const patches = args.patches;
|
|
662
|
+
const patches = this.requirePatches(args.patches);
|
|
811
663
|
const availability = await this.memoryManager.checkAvailability();
|
|
812
|
-
if (!availability.available) return
|
|
813
|
-
type: "text",
|
|
814
|
-
text: JSON.stringify({
|
|
815
|
-
success: false,
|
|
816
|
-
message: "Memory operations not available",
|
|
817
|
-
reason: availability.reason,
|
|
818
|
-
platform: this.platform,
|
|
819
|
-
pid
|
|
820
|
-
}, null, 2)
|
|
821
|
-
}] };
|
|
664
|
+
if (!availability.available) return this.unavailableResponse(pid, availability.reason);
|
|
822
665
|
const result = await this.memoryManager.batchMemoryWrite(pid, patches);
|
|
823
|
-
return
|
|
824
|
-
type: "text",
|
|
825
|
-
text: JSON.stringify(result, null, 2)
|
|
826
|
-
}] };
|
|
666
|
+
return this.jsonResponse(result);
|
|
827
667
|
} catch (error) {
|
|
828
668
|
logger.error("Memory batch write failed:", error);
|
|
829
|
-
return
|
|
830
|
-
type: "text",
|
|
831
|
-
text: JSON.stringify({
|
|
832
|
-
success: false,
|
|
833
|
-
error: error instanceof Error ? error.message : String(error)
|
|
834
|
-
}, null, 2)
|
|
835
|
-
}] };
|
|
669
|
+
return this.errorResponse(error);
|
|
836
670
|
}
|
|
837
671
|
}
|
|
838
672
|
async handleMemoryDumpRegion(args) {
|
|
@@ -841,73 +675,144 @@ var MemoryOperationHandlers = class {
|
|
|
841
675
|
const address = requireString(args.address, "address");
|
|
842
676
|
const size = requirePositiveNumber(args.size, "size");
|
|
843
677
|
const outputPath = requireString(args.outputPath, "outputPath");
|
|
844
|
-
|
|
678
|
+
this.ensureRelativeOutputPath(outputPath);
|
|
845
679
|
const result = await this.memoryManager.dumpMemoryRegion(pid, address, size, outputPath);
|
|
846
|
-
return
|
|
847
|
-
type: "text",
|
|
848
|
-
text: JSON.stringify(result, null, 2)
|
|
849
|
-
}] };
|
|
680
|
+
return this.jsonResponse(result);
|
|
850
681
|
} catch (error) {
|
|
851
682
|
logger.error("Memory dump region failed:", error);
|
|
852
|
-
return
|
|
853
|
-
type: "text",
|
|
854
|
-
text: JSON.stringify({
|
|
855
|
-
success: false,
|
|
856
|
-
error: error instanceof Error ? error.message : String(error)
|
|
857
|
-
}, null, 2)
|
|
858
|
-
}] };
|
|
683
|
+
return this.errorResponse(error);
|
|
859
684
|
}
|
|
860
685
|
}
|
|
861
686
|
async handleMemoryListRegions(args) {
|
|
862
687
|
try {
|
|
863
688
|
const pid = validatePid(args.pid);
|
|
864
689
|
const result = await this.memoryManager.enumerateRegions(pid);
|
|
865
|
-
return
|
|
866
|
-
type: "text",
|
|
867
|
-
text: JSON.stringify(result, null, 2)
|
|
868
|
-
}] };
|
|
690
|
+
return this.jsonResponse(result);
|
|
869
691
|
} catch (error) {
|
|
870
692
|
logger.error("Memory list regions failed:", error);
|
|
871
|
-
return
|
|
872
|
-
type: "text",
|
|
873
|
-
text: JSON.stringify({
|
|
874
|
-
success: false,
|
|
875
|
-
error: error instanceof Error ? error.message : String(error)
|
|
876
|
-
}, null, 2)
|
|
877
|
-
}] };
|
|
693
|
+
return this.errorResponse(error);
|
|
878
694
|
}
|
|
879
695
|
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
696
|
+
jsonResponse(payload) {
|
|
697
|
+
return { content: [{
|
|
698
|
+
type: "text",
|
|
699
|
+
text: JSON.stringify(payload, null, 2)
|
|
700
|
+
}] };
|
|
701
|
+
}
|
|
702
|
+
errorResponse(error) {
|
|
703
|
+
return this.jsonResponse({
|
|
704
|
+
success: false,
|
|
705
|
+
error: this.errorMessage(error)
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
errorMessage(error) {
|
|
709
|
+
return error instanceof Error ? error.message : String(error);
|
|
710
|
+
}
|
|
711
|
+
async auditedUnavailableResponse(params) {
|
|
712
|
+
const errorMessage = params.reason ?? "Memory operations not available";
|
|
713
|
+
const diagnostics = await this.host.safeBuildMemoryDiagnostics({
|
|
714
|
+
pid: params.pid,
|
|
715
|
+
address: params.address ?? void 0,
|
|
716
|
+
size: params.size ?? void 0,
|
|
717
|
+
operation: params.operation,
|
|
887
718
|
error: errorMessage
|
|
888
719
|
});
|
|
889
|
-
this.
|
|
890
|
-
operation,
|
|
891
|
-
pid,
|
|
892
|
-
address,
|
|
893
|
-
size,
|
|
720
|
+
this.host.recordMemoryAudit({
|
|
721
|
+
operation: params.operation,
|
|
722
|
+
pid: params.pid,
|
|
723
|
+
address: params.address,
|
|
724
|
+
size: params.size,
|
|
894
725
|
result: "failure",
|
|
895
726
|
error: errorMessage,
|
|
896
|
-
durationMs: Date.now() - startedAt
|
|
727
|
+
durationMs: Date.now() - params.startedAt
|
|
897
728
|
});
|
|
898
|
-
return {
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
729
|
+
return this.jsonResponse({
|
|
730
|
+
success: false,
|
|
731
|
+
message: "Memory operations not available",
|
|
732
|
+
reason: params.reason,
|
|
733
|
+
platform: this.platform,
|
|
734
|
+
pid: params.pid,
|
|
735
|
+
...params.extra,
|
|
736
|
+
diagnostics
|
|
737
|
+
});
|
|
738
|
+
}
|
|
739
|
+
async auditedResultResponse(params) {
|
|
740
|
+
const diagnostics = !params.result.success ? await this.host.safeBuildMemoryDiagnostics({
|
|
741
|
+
pid: params.pid,
|
|
742
|
+
address: params.address ?? void 0,
|
|
743
|
+
size: params.size ?? void 0,
|
|
744
|
+
operation: params.operation,
|
|
745
|
+
error: params.result.error
|
|
746
|
+
}) : void 0;
|
|
747
|
+
this.host.recordMemoryAudit({
|
|
748
|
+
operation: params.operation,
|
|
749
|
+
pid: params.pid,
|
|
750
|
+
address: params.address,
|
|
751
|
+
size: params.size,
|
|
752
|
+
result: params.result.success ? "success" : "failure",
|
|
753
|
+
error: params.result.error,
|
|
754
|
+
durationMs: Date.now() - params.startedAt
|
|
755
|
+
});
|
|
756
|
+
if (!params.result.success) params.payload.diagnostics = diagnostics;
|
|
757
|
+
return this.jsonResponse(params.payload);
|
|
758
|
+
}
|
|
759
|
+
async auditedExceptionResponse(params) {
|
|
760
|
+
const errorMessage = this.errorMessage(params.error);
|
|
761
|
+
const diagnostics = await this.host.safeBuildMemoryDiagnostics({
|
|
762
|
+
pid: params.pid ?? void 0,
|
|
763
|
+
address: params.address ?? void 0,
|
|
764
|
+
size: params.size ?? void 0,
|
|
765
|
+
operation: params.operation,
|
|
766
|
+
error: errorMessage
|
|
767
|
+
});
|
|
768
|
+
this.host.recordMemoryAudit({
|
|
769
|
+
operation: params.operation,
|
|
770
|
+
pid: params.pid,
|
|
771
|
+
address: params.address,
|
|
772
|
+
size: params.size,
|
|
773
|
+
result: "failure",
|
|
774
|
+
error: errorMessage,
|
|
775
|
+
durationMs: Date.now() - params.startedAt
|
|
776
|
+
});
|
|
777
|
+
return this.jsonResponse({
|
|
778
|
+
success: false,
|
|
779
|
+
error: errorMessage,
|
|
780
|
+
diagnostics
|
|
781
|
+
});
|
|
782
|
+
}
|
|
783
|
+
unavailableResponse(pid, reason) {
|
|
784
|
+
return this.jsonResponse({
|
|
785
|
+
success: false,
|
|
786
|
+
message: "Memory operations not available",
|
|
787
|
+
reason,
|
|
788
|
+
platform: this.platform,
|
|
789
|
+
pid
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
requireStringArray(value, fieldName) {
|
|
793
|
+
if (!Array.isArray(value)) throw new Error(`${fieldName} must be an array of strings`);
|
|
794
|
+
return value.map((entry, index) => requireString(entry, `${fieldName}[${index}]`));
|
|
795
|
+
}
|
|
796
|
+
requirePatches(value) {
|
|
797
|
+
if (!Array.isArray(value)) throw new Error("patches must be an array");
|
|
798
|
+
return value.map((entry, index) => {
|
|
799
|
+
if (entry === null || typeof entry !== "object") throw new Error(`patches[${index}] must be an object`);
|
|
800
|
+
const patch = entry;
|
|
801
|
+
const encoding = this.normalizeEncoding(patch.encoding, `patches[${index}].encoding`);
|
|
802
|
+
return {
|
|
803
|
+
address: requireString(patch.address, `patches[${index}].address`),
|
|
804
|
+
data: requireString(patch.data, `patches[${index}].data`),
|
|
805
|
+
...encoding ? { encoding } : {}
|
|
806
|
+
};
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
normalizeEncoding(value, fieldName) {
|
|
810
|
+
if (value === void 0) return;
|
|
811
|
+
if (value === "hex" || value === "base64") return value;
|
|
812
|
+
throw new Error(`${fieldName} must be "hex" or "base64"`);
|
|
813
|
+
}
|
|
814
|
+
ensureRelativeOutputPath(outputPath) {
|
|
815
|
+
if (/^[/\\]/.test(outputPath) || /\.\./.test(outputPath) || /^[A-Za-z]:/.test(outputPath)) throw new Error("outputPath must be a relative path without parent directory traversal or drive letters");
|
|
911
816
|
}
|
|
912
817
|
};
|
|
913
818
|
//#endregion
|
|
@@ -1321,15 +1226,15 @@ function createDeps() {
|
|
|
1321
1226
|
var ProcessHandlersBase = class {
|
|
1322
1227
|
processMgmt;
|
|
1323
1228
|
memoryOps;
|
|
1324
|
-
|
|
1229
|
+
deps;
|
|
1325
1230
|
buildMemoryDiagnostics;
|
|
1326
1231
|
safeBuildMemoryDiagnostics;
|
|
1327
1232
|
recordMemoryAudit;
|
|
1328
1233
|
constructor() {
|
|
1329
|
-
this.
|
|
1330
|
-
logger.info(`ProcessToolHandlers initialized for platform: ${this.
|
|
1331
|
-
this.processMgmt = new ProcessManagementHandlers(this.
|
|
1332
|
-
this.memoryOps = new MemoryOperationHandlers(this.
|
|
1234
|
+
this.deps = createDeps();
|
|
1235
|
+
logger.info(`ProcessToolHandlers initialized for platform: ${this.deps.platform}`);
|
|
1236
|
+
this.processMgmt = new ProcessManagementHandlers(this.deps);
|
|
1237
|
+
this.memoryOps = new MemoryOperationHandlers(this.deps, this.processMgmt);
|
|
1333
1238
|
this.buildMemoryDiagnostics = this.processMgmt.buildMemoryDiagnostics.bind(this.processMgmt);
|
|
1334
1239
|
this.safeBuildMemoryDiagnostics = this.processMgmt.safeBuildMemoryDiagnostics.bind(this.processMgmt);
|
|
1335
1240
|
this.recordMemoryAudit = this.processMgmt.recordMemoryAudit.bind(this.processMgmt);
|
|
@@ -1379,7 +1284,7 @@ var ProcessToolHandlers = class extends ProcessHandlersBase {
|
|
|
1379
1284
|
injection;
|
|
1380
1285
|
constructor() {
|
|
1381
1286
|
super();
|
|
1382
|
-
this.injection = new InjectionHandlers(this.
|
|
1287
|
+
this.injection = new InjectionHandlers(this.deps, this.processMgmt);
|
|
1383
1288
|
}
|
|
1384
1289
|
async handleInjectDll(args) {
|
|
1385
1290
|
return this.injection.handleInjectDll(args);
|