frida-fs 5.2.5 → 7.0.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/dist/index.d.ts +17 -21
- package/dist/index.js +52 -41
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
-
/// <reference types="frida-gum" />
|
|
4
|
-
/// <reference types="node" resolution-mode="require"/>
|
|
5
1
|
import { Buffer } from "buffer";
|
|
6
2
|
import stream from "stream";
|
|
7
3
|
declare const constants: {
|
|
@@ -68,14 +64,14 @@ declare class Stats {
|
|
|
68
64
|
type AsyncCallback<T> = (error: Error | null, result?: T) => void;
|
|
69
65
|
export declare function createReadStream(path: string): ReadStream;
|
|
70
66
|
export declare function createWriteStream(path: string): WriteStream;
|
|
71
|
-
export declare const readdir: (
|
|
72
|
-
export declare const readFile: (
|
|
73
|
-
export declare const writeFile: (
|
|
74
|
-
export declare const readlink: (
|
|
75
|
-
export declare const rmdir: (
|
|
76
|
-
export declare const unlink: (
|
|
77
|
-
export declare const stat: (
|
|
78
|
-
export declare const lstat: (
|
|
67
|
+
export declare const readdir: (path: string, args_1: AsyncCallback<string[]>) => void;
|
|
68
|
+
export declare const readFile: (path: string, options: ReadFileOptions | undefined, args_2: AsyncCallback<string | Buffer<ArrayBufferLike>>) => void;
|
|
69
|
+
export declare const writeFile: (path: string, data: string | NodeJS.ArrayBufferView<ArrayBufferLike>, options: WriteFileOptions | undefined, args_3: AsyncCallback<void>) => void;
|
|
70
|
+
export declare const readlink: (path: string, args_1: AsyncCallback<string>) => void;
|
|
71
|
+
export declare const rmdir: (path: string, args_1: AsyncCallback<void>) => void;
|
|
72
|
+
export declare const unlink: (path: string, args_1: AsyncCallback<void>) => void;
|
|
73
|
+
export declare const stat: (path: string, args_1: AsyncCallback<Stats>) => void;
|
|
74
|
+
export declare const lstat: (path: string, args_1: AsyncCallback<Stats>) => void;
|
|
79
75
|
export { constants, readdirSync, list, readFileSync, writeFileSync, readlinkSync, rmdirSync, unlinkSync, statSync, lstatSync, Stats, };
|
|
80
76
|
declare const _default: {
|
|
81
77
|
constants: {
|
|
@@ -83,22 +79,22 @@ declare const _default: {
|
|
|
83
79
|
};
|
|
84
80
|
createReadStream: typeof createReadStream;
|
|
85
81
|
createWriteStream: typeof createWriteStream;
|
|
86
|
-
readdir: (
|
|
82
|
+
readdir: (path: string, args_1: AsyncCallback<string[]>) => void;
|
|
87
83
|
readdirSync: typeof readdirSync;
|
|
88
84
|
list: typeof list;
|
|
89
|
-
readFile: (
|
|
90
|
-
readFileSync: (path: string, options?: ReadFileOptions
|
|
91
|
-
writeFile: (
|
|
85
|
+
readFile: (path: string, options: ReadFileOptions | undefined, args_2: AsyncCallback<string | Buffer<ArrayBufferLike>>) => void;
|
|
86
|
+
readFileSync: (path: string, options?: ReadFileOptions) => string | Buffer;
|
|
87
|
+
writeFile: (path: string, data: string | NodeJS.ArrayBufferView<ArrayBufferLike>, options: WriteFileOptions | undefined, args_3: AsyncCallback<void>) => void;
|
|
92
88
|
writeFileSync: typeof writeFileSync;
|
|
93
|
-
readlink: (
|
|
89
|
+
readlink: (path: string, args_1: AsyncCallback<string>) => void;
|
|
94
90
|
readlinkSync: (path: string) => string;
|
|
95
|
-
rmdir: (
|
|
91
|
+
rmdir: (path: string, args_1: AsyncCallback<void>) => void;
|
|
96
92
|
rmdirSync: (path: string) => void;
|
|
97
|
-
unlink: (
|
|
93
|
+
unlink: (path: string, args_1: AsyncCallback<void>) => void;
|
|
98
94
|
unlinkSync: (path: string) => void;
|
|
99
|
-
stat: (
|
|
95
|
+
stat: (path: string, args_1: AsyncCallback<Stats>) => void;
|
|
100
96
|
statSync: (path: string) => Stats;
|
|
101
|
-
lstat: (
|
|
97
|
+
lstat: (path: string, args_1: AsyncCallback<Stats>) => void;
|
|
102
98
|
lstatSync: (path: string) => Stats;
|
|
103
99
|
Stats: typeof Stats;
|
|
104
100
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
-
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
-
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
-
};
|
|
7
|
-
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
-
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
-
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
-
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
-
};
|
|
12
|
-
var _ReadStream_input, _ReadStream_readRequest, _WriteStream_output, _WriteStream_writeRequest;
|
|
13
1
|
import { Buffer } from "buffer";
|
|
14
2
|
import fsPath from "path";
|
|
15
3
|
import process from "process";
|
|
@@ -119,12 +107,12 @@ const SEEK_CUR = 1;
|
|
|
119
107
|
const SEEK_END = 2;
|
|
120
108
|
const EINTR = 4;
|
|
121
109
|
class ReadStream extends stream.Readable {
|
|
110
|
+
#input = null;
|
|
111
|
+
#readRequest = null;
|
|
122
112
|
constructor(path) {
|
|
123
113
|
super({
|
|
124
114
|
highWaterMark: 4 * 1024 * 1024
|
|
125
115
|
});
|
|
126
|
-
_ReadStream_input.set(this, null);
|
|
127
|
-
_ReadStream_readRequest.set(this, null);
|
|
128
116
|
if (isWindows) {
|
|
129
117
|
const api = getWindowsApi();
|
|
130
118
|
const result = api.CreateFileW(Memory.allocUtf16String(path), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL);
|
|
@@ -135,7 +123,7 @@ class ReadStream extends stream.Readable {
|
|
|
135
123
|
});
|
|
136
124
|
return;
|
|
137
125
|
}
|
|
138
|
-
|
|
126
|
+
this.#input = new Win32InputStream(handle, { autoClose: true });
|
|
139
127
|
}
|
|
140
128
|
else {
|
|
141
129
|
const api = getPosixApi();
|
|
@@ -147,20 +135,20 @@ class ReadStream extends stream.Readable {
|
|
|
147
135
|
});
|
|
148
136
|
return;
|
|
149
137
|
}
|
|
150
|
-
|
|
138
|
+
this.#input = new UnixInputStream(fd, { autoClose: true });
|
|
151
139
|
}
|
|
152
140
|
}
|
|
153
141
|
_destroy(error, callback) {
|
|
154
|
-
|
|
155
|
-
|
|
142
|
+
this.#input?.close();
|
|
143
|
+
this.#input = null;
|
|
156
144
|
callback(error);
|
|
157
145
|
}
|
|
158
146
|
_read(size) {
|
|
159
|
-
if (
|
|
147
|
+
if (this.#readRequest !== null)
|
|
160
148
|
return;
|
|
161
|
-
|
|
149
|
+
this.#readRequest = this.#input.read(size)
|
|
162
150
|
.then(buffer => {
|
|
163
|
-
|
|
151
|
+
this.#readRequest = null;
|
|
164
152
|
if (buffer.byteLength === 0) {
|
|
165
153
|
this.push(null);
|
|
166
154
|
return;
|
|
@@ -169,19 +157,18 @@ class ReadStream extends stream.Readable {
|
|
|
169
157
|
this._read(size);
|
|
170
158
|
})
|
|
171
159
|
.catch(error => {
|
|
172
|
-
|
|
160
|
+
this.#readRequest = null;
|
|
173
161
|
this.destroy(error);
|
|
174
|
-
})
|
|
162
|
+
});
|
|
175
163
|
}
|
|
176
164
|
}
|
|
177
|
-
_ReadStream_input = new WeakMap(), _ReadStream_readRequest = new WeakMap();
|
|
178
165
|
class WriteStream extends stream.Writable {
|
|
166
|
+
#output = null;
|
|
167
|
+
#writeRequest = null;
|
|
179
168
|
constructor(path) {
|
|
180
169
|
super({
|
|
181
170
|
highWaterMark: 4 * 1024 * 1024
|
|
182
171
|
});
|
|
183
|
-
_WriteStream_output.set(this, null);
|
|
184
|
-
_WriteStream_writeRequest.set(this, null);
|
|
185
172
|
if (isWindows) {
|
|
186
173
|
const api = getWindowsApi();
|
|
187
174
|
const result = api.CreateFileW(Memory.allocUtf16String(path), GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED, NULL);
|
|
@@ -192,7 +179,7 @@ class WriteStream extends stream.Writable {
|
|
|
192
179
|
});
|
|
193
180
|
return;
|
|
194
181
|
}
|
|
195
|
-
|
|
182
|
+
this.#output = new Win32OutputStream(handle, { autoClose: true });
|
|
196
183
|
}
|
|
197
184
|
else {
|
|
198
185
|
const api = getPosixApi();
|
|
@@ -207,29 +194,28 @@ class WriteStream extends stream.Writable {
|
|
|
207
194
|
});
|
|
208
195
|
return;
|
|
209
196
|
}
|
|
210
|
-
|
|
197
|
+
this.#output = new UnixOutputStream(fd, { autoClose: true });
|
|
211
198
|
}
|
|
212
199
|
}
|
|
213
200
|
_destroy(error, callback) {
|
|
214
|
-
|
|
215
|
-
|
|
201
|
+
this.#output?.close();
|
|
202
|
+
this.#output = null;
|
|
216
203
|
callback(error);
|
|
217
204
|
}
|
|
218
205
|
_write(chunk, encoding, callback) {
|
|
219
|
-
if (
|
|
206
|
+
if (this.#writeRequest !== null)
|
|
220
207
|
return;
|
|
221
|
-
|
|
208
|
+
this.#writeRequest = this.#output.writeAll(chunk)
|
|
222
209
|
.then(size => {
|
|
223
|
-
|
|
210
|
+
this.#writeRequest = null;
|
|
224
211
|
callback();
|
|
225
212
|
})
|
|
226
213
|
.catch(error => {
|
|
227
|
-
|
|
214
|
+
this.#writeRequest = null;
|
|
228
215
|
callback(error);
|
|
229
|
-
})
|
|
216
|
+
});
|
|
230
217
|
}
|
|
231
218
|
}
|
|
232
|
-
_WriteStream_output = new WeakMap(), _WriteStream_writeRequest = new WeakMap();
|
|
233
219
|
const windowsBackend = {
|
|
234
220
|
enumerateDirectoryEntries(path, callback) {
|
|
235
221
|
enumerateWindowsDirectoryEntriesMatching(path + "\\*", callback);
|
|
@@ -728,6 +714,25 @@ function getStatSpec() {
|
|
|
728
714
|
return statSpec;
|
|
729
715
|
}
|
|
730
716
|
class Stats {
|
|
717
|
+
dev;
|
|
718
|
+
mode;
|
|
719
|
+
nlink;
|
|
720
|
+
uid;
|
|
721
|
+
gid;
|
|
722
|
+
rdev;
|
|
723
|
+
blksize;
|
|
724
|
+
ino;
|
|
725
|
+
size;
|
|
726
|
+
blocks;
|
|
727
|
+
atimeMs;
|
|
728
|
+
mtimeMs;
|
|
729
|
+
ctimeMs;
|
|
730
|
+
birthtimeMs;
|
|
731
|
+
atime;
|
|
732
|
+
mtime;
|
|
733
|
+
ctime;
|
|
734
|
+
birthtime;
|
|
735
|
+
buffer;
|
|
731
736
|
isFile() {
|
|
732
737
|
return (this.mode & S_IFMT) === S_IFREG;
|
|
733
738
|
}
|
|
@@ -770,10 +775,13 @@ function makeStatsProxy(path, buf) {
|
|
|
770
775
|
return receiver;
|
|
771
776
|
case "buffer":
|
|
772
777
|
return buf;
|
|
773
|
-
default:
|
|
774
|
-
|
|
775
|
-
|
|
778
|
+
default: {
|
|
779
|
+
let val;
|
|
780
|
+
if (typeof property === "symbol" || (val = target[property]) !== undefined) {
|
|
781
|
+
return val;
|
|
782
|
+
}
|
|
776
783
|
return statsReadField.call(receiver, property, path);
|
|
784
|
+
}
|
|
777
785
|
}
|
|
778
786
|
},
|
|
779
787
|
set(target, property, value, receiver) {
|
|
@@ -956,6 +964,7 @@ function makeApi(spec) {
|
|
|
956
964
|
return api;
|
|
957
965
|
}, {});
|
|
958
966
|
}
|
|
967
|
+
let kernel32 = null;
|
|
959
968
|
const nativeOpts = (isWindows && pointerSize === 4) ? { abi: "stdcall" } : {};
|
|
960
969
|
function addApiPlaceholder(api, entry) {
|
|
961
970
|
const [name] = entry;
|
|
@@ -963,10 +972,12 @@ function addApiPlaceholder(api, entry) {
|
|
|
963
972
|
configurable: true,
|
|
964
973
|
get() {
|
|
965
974
|
const [, Ctor, retType, argTypes, wrapper] = entry;
|
|
975
|
+
if (isWindows && kernel32 === null)
|
|
976
|
+
kernel32 = Process.getModuleByName("kernel32.dll");
|
|
966
977
|
let impl = null;
|
|
967
978
|
const address = isWindows
|
|
968
|
-
?
|
|
969
|
-
: Module.
|
|
979
|
+
? kernel32.findExportByName(name)
|
|
980
|
+
: Module.findGlobalExportByName(name);
|
|
970
981
|
if (address !== null)
|
|
971
982
|
impl = new Ctor(address, retType, argTypes, nativeOpts);
|
|
972
983
|
if (wrapper !== undefined)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "frida-fs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Create a stream from a filesystem resource",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/nowsecure/frida-fs#readme",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@types/frida-gum": "^
|
|
27
|
-
"@types/node": "^
|
|
28
|
-
"typescript": "^5.
|
|
26
|
+
"@types/frida-gum": "^19.0.0",
|
|
27
|
+
"@types/node": "^18.15.3",
|
|
28
|
+
"typescript": "^5.8.3"
|
|
29
29
|
}
|
|
30
30
|
}
|