@jshookmcp/jshook 0.2.7 → 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-CZ6IveoV.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 +384 -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 +48 -78
  151. package/dist/ExtensionManager-DqUSOamB.mjs +0 -2
  152. package/dist/ToolCatalog-CnwmMIw3.mjs +0 -61483
  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,135 @@
1
+ //#region src/server/domains/cross-domain/handlers/evidence-graph-bridge.impl.ts
2
+ var CrossDomainEvidenceBridge = class {
3
+ graph;
4
+ constructor(graph) {
5
+ this.graph = graph;
6
+ }
7
+ getGraph() {
8
+ return this.graph;
9
+ }
10
+ addNode(type, label, metadata) {
11
+ return this.graph.addNode(type, label, metadata);
12
+ }
13
+ addV8Object(input, scriptNodeId) {
14
+ const node = this.graph.addNode("v8-heap-object", input.name, {
15
+ domain: "v8-inspector",
16
+ address: input.address,
17
+ name: input.name
18
+ });
19
+ if (scriptNodeId) this.graph.addEdge(scriptNodeId, node.id, "heap-allocates", {
20
+ domain: "cross-domain",
21
+ relation: "script-allocates-heap-object"
22
+ });
23
+ return node;
24
+ }
25
+ addNetworkRequest(input, initiatorHeapNodeId) {
26
+ const label = input.method ? `${input.method} ${input.url}` : input.url;
27
+ const node = this.graph.addNode("network-request", label, {
28
+ domain: "network",
29
+ url: input.url,
30
+ method: input.method ?? "GET"
31
+ });
32
+ let initiatorNode;
33
+ if (initiatorHeapNodeId) {
34
+ initiatorNode = this.graph.getNode(initiatorHeapNodeId);
35
+ this.graph.addEdge(initiatorHeapNodeId, node.id, "network-initiated-by", {
36
+ domain: "cross-domain",
37
+ relation: "heap-initiates-network"
38
+ });
39
+ }
40
+ return {
41
+ node,
42
+ initiatorNode
43
+ };
44
+ }
45
+ addCanvasNode(input, creatorHeapNodeId) {
46
+ const node = this.graph.addNode("canvas-scene-node", input.label, {
47
+ domain: "canvas",
48
+ nodeId: input.nodeId,
49
+ label: input.label
50
+ });
51
+ if (creatorHeapNodeId) this.graph.addEdge(creatorHeapNodeId, node.id, "canvas-rendered-by", {
52
+ domain: "cross-domain",
53
+ relation: "heap-creates-canvas-node"
54
+ });
55
+ return node;
56
+ }
57
+ addSyscallEvent(input, jsFunctionNodeId) {
58
+ const node = this.graph.addNode("syscall-event", input.syscallName, {
59
+ domain: "syscall-hook",
60
+ pid: input.pid,
61
+ tid: input.tid,
62
+ syscallName: input.syscallName,
63
+ timestamp: input.timestamp
64
+ });
65
+ if (jsFunctionNodeId) this.graph.addEdge(jsFunctionNodeId, node.id, "syscall-emitted-by", {
66
+ domain: "cross-domain",
67
+ relation: "js-triggers-syscall"
68
+ });
69
+ return node;
70
+ }
71
+ addMojoMessage(input, cdpEventNodeId) {
72
+ const node = this.graph.addNode("mojo-message", `${input.interface}:${input.method}`, {
73
+ domain: "mojo-ipc",
74
+ interface: input.interface,
75
+ method: input.method,
76
+ timestamp: input.timestamp
77
+ });
78
+ if (cdpEventNodeId) this.graph.addEdge(cdpEventNodeId, node.id, "mojo-routed-to", {
79
+ domain: "cross-domain",
80
+ relation: "cdp-routes-to-mojo"
81
+ });
82
+ return node;
83
+ }
84
+ addBinarySymbol(input, jsFunctionNodeId) {
85
+ const node = this.graph.addNode("binary-symbol", input.symbolName, {
86
+ domain: "binary-instrument",
87
+ moduleName: input.moduleName,
88
+ symbolName: input.symbolName,
89
+ address: input.address
90
+ });
91
+ if (jsFunctionNodeId) this.graph.addEdge(jsFunctionNodeId, node.id, "binary-exports", {
92
+ domain: "cross-domain",
93
+ relation: "js-references-native-symbol"
94
+ });
95
+ return node;
96
+ }
97
+ queryByHeapAddress(addr) {
98
+ const snapshot = this.graph.exportJson();
99
+ const matchingIds = [];
100
+ for (const node of snapshot.nodes) {
101
+ const address = node.metadata["address"];
102
+ if (typeof address === "string" && address.includes(addr)) matchingIds.push(node.id);
103
+ }
104
+ return this.collectConnectedNodes(matchingIds);
105
+ }
106
+ queryByNetworkUrl(url) {
107
+ return this.graph.queryByUrl(url);
108
+ }
109
+ exportGraph() {
110
+ return this.graph.exportJson();
111
+ }
112
+ getStats() {
113
+ const snapshot = this.graph.exportJson();
114
+ const nodesByType = {};
115
+ for (const node of snapshot.nodes) {
116
+ const currentCount = nodesByType[node.type] ?? 0;
117
+ nodesByType[node.type] = currentCount + 1;
118
+ }
119
+ return {
120
+ nodeCount: snapshot.nodes.length,
121
+ edgeCount: snapshot.edges.length,
122
+ nodesByType
123
+ };
124
+ }
125
+ collectConnectedNodes(nodeIds) {
126
+ const collected = /* @__PURE__ */ new Map();
127
+ for (const nodeId of nodeIds) {
128
+ for (const node of this.graph.getEvidenceChain(nodeId, "forward")) collected.set(node.id, node);
129
+ for (const node of this.graph.getEvidenceChain(nodeId, "backward")) collected.set(node.id, node);
130
+ }
131
+ return [...collected.values()];
132
+ }
133
+ };
134
+ //#endregion
135
+ export { CrossDomainEvidenceBridge };
@@ -1,22 +1,7 @@
1
1
  import { t as __exportAll } from "./chunk-CjcI7cDX.mjs";
