@cheatron/native-mock 1.0.0 → 1.0.2
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/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +6 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/kernel32.d.ts +31 -0
- package/dist/src/kernel32.d.ts.map +1 -0
- package/dist/src/kernel32.js +232 -0
- package/dist/src/kernel32.js.map +1 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/{logger.js → src/logger.js} +1 -0
- package/dist/src/logger.js.map +1 -0
- package/dist/src/msvcrt.d.ts +15 -0
- package/dist/src/msvcrt.d.ts.map +1 -0
- package/dist/src/msvcrt.js +43 -0
- package/dist/src/msvcrt.js.map +1 -0
- package/dist/src/os/handles.d.ts +17 -0
- package/dist/src/os/handles.d.ts.map +1 -0
- package/dist/{os → src/os}/handles.js +2 -0
- package/dist/src/os/handles.js.map +1 -0
- package/dist/src/os/kernel.d.ts +21 -0
- package/dist/src/os/kernel.d.ts.map +1 -0
- package/dist/{os → src/os}/kernel.js +36 -1
- package/dist/src/os/kernel.js.map +1 -0
- package/dist/{os → src/os}/memory.d.ts +1 -5
- package/dist/src/os/memory.d.ts.map +1 -0
- package/dist/{os → src/os}/memory.js +3 -8
- package/dist/src/os/memory.js.map +1 -0
- package/dist/src/os/module.d.ts +11 -0
- package/dist/src/os/module.d.ts.map +1 -0
- package/dist/src/os/module.js +20 -0
- package/dist/src/os/module.js.map +1 -0
- package/dist/{os → src/os}/process.d.ts +4 -0
- package/dist/src/os/process.d.ts.map +1 -0
- package/dist/{os → src/os}/process.js +12 -0
- package/dist/src/os/process.js.map +1 -0
- package/dist/{os → src/os}/thread.d.ts +4 -4
- package/dist/src/os/thread.d.ts.map +1 -0
- package/dist/{os → src/os}/thread.js +1 -0
- package/dist/src/os/thread.js.map +1 -0
- package/dist/utils/src/handle.d.ts +26 -0
- package/dist/utils/src/handle.d.ts.map +1 -0
- package/dist/utils/src/handle.js +56 -0
- package/dist/utils/src/handle.js.map +1 -0
- package/dist/utils/src/index.d.ts +4 -0
- package/dist/utils/src/index.d.ts.map +1 -0
- package/dist/utils/src/index.js +4 -0
- package/dist/utils/src/index.js.map +1 -0
- package/dist/utils/src/module.d.ts +22 -0
- package/dist/utils/src/module.d.ts.map +1 -0
- package/dist/utils/src/module.js +54 -0
- package/dist/utils/src/module.js.map +1 -0
- package/dist/utils/src/process.d.ts +30 -0
- package/dist/utils/src/process.d.ts.map +1 -0
- package/dist/utils/src/process.js +103 -0
- package/dist/utils/src/process.js.map +1 -0
- package/dist/utils/src/thread.d.ts +38 -0
- package/dist/utils/src/thread.d.ts.map +1 -0
- package/dist/utils/src/thread.js +136 -0
- package/dist/utils/src/thread.js.map +1 -0
- package/package.json +7 -7
- package/dist/constants.d.ts +0 -175
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js +0 -173
- package/dist/index.d.ts +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -4
- package/dist/kernel32.d.ts +0 -22
- package/dist/kernel32.d.ts.map +0 -1
- package/dist/kernel32.js +0 -170
- package/dist/logger.d.ts.map +0 -1
- package/dist/os/handles.d.ts +0 -17
- package/dist/os/handles.d.ts.map +0 -1
- package/dist/os/kernel.d.ts +0 -18
- package/dist/os/kernel.d.ts.map +0 -1
- package/dist/os/memory.d.ts.map +0 -1
- package/dist/os/process.d.ts.map +0 -1
- package/dist/os/thread.d.ts.map +0 -1
- package/dist/process.d.ts +0 -30
- package/dist/process.d.ts.map +0 -1
- package/dist/process.js +0 -124
- package/dist/thread.d.ts +0 -28
- package/dist/thread.d.ts.map +0 -1
- package/dist/thread.js +0 -113
- /package/dist/{logger.d.ts → src/logger.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"thread.js","sourceRoot":"","sources":["../../../utils/src/thread.ts"],"names":[],"mappings":"AAAA,OAAO,EACL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Q,KAAK;QACZ,IAAI,CAAC,OAAO,GAAG,IAAK,CAAC;IACvB,CAAC;CACF;AAED,2EAA2E;AAC3E,IAAI,cAAyC,CAAC;AAC9C,MAAM,CAAC,MAAM,aAAa,GAAkB,IAAI,KAAK,CAAC,EAAmB,EAAE;IACzE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,QAAQ;QACzB,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,cAAc,GAAG,IAAI,aAAa,EAAE,CAAC;QACvC,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACrD,CAAC;IACD,cAAc;QACZ,OAAO,aAAa,CAAC,SAAS,CAAC;IACjC,CAAC;CACF,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cheatron/native-mock",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Pure JavaScript mock implementation of Win32 native modules for testing without native dependencies",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@cheatron/log": "^1.0.1",
|
|
33
33
|
"@cheatron/native-mock-koffi": "^1.0.0",
|
|
34
|
-
"win32-
|
|
34
|
+
"@cheatron/win32-ext": "^1.0.2"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@eslint/js": "^10.0.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"eslint-config-prettier": "^10.1.8",
|
|
42
42
|
"globals": "^17.3.0",
|
|
43
43
|
"prettier": "^3.8.1",
|
|
44
|
-
"typescript": "^5",
|
|
44
|
+
"typescript": "^5.9.3",
|
|
45
45
|
"typescript-eslint": "^8.56.0"
|
|
46
46
|
},
|
|
47
47
|
"overrides": {
|
|
@@ -51,9 +51,9 @@
|
|
|
51
51
|
"build": "tsc",
|
|
52
52
|
"prepublishOnly": "bun run build",
|
|
53
53
|
"test": "bun test",
|
|
54
|
-
"lint": "eslint \"src/**/*.{js,ts,jsx,tsx}\" --cache",
|
|
55
|
-
"lint:fix": "eslint \"src/**/*.{js,ts,jsx,tsx}\" --fix",
|
|
56
|
-
"format": "prettier --write \"{src,tests}/**/*.{js,ts,jsx,tsx,css,md,json}\"",
|
|
57
|
-
"format:check": "prettier --check \"{src,tests}/**/*.{js,ts,jsx,tsx,css,md,json}\""
|
|
54
|
+
"lint": "eslint \"{src,utils,tests}/**/*.{js,ts,jsx,tsx}\" --cache",
|
|
55
|
+
"lint:fix": "eslint \"{src,utils,tests}/**/*.{js,ts,jsx,tsx}\" --fix",
|
|
56
|
+
"format": "prettier --write \"{src,utils,tests}/**/*.{js,ts,jsx,tsx,css,md,json}\"",
|
|
57
|
+
"format:check": "prettier --check \"{src,utils,tests}/**/*.{js,ts,jsx,tsx,css,md,json}\""
|
|
58
58
|
}
|
|
59
59
|
}
|
package/dist/constants.d.ts
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process access rights
|
|
3
|
-
* https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
|
4
|
-
*/
|
|
5
|
-
export declare const ProcessAccess: {
|
|
6
|
-
readonly TERMINATE: 1;
|
|
7
|
-
readonly CREATE_THREAD: 2;
|
|
8
|
-
readonly SET_SESSIONID: 4;
|
|
9
|
-
readonly VM_OPERATION: 8;
|
|
10
|
-
readonly VM_READ: 16;
|
|
11
|
-
readonly VM_WRITE: 32;
|
|
12
|
-
readonly DUP_HANDLE: 64;
|
|
13
|
-
readonly CREATE_PROCESS: 128;
|
|
14
|
-
readonly SET_QUOTA: 256;
|
|
15
|
-
readonly SET_INFORMATION: 512;
|
|
16
|
-
readonly QUERY_INFORMATION: 1024;
|
|
17
|
-
readonly SUSPEND_RESUME: 2048;
|
|
18
|
-
readonly QUERY_LIMITED_INFORMATION: 4096;
|
|
19
|
-
readonly SET_LIMITED_INFORMATION: 8192;
|
|
20
|
-
readonly ALL_ACCESS: 2097151;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Thread access rights
|
|
24
|
-
* https://learn.microsoft.com/en-us/windows/win32/procthread/thread-security-and-access-rights
|
|
25
|
-
*/
|
|
26
|
-
export declare const ThreadAccess: {
|
|
27
|
-
readonly TERMINATE: 1;
|
|
28
|
-
readonly SUSPEND_RESUME: 2;
|
|
29
|
-
readonly GET_CONTEXT: 8;
|
|
30
|
-
readonly SET_CONTEXT: 16;
|
|
31
|
-
readonly SET_INFORMATION: 32;
|
|
32
|
-
readonly QUERY_INFORMATION: 64;
|
|
33
|
-
readonly SET_THREAD_TOKEN: 128;
|
|
34
|
-
readonly IMPERSONATE: 256;
|
|
35
|
-
readonly DIRECT_IMPERSONATION: 512;
|
|
36
|
-
readonly SET_LIMITED_INFORMATION: 1024;
|
|
37
|
-
readonly QUERY_LIMITED_INFORMATION: 2048;
|
|
38
|
-
readonly ALL_ACCESS: 2097151;
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Memory protection constants
|
|
42
|
-
* https://learn.microsoft.com/en-us/windows/win32/memory/memory-protection-constants
|
|
43
|
-
*/
|
|
44
|
-
export declare const MemoryProtection: {
|
|
45
|
-
readonly NOACCESS: 1;
|
|
46
|
-
readonly READONLY: 2;
|
|
47
|
-
readonly READWRITE: 4;
|
|
48
|
-
readonly WRITECOPY: 8;
|
|
49
|
-
readonly EXECUTE: 16;
|
|
50
|
-
readonly EXECUTE_READ: 32;
|
|
51
|
-
readonly EXECUTE_READWRITE: 64;
|
|
52
|
-
readonly EXECUTE_WRITECOPY: 128;
|
|
53
|
-
readonly GUARD: 256;
|
|
54
|
-
readonly NOCACHE: 512;
|
|
55
|
-
readonly WRITECOMBINE: 1024;
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Memory state constants
|
|
59
|
-
*/
|
|
60
|
-
export declare const MemoryState: {
|
|
61
|
-
readonly COMMIT: 4096;
|
|
62
|
-
readonly RESERVE: 8192;
|
|
63
|
-
readonly FREE: 65536;
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Memory type constants
|
|
67
|
-
*/
|
|
68
|
-
export declare const MemoryType: {
|
|
69
|
-
readonly PRIVATE: 131072;
|
|
70
|
-
readonly MAPPED: 262144;
|
|
71
|
-
readonly IMAGE: 16777216;
|
|
72
|
-
};
|
|
73
|
-
export type ProcessAccessValue = (typeof ProcessAccess)[keyof typeof ProcessAccess];
|
|
74
|
-
export type ThreadAccessValue = (typeof ThreadAccess)[keyof typeof ThreadAccess];
|
|
75
|
-
/**
|
|
76
|
-
* MEMORY_BASIC_INFORMATION structure
|
|
77
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-memory_basic_information
|
|
78
|
-
*/
|
|
79
|
-
export interface MemoryBasicInformation {
|
|
80
|
-
BaseAddress: number | bigint;
|
|
81
|
-
AllocationBase: number | bigint;
|
|
82
|
-
AllocationProtect: number;
|
|
83
|
-
RegionSize: number | bigint;
|
|
84
|
-
State: number;
|
|
85
|
-
Protect: number;
|
|
86
|
-
Type: number;
|
|
87
|
-
}
|
|
88
|
-
export declare const MEMORY_BASIC_INFORMATION: {
|
|
89
|
-
name: string;
|
|
90
|
-
spec: unknown;
|
|
91
|
-
};
|
|
92
|
-
export declare const MBI_SIZE: 1 | 2 | 4 | 8 | 16 | 48 | 1232;
|
|
93
|
-
export declare const ContextFlags: {
|
|
94
|
-
readonly AMD64: 1048576;
|
|
95
|
-
readonly CONTROL: number;
|
|
96
|
-
readonly INTEGER: number;
|
|
97
|
-
readonly SEGMENTS: number;
|
|
98
|
-
readonly FLOATING_POINT: number;
|
|
99
|
-
readonly DEBUG_REGISTERS: number;
|
|
100
|
-
readonly FULL: number;
|
|
101
|
-
readonly ALL: number;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* M128A structure (128-bit register value)
|
|
105
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-m128a
|
|
106
|
-
*/
|
|
107
|
-
export declare const M128A: {
|
|
108
|
-
name: string;
|
|
109
|
-
spec: unknown;
|
|
110
|
-
};
|
|
111
|
-
export interface M128AValue {
|
|
112
|
-
Low: bigint;
|
|
113
|
-
High: bigint;
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* CONTEXT structure for x64 (AMD64)
|
|
117
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-context
|
|
118
|
-
*/
|
|
119
|
-
export declare const CONTEXT: {
|
|
120
|
-
name: string;
|
|
121
|
-
spec: unknown;
|
|
122
|
-
};
|
|
123
|
-
export declare const CONTEXT_SIZE: 1 | 2 | 4 | 8 | 16 | 48 | 1232;
|
|
124
|
-
/**
|
|
125
|
-
* Parsed thread context (x64)
|
|
126
|
-
*/
|
|
127
|
-
export interface ThreadContext {
|
|
128
|
-
P1Home: bigint;
|
|
129
|
-
P2Home: bigint;
|
|
130
|
-
P3Home: bigint;
|
|
131
|
-
P4Home: bigint;
|
|
132
|
-
P5Home: bigint;
|
|
133
|
-
P6Home: bigint;
|
|
134
|
-
ContextFlags: number;
|
|
135
|
-
MxCsr: number;
|
|
136
|
-
SegCs: number;
|
|
137
|
-
SegDs: number;
|
|
138
|
-
SegEs: number;
|
|
139
|
-
SegFs: number;
|
|
140
|
-
SegGs: number;
|
|
141
|
-
SegSs: number;
|
|
142
|
-
EFlags: number;
|
|
143
|
-
Dr0: bigint;
|
|
144
|
-
Dr1: bigint;
|
|
145
|
-
Dr2: bigint;
|
|
146
|
-
Dr3: bigint;
|
|
147
|
-
Dr6: bigint;
|
|
148
|
-
Dr7: bigint;
|
|
149
|
-
Rax: bigint;
|
|
150
|
-
Rcx: bigint;
|
|
151
|
-
Rdx: bigint;
|
|
152
|
-
Rbx: bigint;
|
|
153
|
-
Rsp: bigint;
|
|
154
|
-
Rbp: bigint;
|
|
155
|
-
Rsi: bigint;
|
|
156
|
-
Rdi: bigint;
|
|
157
|
-
R8: bigint;
|
|
158
|
-
R9: bigint;
|
|
159
|
-
R10: bigint;
|
|
160
|
-
R11: bigint;
|
|
161
|
-
R12: bigint;
|
|
162
|
-
R13: bigint;
|
|
163
|
-
R14: bigint;
|
|
164
|
-
R15: bigint;
|
|
165
|
-
Rip: bigint;
|
|
166
|
-
FltSave: number[];
|
|
167
|
-
VectorRegister: M128AValue[];
|
|
168
|
-
VectorControl: bigint;
|
|
169
|
-
DebugControl: bigint;
|
|
170
|
-
LastBranchToRip: bigint;
|
|
171
|
-
LastBranchFromRip: bigint;
|
|
172
|
-
LastExceptionToRip: bigint;
|
|
173
|
-
LastExceptionFromRip: bigint;
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;CAgBhB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAaf,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;;;;;CAYnB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,WAAW;;;;CAId,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,UAAU;;;;CAIb,CAAC;AAEX,MAAM,MAAM,kBAAkB,GAC5B,CAAC,OAAO,aAAa,CAAC,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC;AACrD,MAAM,MAAM,iBAAiB,GAC3B,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,GAAG,MAAM,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IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,cAAc,EAAE,UAAU,EAAE,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;CAC9B"}
|
package/dist/constants.js
DELETED
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Process access rights
|
|
3
|
-
* https://learn.microsoft.com/en-us/windows/win32/procthread/process-security-and-access-rights
|
|
4
|
-
*/
|
|
5
|
-
export const ProcessAccess = {
|
|
6
|
-
TERMINATE: 0x0001,
|
|
7
|
-
CREATE_THREAD: 0x0002,
|
|
8
|
-
SET_SESSIONID: 0x0004,
|
|
9
|
-
VM_OPERATION: 0x0008,
|
|
10
|
-
VM_READ: 0x0010,
|
|
11
|
-
VM_WRITE: 0x0020,
|
|
12
|
-
DUP_HANDLE: 0x0040,
|
|
13
|
-
CREATE_PROCESS: 0x0080,
|
|
14
|
-
SET_QUOTA: 0x0100,
|
|
15
|
-
SET_INFORMATION: 0x0200,
|
|
16
|
-
QUERY_INFORMATION: 0x0400,
|
|
17
|
-
SUSPEND_RESUME: 0x0800,
|
|
18
|
-
QUERY_LIMITED_INFORMATION: 0x1000,
|
|
19
|
-
SET_LIMITED_INFORMATION: 0x2000,
|
|
20
|
-
ALL_ACCESS: 0x1fffff,
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Thread access rights
|
|
24
|
-
* https://learn.microsoft.com/en-us/windows/win32/procthread/thread-security-and-access-rights
|
|
25
|
-
*/
|
|
26
|
-
export const ThreadAccess = {
|
|
27
|
-
TERMINATE: 0x0001,
|
|
28
|
-
SUSPEND_RESUME: 0x0002,
|
|
29
|
-
GET_CONTEXT: 0x0008,
|
|
30
|
-
SET_CONTEXT: 0x0010,
|
|
31
|
-
SET_INFORMATION: 0x0020,
|
|
32
|
-
QUERY_INFORMATION: 0x0040,
|
|
33
|
-
SET_THREAD_TOKEN: 0x0080,
|
|
34
|
-
IMPERSONATE: 0x0100,
|
|
35
|
-
DIRECT_IMPERSONATION: 0x0200,
|
|
36
|
-
SET_LIMITED_INFORMATION: 0x0400,
|
|
37
|
-
QUERY_LIMITED_INFORMATION: 0x0800,
|
|
38
|
-
ALL_ACCESS: 0x1fffff,
|
|
39
|
-
};
|
|
40
|
-
/**
|
|
41
|
-
* Memory protection constants
|
|
42
|
-
* https://learn.microsoft.com/en-us/windows/win32/memory/memory-protection-constants
|
|
43
|
-
*/
|
|
44
|
-
export const MemoryProtection = {
|
|
45
|
-
NOACCESS: 0x01,
|
|
46
|
-
READONLY: 0x02,
|
|
47
|
-
READWRITE: 0x04,
|
|
48
|
-
WRITECOPY: 0x08,
|
|
49
|
-
EXECUTE: 0x10,
|
|
50
|
-
EXECUTE_READ: 0x20,
|
|
51
|
-
EXECUTE_READWRITE: 0x40,
|
|
52
|
-
EXECUTE_WRITECOPY: 0x80,
|
|
53
|
-
GUARD: 0x100,
|
|
54
|
-
NOCACHE: 0x200,
|
|
55
|
-
WRITECOMBINE: 0x400,
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* Memory state constants
|
|
59
|
-
*/
|
|
60
|
-
export const MemoryState = {
|
|
61
|
-
COMMIT: 0x1000,
|
|
62
|
-
RESERVE: 0x2000,
|
|
63
|
-
FREE: 0x10000,
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* Memory type constants
|
|
67
|
-
*/
|
|
68
|
-
export const MemoryType = {
|
|
69
|
-
PRIVATE: 0x20000,
|
|
70
|
-
MAPPED: 0x40000,
|
|
71
|
-
IMAGE: 0x1000000,
|
|
72
|
-
};
|
|
73
|
-
import koffi from 'koffi';
|
|
74
|
-
// Koffi struct for MEMORY_BASIC_INFORMATION (64-bit)
|
|
75
|
-
export const MEMORY_BASIC_INFORMATION = koffi.struct('MEMORY_BASIC_INFORMATION', {
|
|
76
|
-
BaseAddress: 'uint64',
|
|
77
|
-
AllocationBase: 'uint64',
|
|
78
|
-
AllocationProtect: 'uint32',
|
|
79
|
-
__PartitionId: 'uint16',
|
|
80
|
-
__pad: 'uint16',
|
|
81
|
-
RegionSize: 'uint64',
|
|
82
|
-
State: 'uint32',
|
|
83
|
-
Protect: 'uint32',
|
|
84
|
-
Type: 'uint32',
|
|
85
|
-
__pad2: 'uint32',
|
|
86
|
-
});
|
|
87
|
-
export const MBI_SIZE = koffi.sizeof(MEMORY_BASIC_INFORMATION);
|
|
88
|
-
/**
|
|
89
|
-
* CONTEXT flags for x64
|
|
90
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-context
|
|
91
|
-
*/
|
|
92
|
-
const CONTEXT_AMD64 = 0x00100000;
|
|
93
|
-
export const ContextFlags = {
|
|
94
|
-
AMD64: CONTEXT_AMD64,
|
|
95
|
-
CONTROL: CONTEXT_AMD64 | 0x01,
|
|
96
|
-
INTEGER: CONTEXT_AMD64 | 0x02,
|
|
97
|
-
SEGMENTS: CONTEXT_AMD64 | 0x04,
|
|
98
|
-
FLOATING_POINT: CONTEXT_AMD64 | 0x08,
|
|
99
|
-
DEBUG_REGISTERS: CONTEXT_AMD64 | 0x10,
|
|
100
|
-
FULL: CONTEXT_AMD64 | 0x01 | 0x02 | 0x08,
|
|
101
|
-
ALL: CONTEXT_AMD64 | 0x01 | 0x02 | 0x04 | 0x08 | 0x10,
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* M128A structure (128-bit register value)
|
|
105
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-m128a
|
|
106
|
-
*/
|
|
107
|
-
export const M128A = koffi.struct('M128A', {
|
|
108
|
-
Low: 'uint64',
|
|
109
|
-
High: 'int64',
|
|
110
|
-
});
|
|
111
|
-
/**
|
|
112
|
-
* CONTEXT structure for x64 (AMD64)
|
|
113
|
-
* https://learn.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-context
|
|
114
|
-
*/
|
|
115
|
-
export const CONTEXT = koffi.struct('CONTEXT', {
|
|
116
|
-
// Register parameter home addresses
|
|
117
|
-
P1Home: 'uint64',
|
|
118
|
-
P2Home: 'uint64',
|
|
119
|
-
P3Home: 'uint64',
|
|
120
|
-
P4Home: 'uint64',
|
|
121
|
-
P5Home: 'uint64',
|
|
122
|
-
P6Home: 'uint64',
|
|
123
|
-
// Control flags
|
|
124
|
-
ContextFlags: 'uint32',
|
|
125
|
-
MxCsr: 'uint32',
|
|
126
|
-
// Segment registers
|
|
127
|
-
SegCs: 'uint16',
|
|
128
|
-
SegDs: 'uint16',
|
|
129
|
-
SegEs: 'uint16',
|
|
130
|
-
SegFs: 'uint16',
|
|
131
|
-
SegGs: 'uint16',
|
|
132
|
-
SegSs: 'uint16',
|
|
133
|
-
// Flags
|
|
134
|
-
EFlags: 'uint32',
|
|
135
|
-
// Debug registers
|
|
136
|
-
Dr0: 'uint64',
|
|
137
|
-
Dr1: 'uint64',
|
|
138
|
-
Dr2: 'uint64',
|
|
139
|
-
Dr3: 'uint64',
|
|
140
|
-
Dr6: 'uint64',
|
|
141
|
-
Dr7: 'uint64',
|
|
142
|
-
// Integer registers
|
|
143
|
-
Rax: 'uint64',
|
|
144
|
-
Rcx: 'uint64',
|
|
145
|
-
Rdx: 'uint64',
|
|
146
|
-
Rbx: 'uint64',
|
|
147
|
-
Rsp: 'uint64',
|
|
148
|
-
Rbp: 'uint64',
|
|
149
|
-
Rsi: 'uint64',
|
|
150
|
-
Rdi: 'uint64',
|
|
151
|
-
R8: 'uint64',
|
|
152
|
-
R9: 'uint64',
|
|
153
|
-
R10: 'uint64',
|
|
154
|
-
R11: 'uint64',
|
|
155
|
-
R12: 'uint64',
|
|
156
|
-
R13: 'uint64',
|
|
157
|
-
R14: 'uint64',
|
|
158
|
-
R15: 'uint64',
|
|
159
|
-
// Program counter
|
|
160
|
-
Rip: 'uint64',
|
|
161
|
-
// Floating point / XMM save area (XMM_SAVE_AREA32 = 512 bytes)
|
|
162
|
-
FltSave: 'uint8[512]',
|
|
163
|
-
// Vector registers
|
|
164
|
-
VectorRegister: 'M128A[26]',
|
|
165
|
-
VectorControl: 'uint64',
|
|
166
|
-
// Special debug registers
|
|
167
|
-
DebugControl: 'uint64',
|
|
168
|
-
LastBranchToRip: 'uint64',
|
|
169
|
-
LastBranchFromRip: 'uint64',
|
|
170
|
-
LastExceptionToRip: 'uint64',
|
|
171
|
-
LastExceptionFromRip: 'uint64',
|
|
172
|
-
});
|
|
173
|
-
export const CONTEXT_SIZE = koffi.sizeof(CONTEXT);
|
package/dist/index.d.ts
DELETED
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC"}
|
package/dist/index.js
DELETED
package/dist/kernel32.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as D from 'win32-def';
|
|
2
|
-
export declare const Kernel32Impl: {
|
|
3
|
-
OpenProcess: (dwDesiredAccess: D.DWORD, bInheritHandle: D.BOOL, dwProcessId: D.DWORD) => D.HANDLE;
|
|
4
|
-
GetCurrentProcess: () => D.HANDLE;
|
|
5
|
-
GetCurrentProcessId: () => D.DWORD;
|
|
6
|
-
CloseHandle: (hObject: D.HANDLE) => D.BOOL;
|
|
7
|
-
ReadProcessMemory: (hProcess: D.HANDLE, lpBaseAddress: D.LPCVOID, lpBuffer: Buffer, nSize: D.SIZE_T, _lpNumberOfBytesRead: D.LPDWORD | null) => D.BOOL;
|
|
8
|
-
WriteProcessMemory: (hProcess: D.HANDLE, lpBaseAddress: D.LPCVOID, lpBuffer: Buffer, nSize: D.SIZE_T, _lpNumberOfBytesWritten: D.LPDWORD | null) => D.BOOL;
|
|
9
|
-
VirtualAlloc: (lpAddress: D.LPCVOID, dwSize: D.SIZE_T, flAllocationType: D.DWORD, flProtect: D.DWORD) => D.LPVOID;
|
|
10
|
-
VirtualAllocEx: (hProcess: D.HANDLE, lpAddress: D.LPCVOID, dwSize: D.SIZE_T, flAllocationType: D.DWORD, flProtect: D.DWORD) => D.LPVOID;
|
|
11
|
-
VirtualQuery: (lpAddress: D.LPCVOID, lpBuffer: Buffer, dwLength: D.SIZE_T) => D.SIZE_T;
|
|
12
|
-
VirtualQueryEx: (hProcess: D.HANDLE, lpAddress: D.LPCVOID, lpBuffer: Buffer, dwLength: D.SIZE_T) => D.SIZE_T;
|
|
13
|
-
OpenThread: (_dwDesiredAccess: D.DWORD, _bInheritHandle: D.BOOL, _dwThreadId: D.DWORD) => D.HANDLE;
|
|
14
|
-
GetCurrentThread: () => D.HANDLE;
|
|
15
|
-
GetCurrentThreadId: () => D.DWORD;
|
|
16
|
-
SuspendThread: (hThread: D.HANDLE) => D.DWORD;
|
|
17
|
-
ResumeThread: (hThread: D.HANDLE) => D.DWORD;
|
|
18
|
-
GetThreadContext: (_hThread: D.HANDLE, _lpContext: Buffer) => D.BOOL;
|
|
19
|
-
SetThreadContext: (_hThread: D.HANDLE, _lpContext: Buffer) => D.BOOL;
|
|
20
|
-
GetLastError: () => D.DWORD;
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=kernel32.d.ts.map
|
package/dist/kernel32.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kernel32.d.ts","sourceRoot":"","sources":["../src/kernel32.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAQ/B,eAAO,MAAM,YAAY;mCAGJ,CAAC,CAAC,KAAK,kBACR,CAAC,CAAC,IAAI,eACT,CAAC,CAAC,KAAK,KACnB,CAAC,CAAC,MAAM;6BAGY,CAAC,CAAC,MAAM;+BACN,CAAC,CAAC,KAAK;2BACT,CAAC,CAAC,MAAM,KAAG,CAAC,CAAC,IAAI;kCAS5B,CAAC,CAAC,MAAM,iBACH,CAAC,CAAC,OAAO,YACd,MAAM,SACT,CAAC,CAAC,MAAM,wBACO,CAAC,CAAC,OAAO,GAAG,IAAI,KACrC,CAAC,CAAC,IAAI;mCA0BG,CAAC,CAAC,MAAM,iBACH,CAAC,CAAC,OAAO,YACd,MAAM,SACT,CAAC,CAAC,MAAM,2BACU,CAAC,CAAC,OAAO,GAAG,IAAI,KACxC,CAAC,CAAC,IAAI;8BA6BI,CAAC,CAAC,OAAO,UACZ,CAAC,CAAC,MAAM,oBACE,CAAC,CAAC,KAAK,aACd,CAAC,CAAC,KAAK,KACjB,CAAC,CAAC,MAAM;+BAUC,CAAC,CAAC,MAAM,aACP,CAAC,CAAC,OAAO,UACZ,CAAC,CAAC,MAAM,oBACE,CAAC,CAAC,KAAK,aACd,CAAC,CAAC,KAAK,KACjB,CAAC,CAAC,MAAM;8BAkCE,CAAC,CAAC,OAAO,YACV,MAAM,YACN,CAAC,CAAC,MAAM,KACjB,CAAC,CAAC,MAAM;+BAUC,CAAC,CAAC,MAAM,aACP,CAAC,CAAC,OAAO,YACV,MAAM,YACN,CAAC,CAAC,MAAM,KACjB,CAAC,CAAC,MAAM;mCAsCS,CAAC,CAAC,KAAK,mBACR,CAAC,CAAC,IAAI,eACV,CAAC,CAAC,KAAK,KACnB,CAAC,CAAC,MAAM;4BAGW,CAAC,CAAC,MAAM;8BACN,CAAC,CAAC,KAAK;6BACN,CAAC,CAAC,MAAM,KAAG,CAAC,CAAC,KAAK;4BASnB,CAAC,CAAC,MAAM,KAAG,CAAC,CAAC,KAAK;iCASb,CAAC,CAAC,MAAM,cAAc,MAAM,KAAG,CAAC,CAAC,IAAI;iCAGrC,CAAC,CAAC,MAAM,cAAc,MAAM,KAAG,CAAC,CAAC,IAAI;wBAGhD,CAAC,CAAC,KAAK;CAC1B,CAAC"}
|
package/dist/kernel32.js
DELETED
|
@@ -1,170 +0,0 @@
|
|
|
1
|
-
import { kernel } from './os/kernel';
|
|
2
|
-
// Constants
|
|
3
|
-
const PSEUDO_HANDLE_PROCESS = 0xffffffffffffffffn; // -1
|
|
4
|
-
const PSEUDO_HANDLE_THREAD = 0xfffffffffffffffen; // -2
|
|
5
|
-
export const Kernel32Impl = {
|
|
6
|
-
// Process
|
|
7
|
-
OpenProcess: (dwDesiredAccess, bInheritHandle, dwProcessId) => {
|
|
8
|
-
return kernel.OpenProcess(dwDesiredAccess, !!bInheritHandle, dwProcessId);
|
|
9
|
-
},
|
|
10
|
-
GetCurrentProcess: () => PSEUDO_HANDLE_PROCESS,
|
|
11
|
-
GetCurrentProcessId: () => kernel.currentProcess.id,
|
|
12
|
-
CloseHandle: (hObject) => {
|
|
13
|
-
if (hObject === PSEUDO_HANDLE_PROCESS || hObject === PSEUDO_HANDLE_THREAD) {
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
|
-
return kernel.CloseHandle(hObject) ? 1 : 0;
|
|
17
|
-
},
|
|
18
|
-
// Memory
|
|
19
|
-
ReadProcessMemory: (hProcess, lpBaseAddress, // bigint | number
|
|
20
|
-
lpBuffer, // LPVOID
|
|
21
|
-
nSize, // bigint | number
|
|
22
|
-
_lpNumberOfBytesRead) => {
|
|
23
|
-
let process;
|
|
24
|
-
if (hProcess === PSEUDO_HANDLE_PROCESS) {
|
|
25
|
-
process = kernel.currentProcess;
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const handleObj = kernel.getObjectFromHandle(hProcess);
|
|
29
|
-
if (handleObj && handleObj.type === 'Process') {
|
|
30
|
-
process = handleObj.object;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
if (!process)
|
|
34
|
-
return 0;
|
|
35
|
-
const addr = Number(lpBaseAddress);
|
|
36
|
-
const size = Number(nSize);
|
|
37
|
-
try {
|
|
38
|
-
const data = process.memory.read(addr, size);
|
|
39
|
-
data.copy(lpBuffer);
|
|
40
|
-
return 1;
|
|
41
|
-
}
|
|
42
|
-
catch (_e) {
|
|
43
|
-
return 0;
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
WriteProcessMemory: (hProcess, lpBaseAddress, lpBuffer, nSize, _lpNumberOfBytesWritten) => {
|
|
47
|
-
let process;
|
|
48
|
-
if (hProcess === PSEUDO_HANDLE_PROCESS) {
|
|
49
|
-
process = kernel.currentProcess;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const handleObj = kernel.getObjectFromHandle(hProcess);
|
|
53
|
-
if (handleObj && handleObj.type === 'Process') {
|
|
54
|
-
process = handleObj.object;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
if (!process)
|
|
58
|
-
return 0;
|
|
59
|
-
const addr = Number(lpBaseAddress);
|
|
60
|
-
// Ensure we only write nSize bytes essentially
|
|
61
|
-
const dataToWrite = lpBuffer.subarray(0, Number(nSize));
|
|
62
|
-
try {
|
|
63
|
-
if (process.memory.write(addr, dataToWrite) > 0) {
|
|
64
|
-
return 1;
|
|
65
|
-
}
|
|
66
|
-
return 0;
|
|
67
|
-
}
|
|
68
|
-
catch (_e) {
|
|
69
|
-
return 0;
|
|
70
|
-
}
|
|
71
|
-
},
|
|
72
|
-
VirtualAlloc: (lpAddress, dwSize, flAllocationType, flProtect) => {
|
|
73
|
-
return Kernel32Impl.VirtualAllocEx(PSEUDO_HANDLE_PROCESS, lpAddress, dwSize, flAllocationType, flProtect);
|
|
74
|
-
},
|
|
75
|
-
VirtualAllocEx: (hProcess, lpAddress, dwSize, flAllocationType, flProtect) => {
|
|
76
|
-
let process;
|
|
77
|
-
if (hProcess === PSEUDO_HANDLE_PROCESS) {
|
|
78
|
-
process = kernel.currentProcess;
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
const handleObj = kernel.getObjectFromHandle(hProcess);
|
|
82
|
-
if (handleObj && handleObj.type === 'Process') {
|
|
83
|
-
process = handleObj.object;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (!process)
|
|
87
|
-
return 0n;
|
|
88
|
-
const addr = Number(lpAddress);
|
|
89
|
-
const size = Number(dwSize);
|
|
90
|
-
// We assume flAllocationType and flProtect match our internal constants or we pass them through
|
|
91
|
-
// Our MemoryManager uses constants from constants.ts which match Win32
|
|
92
|
-
try {
|
|
93
|
-
const allocatedAddr = process.memory.allocate(addr, size, flAllocationType, flProtect);
|
|
94
|
-
return BigInt(allocatedAddr);
|
|
95
|
-
}
|
|
96
|
-
catch (_e) {
|
|
97
|
-
return 0n;
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
VirtualQuery: (lpAddress, lpBuffer, // PMEMORY_BASIC_INFORMATION
|
|
101
|
-
dwLength) => {
|
|
102
|
-
// Queries CURRENT process
|
|
103
|
-
return Kernel32Impl.VirtualQueryEx(PSEUDO_HANDLE_PROCESS, lpAddress, lpBuffer, dwLength);
|
|
104
|
-
},
|
|
105
|
-
VirtualQueryEx: (hProcess, lpAddress, lpBuffer, dwLength) => {
|
|
106
|
-
let process;
|
|
107
|
-
if (hProcess === PSEUDO_HANDLE_PROCESS) {
|
|
108
|
-
process = kernel.currentProcess;
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
const handleObj = kernel.getObjectFromHandle(hProcess);
|
|
112
|
-
if (handleObj && handleObj.type === 'Process') {
|
|
113
|
-
process = handleObj.object;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
if (!process)
|
|
117
|
-
return 0n;
|
|
118
|
-
const addr = Number(lpAddress);
|
|
119
|
-
const info = process.memory.query(addr);
|
|
120
|
-
// Serialize info to lpBuffer
|
|
121
|
-
// BaseAddress (0)
|
|
122
|
-
lpBuffer.writeBigUInt64LE(BigInt(info.BaseAddress), 0);
|
|
123
|
-
// AllocationBase (8)
|
|
124
|
-
lpBuffer.writeBigUInt64LE(BigInt(info.AllocationBase), 8);
|
|
125
|
-
// AllocationProtect (16)
|
|
126
|
-
lpBuffer.writeUInt32LE(info.AllocationProtect, 16);
|
|
127
|
-
// RegionSize (24)
|
|
128
|
-
lpBuffer.writeBigUInt64LE(BigInt(info.RegionSize), 24);
|
|
129
|
-
// State (32)
|
|
130
|
-
lpBuffer.writeUInt32LE(info.State, 32);
|
|
131
|
-
// Protect (36)
|
|
132
|
-
lpBuffer.writeUInt32LE(info.Protect, 36);
|
|
133
|
-
// Type (40)
|
|
134
|
-
lpBuffer.writeUInt32LE(info.Type, 40);
|
|
135
|
-
return BigInt(dwLength);
|
|
136
|
-
},
|
|
137
|
-
// Thread
|
|
138
|
-
OpenThread: (_dwDesiredAccess, _bInheritHandle, _dwThreadId) => {
|
|
139
|
-
return 0x200n;
|
|
140
|
-
},
|
|
141
|
-
GetCurrentThread: () => PSEUDO_HANDLE_THREAD,
|
|
142
|
-
GetCurrentThreadId: () => 98765,
|
|
143
|
-
SuspendThread: (hThread) => {
|
|
144
|
-
if (hThread === PSEUDO_HANDLE_THREAD)
|
|
145
|
-
return 0;
|
|
146
|
-
const handleObj = kernel.getObjectFromHandle(hThread);
|
|
147
|
-
if (handleObj && handleObj.type === 'Thread') {
|
|
148
|
-
// return (handleObj.object as SimulatedThread).suspend();
|
|
149
|
-
return 0; // SimulatedThread import might be cyclic or tricky, simplified for now
|
|
150
|
-
}
|
|
151
|
-
return 0; // Fail
|
|
152
|
-
},
|
|
153
|
-
ResumeThread: (hThread) => {
|
|
154
|
-
if (hThread === PSEUDO_HANDLE_THREAD)
|
|
155
|
-
return 0;
|
|
156
|
-
const handleObj = kernel.getObjectFromHandle(hThread);
|
|
157
|
-
if (handleObj && handleObj.type === 'Thread') {
|
|
158
|
-
// return (handleObj.object as SimulatedThread).resume();
|
|
159
|
-
return 0;
|
|
160
|
-
}
|
|
161
|
-
return 0;
|
|
162
|
-
},
|
|
163
|
-
GetThreadContext: (_hThread, _lpContext) => {
|
|
164
|
-
return 0;
|
|
165
|
-
},
|
|
166
|
-
SetThreadContext: (_hThread, _lpContext) => {
|
|
167
|
-
return 1;
|
|
168
|
-
},
|
|
169
|
-
GetLastError: () => 0,
|
|
170
|
-
};
|
package/dist/logger.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG,uCAAgC,CAAC"}
|
package/dist/os/handles.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import * as D from 'win32-def';
|
|
2
|
-
export interface ISimulatedObject {
|
|
3
|
-
id: number;
|
|
4
|
-
}
|
|
5
|
-
export interface HandleObject {
|
|
6
|
-
type: 'Process' | 'Thread' | 'File' | 'Event' | 'Unknown';
|
|
7
|
-
object: ISimulatedObject;
|
|
8
|
-
accessMask: number;
|
|
9
|
-
}
|
|
10
|
-
export declare class HandleTable {
|
|
11
|
-
private handles;
|
|
12
|
-
private nextHandleValue;
|
|
13
|
-
createHandle(object: ISimulatedObject, type: HandleObject['type'], accessMask: number): D.HANDLE;
|
|
14
|
-
getObject(handle: D.HANDLE): HandleObject | undefined;
|
|
15
|
-
closeHandle(handle: D.HANDLE): boolean;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=handles.d.ts.map
|
package/dist/os/handles.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"handles.d.ts","sourceRoot":"","sources":["../../src/os/handles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAE/B,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,SAAS,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IAC1D,MAAM,EAAE,gBAAgB,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,qBAAa,WAAW;IACtB,OAAO,CAAC,OAAO,CAAmC;IAClD,OAAO,CAAC,eAAe,CAAM;IAE7B,YAAY,CACV,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,YAAY,CAAC,MAAM,CAAC,EAC1B,UAAU,EAAE,MAAM,GACjB,CAAC,CAAC,MAAM;IAeX,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,YAAY,GAAG,SAAS;IAIrD,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,OAAO;CAGvC"}
|
package/dist/os/kernel.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SimulatedProcess } from './process';
|
|
2
|
-
import { HandleObject } from './handles';
|
|
3
|
-
import * as D from 'win32-def';
|
|
4
|
-
export declare class Kernel {
|
|
5
|
-
static instance: Kernel;
|
|
6
|
-
private processes;
|
|
7
|
-
private nextPid;
|
|
8
|
-
currentProcess: SimulatedProcess;
|
|
9
|
-
constructor();
|
|
10
|
-
private createSystemProcess;
|
|
11
|
-
createProcess(name: string): SimulatedProcess;
|
|
12
|
-
getProcess(pid: number): SimulatedProcess | undefined;
|
|
13
|
-
OpenProcess(dwDesiredAccess: number, bInheritHandle: boolean, dwProcessId: number): D.HANDLE;
|
|
14
|
-
CloseHandle(hObject: D.HANDLE): boolean;
|
|
15
|
-
getObjectFromHandle(handle: D.HANDLE): HandleObject | undefined;
|
|
16
|
-
}
|
|
17
|
-
export declare const kernel: Kernel;
|
|
18
|
-
//# sourceMappingURL=kernel.d.ts.map
|
package/dist/os/kernel.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kernel.d.ts","sourceRoot":"","sources":["../../src/os/kernel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,CAAC,MAAM,WAAW,CAAC;AAE/B,qBAAa,MAAM;IACjB,OAAc,QAAQ,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,SAAS,CAA4C;IAC7D,OAAO,CAAC,OAAO,CAAa;IAGrB,cAAc,EAAE,gBAAgB,CAAC;;IAaxC,OAAO,CAAC,mBAAmB;IAKpB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,gBAAgB;IAQ7C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS;IAMrD,WAAW,CAChB,eAAe,EAAE,MAAM,EACvB,cAAc,EAAE,OAAO,EACvB,WAAW,EAAE,MAAM,GAClB,CAAC,CAAC,MAAM;IAeJ,WAAW,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,GAAG,OAAO;IAKvC,mBAAmB,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,GAAG,YAAY,GAAG,SAAS;CAGvE;AAGD,eAAO,MAAM,MAAM,QAAe,CAAC"}
|
package/dist/os/memory.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../src/os/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAs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