2
- import { _ as WriteProcessMemory, b as openProcessForMemory, d as ReadProcessMemory, f as VirtualAllocEx, h as VirtualQueryEx, i as GetModuleBaseName, l as MEM, m as VirtualProtectEx, n as EnumProcessModules, p as VirtualFreeEx, s as GetModuleInformation, t as CloseHandle, u as PAGE, v as isKoffiAvailable, y as isWindows } from "./Win32API-Bc0QnQsN.mjs";
3
- import { _ as machVmReadOverwrite, a as VM_PROT, b as taskForPid, c as dyldImageCount, d as kernReturnName, f as machPortDeallocate, g as machVmProtect, h as machVmDeallocate, i as VM_FLAGS, l as isDarwin, m as machVmAllocate, n as KERN, o as dyldGetImageHeader, p as machTaskSelf, r as SM, s as dyldGetImageName, u as isKoffiAvailableOnDarwin, v as machVmRegion, y as machVmWrite } from "./DarwinAPI-B8hg_yhz.mjs";
2
+ import { _ as WriteProcessMemory, b as openProcessForMemory, d as ReadProcessMemory, f as VirtualAllocEx, h as VirtualQueryEx, i as GetModuleBaseName, l as MEM, m as VirtualProtectEx, n as EnumProcessModules, p as VirtualFreeEx, s as GetModuleInformation, t as CloseHandle, u as PAGE, v as isKoffiAvailable, y as isWindows } from "./Win32API-CePkipZY.mjs";
3
+ import { _ as machVmReadOverwrite, a as VM_PROT, b as taskForPid, c as dyldImageCount, d as kernReturnName, f as machPortDeallocate, g as machVmProtect, h as machVmDeallocate, i as VM_FLAGS, l as isDarwin, m as machVmAllocate, n as KERN, o as dyldGetImageHeader, p as machTaskSelf, r as SM, s as dyldGetImageName, u as isKoffiAvailableOnDarwin, v as machVmRegion, y as machVmWrite } from "./DarwinAPI-BNPxu0RH.mjs";
4
4
  import fs from "node:fs";
5
- //#region src/native/platform/types.ts
6
- /** Memory protection flags (platform-independent) */
7
- let MemoryProtection = /* @__PURE__ */ function(MemoryProtection) {
8
- MemoryProtection[MemoryProtection["NoAccess"] = 0] = "NoAccess";
9
- MemoryProtection[MemoryProtection["Read"] = 1] = "Read";
10
- MemoryProtection[MemoryProtection["Write"] = 2] = "Write";
11
- MemoryProtection[MemoryProtection["Execute"] = 4] = "Execute";
12
- MemoryProtection[MemoryProtection["ReadWrite"] = 3] = "ReadWrite";
13
- MemoryProtection[MemoryProtection["ReadExecute"] = 5] = "ReadExecute";
14
- MemoryProtection[MemoryProtection["ReadWriteExecute"] = 7] = "ReadWriteExecute";
15
- MemoryProtection[MemoryProtection["Guard"] = 8] = "Guard";
16
- MemoryProtection[MemoryProtection["WriteCopy"] = 16] = "WriteCopy";
17
- return MemoryProtection;
18
- }({});
19
- //#endregion
20
5
  //#region src/native/platform/win32/Win32MemoryProvider.ts
21
6
  const handleMap$1 = /* @__PURE__ */ new WeakMap();
22
7
  function getWin32Handle(handle) {
@@ -25,28 +10,28 @@ function getWin32Handle(handle) {
25
10
  return h;
26
11
  }
27
12
  function win32ProtToMemoryProtection(prot) {
28
- let flags = MemoryProtection.NoAccess;
29
- if (prot & PAGE.READONLY) flags |= MemoryProtection.Read;
30
- if (prot & PAGE.READWRITE) flags |= MemoryProtection.ReadWrite;
31
- if (prot & PAGE.WRITECOPY) flags |= MemoryProtection.Read | MemoryProtection.WriteCopy;
32
- if (prot & PAGE.EXECUTE) flags |= MemoryProtection.Execute;
33
- if (prot & PAGE.EXECUTE_READ) flags |= MemoryProtection.ReadExecute;
34
- if (prot & PAGE.EXECUTE_READWRITE) flags |= MemoryProtection.ReadWriteExecute;
35
- if (prot & PAGE.EXECUTE_WRITECOPY) flags |= MemoryProtection.Execute | MemoryProtection.Read | MemoryProtection.WriteCopy;
36
- if (prot & PAGE.GUARD) flags |= MemoryProtection.Guard;
13
+ let flags = 0;
14
+ if (prot & PAGE.READONLY) flags |= 1;
15
+ if (prot & PAGE.READWRITE) flags |= 3;
16
+ if (prot & PAGE.WRITECOPY) flags |= 17;
17
+ if (prot & PAGE.EXECUTE) flags |= 4;
18
+ if (prot & PAGE.EXECUTE_READ) flags |= 5;
19
+ if (prot & PAGE.EXECUTE_READWRITE) flags |= 7;
20
+ if (prot & PAGE.EXECUTE_WRITECOPY) flags |= 21;
21
+ if (prot & PAGE.GUARD) flags |= 8;
37
22
  return flags;
38
23
  }
39
24
  function memoryProtectionToWin32Prot(prot) {
40
- const hasRead = (prot & MemoryProtection.Read) !== 0;
41
- const hasWrite = (prot & MemoryProtection.Write) !== 0;
42
- const hasExec = (prot & MemoryProtection.Execute) !== 0;
25
+ const hasRead = (prot & 1) !== 0;
26
+ const hasWrite = (prot & 2) !== 0;
27
+ const hasExec = (prot & 4) !== 0;
43
28
  let page = PAGE.NOACCESS;
44
29
  if (hasRead && hasWrite && hasExec) page = PAGE.EXECUTE_READWRITE;
45
30
  else if (hasRead && hasExec) page = PAGE.EXECUTE_READ;
46
31
  else if (hasRead && hasWrite) page = PAGE.READWRITE;
47
32
  else if (hasExec) page = PAGE.EXECUTE;
48
33
  else if (hasRead) page = PAGE.READONLY;
49
- if ((prot & MemoryProtection.Guard) !== 0) page |= PAGE.GUARD;
34
+ if ((prot & 8) !== 0) page |= PAGE.GUARD;
50
35
  return page;
51
36
  }
52
37
  function win32StateToState(state) {
@@ -110,9 +95,9 @@ var Win32MemoryProvider = class {
110
95
  protection,
111
96
  state: win32StateToState(info.State),
112
97
  type: win32TypeToType(info.Type),
113
- isReadable: (protection & MemoryProtection.Read) !== 0,
114
- isWritable: (protection & MemoryProtection.Write) !== 0,
115
- isExecutable: (protection & MemoryProtection.Execute) !== 0
98
+ isReadable: (protection & 1) !== 0,
99
+ isWritable: (protection & 2) !== 0,
100
+ isExecutable: (protection & 4) !== 0
116
101
  };
117
102
  }
118
103
  changeProtection(handle, address, size, newProtection) {
@@ -161,10 +146,10 @@ function getDarwinHandle(handle) {
161
146
  * Map Mach VM_PROT_* flags → platform-agnostic MemoryProtection
162
147
  */
163
148
  function machProtToMemoryProtection(prot) {
164
- let flags = MemoryProtection.NoAccess;
165
- if (prot & VM_PROT.READ) flags |= MemoryProtection.Read;
166
- if (prot & VM_PROT.WRITE) flags |= MemoryProtection.Write;
167
- if (prot & VM_PROT.EXECUTE) flags |= MemoryProtection.Execute;
149
+ let flags = 0;
150
+ if (prot & VM_PROT.READ) flags |= 1;
151
+ if (prot & VM_PROT.WRITE) flags |= 2;
152
+ if (prot & VM_PROT.EXECUTE) flags |= 4;
168
153
  return flags;
169
154
  }
170
155
  /**
@@ -172,9 +157,9 @@ function machProtToMemoryProtection(prot) {
172
157
  */
173
158
  function memoryProtectionToMachProt(prot) {
174
159
  let machProt = VM_PROT.NONE;
175
- if (prot & MemoryProtection.Read) machProt |= VM_PROT.READ;
176
- if (prot & MemoryProtection.Write) machProt |= VM_PROT.WRITE;
177
- if (prot & MemoryProtection.Execute) machProt |= VM_PROT.EXECUTE;
160
+ if (prot & 1) machProt |= VM_PROT.READ;
161
+ if (prot & 2) machProt |= VM_PROT.WRITE;
162
+ if (prot & 4) machProt |= VM_PROT.EXECUTE;
178
163
  return machProt;
179
164
  }
180
165
  /**
@@ -264,16 +249,16 @@ var DarwinMemoryProvider = class {
264
249
  protection,
265
250
  state: "committed",
266
251
  type: darwinShareModeToType(info.behavior),
267
- isReadable: (protection & MemoryProtection.Read) !== 0,
268
- isWritable: (protection & MemoryProtection.Write) !== 0,
269
- isExecutable: (protection & MemoryProtection.Execute) !== 0
252
+ isReadable: (protection & 1) !== 0,
253
+ isWritable: (protection & 2) !== 0,
254
+ isExecutable: (protection & 4) !== 0
270
255
  };
271
256
  }
272
257
  changeProtection(handle, address, size, newProtection) {
273
258
  const h = getDarwinHandle(handle);
274
259
  const machProt = memoryProtectionToMachProt(newProtection);
275
260
  const { kr: queryKr, info } = machVmRegion(h.task, address);
276
- const oldProtection = queryKr === KERN.SUCCESS ? machProtToMemoryProtection(info.protection) : MemoryProtection.NoAccess;
261
+ const oldProtection = queryKr === KERN.SUCCESS ? machProtToMemoryProtection(info.protection) : 0;
277
262
  if ((machProt & VM_PROT.WRITE) !== 0 && (machProt & VM_PROT.EXECUTE) !== 0) {
278
263
  const maxKr = machVmProtect(h.task, address, BigInt(size), true, VM_PROT.ALL);
279
264
  if (maxKr !== KERN.SUCCESS) throw new Error(`mach_vm_protect (set_maximum) failed at 0x${address.toString(16)}: ${kernReturnName(maxKr)} (${maxKr})`);
@@ -389,10 +374,10 @@ function isLinuxRuntime() {
389
374
  return process.platform === "linux";
390
375
  }
391
376
  function toProtection(perms) {
392
- let protection = MemoryProtection.NoAccess;
393
- if (perms.includes("r")) protection |= MemoryProtection.Read;
394
- if (perms.includes("w")) protection |= MemoryProtection.Write;
395
- if (perms.includes("x")) protection |= MemoryProtection.Execute;
377
+ let protection = 0;
378
+ if (perms.includes("r")) protection |= 1;
379
+ if (perms.includes("w")) protection |= 2;
380
+ if (perms.includes("x")) protection |= 4;
396
381
  return protection;
397
382
  }
398
383
  function toRegionInfo(region) {
@@ -403,9 +388,9 @@ function toRegionInfo(region) {
403
388
  protection,
404
389
  state: "committed",
405
390
  type: region.path ? "mapped" : "private",
406
- isReadable: (protection & MemoryProtection.Read) !== 0,
407
- isWritable: (protection & MemoryProtection.Write) !== 0,
408
- isExecutable: (protection & MemoryProtection.Execute) !== 0
391
+ isReadable: (protection & 1) !== 0,
392
+ isWritable: (protection & 2) !== 0,
393
+ isExecutable: (protection & 4) !== 0
409
394
  };
410
395
  }
411
396
  function normalizePattern(pattern) {
@@ -587,4 +572,4 @@ function createPlatformProvider() {
587
572
  return cachedProvider;
588
573
  }
589
574
  //#endregion
590
- export { MemoryProtection as a, parseProcMaps as i, factory_exports as n, formatLinuxProtection as r, createPlatformProvider as t };
575
+ export { parseProcMaps as i, factory_exports as n, formatLinuxProtection as r, createPlatformProvider as t };