jsilnet 0.1.0 → 0.2.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 +25 -6
- package/REFERENCE.md +4 -0
- package/dist/browser/index.js +345 -0
- package/dist/browser/worker.js +42480 -0
- package/package.json +23 -4
- package/src/assembly/instruction-editing.js +165 -0
- package/src/assembly/method-removal.js +789 -0
- package/src/assembly/pointer-table-editing.js +506 -0
- package/src/assembly/portable-pdb-editing.js +441 -0
- package/src/browser/index.d.ts +123 -0
- package/src/browser/index.js +373 -0
- package/src/browser/worker-runtime.js +287 -0
- package/src/browser/worker.js +47 -0
- package/src/index.d.ts +267 -0
- package/src/index.js +107 -1574
- package/src/metadata/portable-pdb.js +2 -2
- package/src/metadata/strong-name.js +84 -83
- package/src/pe/headers.js +1 -1
- package/src/platform/bytes.js +21 -0
- package/src/platform/compression.js +24 -0
- package/src/platform/crypto.js +17 -0
- package/src/types/assembly/instruction-editing.d.ts +33 -0
- package/src/types/assembly/method-removal.d.ts +3 -0
- package/src/types/assembly/pointer-table-editing.d.ts +3 -0
- package/src/types/assembly/portable-pdb-editing.d.ts +23 -0
- package/src/types/binary/errors.d.ts +7 -0
- package/src/types/binary/reader.d.ts +30 -0
- package/src/types/il/body.d.ts +51 -0
- package/src/types/il/instructions.d.ts +33 -0
- package/src/types/il/opcodes.d.ts +2 -0
- package/src/types/il/rewrite.d.ts +38 -0
- package/src/types/index.d.ts +864 -0
- package/src/types/metadata/classic-pdb.d.ts +688 -0
- package/src/types/metadata/custom-attributes.d.ts +28 -0
- package/src/types/metadata/portable-pdb.d.ts +296 -0
- package/src/types/metadata/resources.d.ts +1 -0
- package/src/types/metadata/root-writer.d.ts +1 -0
- package/src/types/metadata/signatures.d.ts +5 -0
- package/src/types/metadata/streams.d.ts +26 -0
- package/src/types/metadata/strong-name.d.ts +11 -0
- package/src/types/metadata/tables.d.ts +25 -0
- package/src/types/metadata/writer.d.ts +16 -0
- package/src/types/pe/headers.d.ts +160 -0
- package/src/types/platform/bytes.d.ts +3 -0
- package/src/types/platform/compression.d.ts +2 -0
- package/src/types/platform/crypto.d.ts +4 -0
- package/src/types/resolution/module.d.ts +12 -0
- package/src/types/writer/patch.d.ts +4 -0
- package/src/types/writer/pe.d.ts +9 -0
- package/src/types/writer/structural.d.ts +4 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { deflateRawSync, inflateRawSync } from "
|
|
2
|
-
import { createHash } from "
|
|
1
|
+
import { deflateRawSync, inflateRawSync } from "../platform/compression.js";
|
|
2
|
+
import { createHash } from "../platform/crypto.js";
|
|
3
3
|
import { BinaryReader, readCompressedInt, readCompressedUInt } from "../binary/reader.js";
|
|
4
4
|
import { FormatError, UnsupportedFormatError } from "../binary/errors.js";
|
|
5
5
|
import {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
createPrivateKey,
|
|
3
|
-
createPublicKey,
|
|
4
|
-
createSign,
|
|
5
|
-
createVerify
|
|
6
|
-
} from "node:crypto";
|
|
1
|
+
import forge from "node-forge";
|
|
7
2
|
import { FormatError, UnsupportedFormatError } from "../binary/errors.js";
|
|
3
|
+
import { binaryStringToBytes, bytesToBinaryString } from "../platform/bytes.js";
|
|
8
4
|
|
|
9
5
|
const rsaSignAlgorithm = 0x00002400;
|
|
10
6
|
const sha1Algorithm = 0x00008004;
|
|
@@ -26,74 +22,76 @@ export function getStrongNameHashName(algorithm) {
|
|
|
26
22
|
return name;
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw new UnsupportedFormatError("Strong-name RSA key does not expose its modulus length");
|
|
38
|
-
}
|
|
39
|
-
return key;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function getRsaJwk(key) {
|
|
43
|
-
const jwk = createPublicKey(key).export({ format: "jwk" });
|
|
44
|
-
if (!jwk.n || !jwk.e || jwk.kty !== "RSA") {
|
|
45
|
-
throw new UnsupportedFormatError("Strong-name key is not a usable RSA key");
|
|
46
|
-
}
|
|
47
|
-
return jwk;
|
|
25
|
+
function binaryIntegerBytes(value, length) {
|
|
26
|
+
let hex = value.toString(16);
|
|
27
|
+
if ((hex.length & 1) !== 0) hex = `0${hex}`;
|
|
28
|
+
const encoded = binaryStringToBytes(forge.util.hexToBytes(hex));
|
|
29
|
+
if (encoded.length > length) throw new FormatError("RSA integer exceeds its declared size");
|
|
30
|
+
const output = new Uint8Array(length);
|
|
31
|
+
output.set(encoded, length - encoded.length);
|
|
32
|
+
return output;
|
|
48
33
|
}
|
|
49
34
|
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
const encoded = Buffer.from(jwk.n, "base64url");
|
|
53
|
-
if (encoded.length > modulusLength) {
|
|
54
|
-
throw new FormatError("RSA modulus exceeds its declared bit length");
|
|
55
|
-
}
|
|
56
|
-
const modulus = Buffer.alloc(modulusLength);
|
|
57
|
-
encoded.copy(modulus, modulusLength - encoded.length);
|
|
58
|
-
return modulus;
|
|
35
|
+
function getRsaModulusBits(key) {
|
|
36
|
+
return key.n.bitLength();
|
|
59
37
|
}
|
|
60
38
|
|
|
61
|
-
function
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
39
|
+
export function importStrongNamePrivateKey(input) {
|
|
40
|
+
if (input && typeof input === "object" && input.n && input.e && input.d) return input;
|
|
41
|
+
let pem = input;
|
|
42
|
+
if (input && typeof input === "object" && input.type === "private" &&
|
|
43
|
+
typeof input.export === "function") {
|
|
44
|
+
if (input.asymmetricKeyType !== "rsa") {
|
|
45
|
+
throw new UnsupportedFormatError("Strong-name signing requires an RSA private key");
|
|
46
|
+
}
|
|
47
|
+
pem = input.export({ format: "pem", type: "pkcs8" });
|
|
48
|
+
} else if (input instanceof Uint8Array) {
|
|
49
|
+
pem = new TextDecoder("ascii", { fatal: true }).decode(input);
|
|
50
|
+
}
|
|
51
|
+
if (typeof pem !== "string") {
|
|
52
|
+
throw new UnsupportedFormatError("Strong-name signing requires an RSA PEM or private key");
|
|
53
|
+
}
|
|
54
|
+
const key = forge.pki.privateKeyFromPem(pem);
|
|
55
|
+
if (!key.n || !key.e || !key.d) {
|
|
56
|
+
throw new UnsupportedFormatError("Strong-name signing requires an RSA private key");
|
|
65
57
|
}
|
|
66
|
-
|
|
67
|
-
for (const byte of bytes) exponent = exponent * 256 + byte;
|
|
68
|
-
return exponent;
|
|
58
|
+
return key;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
|
-
export function encodeStrongNamePublicKey(
|
|
61
|
+
export function encodeStrongNamePublicKey(keyInput, hashAlgorithm) {
|
|
72
62
|
const hashName = getStrongNameHashName(hashAlgorithm);
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
const
|
|
76
|
-
const
|
|
63
|
+
const key = importStrongNamePrivateKey(keyInput);
|
|
64
|
+
const modulusBits = getRsaModulusBits(key);
|
|
65
|
+
const modulusLength = Math.ceil(modulusBits / 8);
|
|
66
|
+
const modulus = binaryIntegerBytes(key.n, modulusLength);
|
|
67
|
+
const exponent = Number(key.e.toString(10));
|
|
77
68
|
if (modulusBits % 8 !== 0) {
|
|
78
69
|
throw new UnsupportedFormatError("Strong-name RSA modulus length must be byte-aligned");
|
|
79
70
|
}
|
|
71
|
+
if (exponent < 3 || exponent % 2 === 0) {
|
|
72
|
+
throw new UnsupportedFormatError("Strong-name RSA public exponent is invalid");
|
|
73
|
+
}
|
|
80
74
|
|
|
81
|
-
const capiKey =
|
|
75
|
+
const capiKey = new Uint8Array(20 + modulus.length);
|
|
76
|
+
const capiView = new DataView(capiKey.buffer);
|
|
82
77
|
capiKey[0] = 0x06;
|
|
83
78
|
capiKey[1] = 0x02;
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
79
|
+
capiView.setUint32(4, rsaSignAlgorithm, true);
|
|
80
|
+
capiView.setUint32(8, 0x31415352, true);
|
|
81
|
+
capiView.setUint32(12, modulusBits, true);
|
|
82
|
+
capiView.setUint32(16, exponent, true);
|
|
83
|
+
for (let index = 0; index < modulus.length; index++) {
|
|
84
|
+
capiKey[20 + index] = modulus[modulus.length - 1 - index];
|
|
85
|
+
}
|
|
89
86
|
|
|
90
87
|
const hashAlgorithmId = [...hashNames].find(([, name]) => name === hashName)?.[0];
|
|
91
|
-
const publicKey =
|
|
92
|
-
publicKey.
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
88
|
+
const publicKey = new Uint8Array(12 + capiKey.length);
|
|
89
|
+
const publicKeyView = new DataView(publicKey.buffer);
|
|
90
|
+
publicKeyView.setUint32(0, rsaSignAlgorithm, true);
|
|
91
|
+
publicKeyView.setUint32(4, hashAlgorithmId, true);
|
|
92
|
+
publicKeyView.setUint32(8, capiKey.length, true);
|
|
93
|
+
publicKey.set(capiKey, 12);
|
|
94
|
+
return typeof Buffer === "undefined" ? publicKey : Buffer.from(publicKey);
|
|
97
95
|
}
|
|
98
96
|
|
|
99
97
|
export function decodeStrongNamePublicKey(bytes) {
|
|
@@ -120,20 +118,15 @@ export function decodeStrongNamePublicKey(bytes) {
|
|
|
120
118
|
publicKeySize !== 20 + modulusBits / 8 || exponent < 3 || exponent % 2 === 0) {
|
|
121
119
|
throw new FormatError("Strong-name CAPI RSA key has inconsistent dimensions");
|
|
122
120
|
}
|
|
123
|
-
const modulus =
|
|
121
|
+
const modulus = Uint8Array.from(bytes.subarray(32)).reverse();
|
|
124
122
|
if ((modulus[0] & 0x80) === 0) {
|
|
125
123
|
throw new FormatError("Strong-name RSA modulus does not match its declared bit length");
|
|
126
124
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
kty: "RSA",
|
|
133
|
-
n: modulus.toString("base64url"),
|
|
134
|
-
e: exponentBytes.subarray(exponentStart).toString("base64url")
|
|
135
|
-
};
|
|
136
|
-
const publicKey = createPublicKey({ key: jwk, format: "jwk" });
|
|
125
|
+
const modulusHex = forge.util.bytesToHex(bytesToBinaryString(modulus));
|
|
126
|
+
const publicKey = forge.pki.rsa.setPublicKey(
|
|
127
|
+
new forge.jsbn.BigInteger(modulusHex, 16),
|
|
128
|
+
new forge.jsbn.BigInteger(String(exponent), 10)
|
|
129
|
+
);
|
|
137
130
|
return {
|
|
138
131
|
publicKey,
|
|
139
132
|
hashAlgorithm,
|
|
@@ -171,29 +164,30 @@ function getStrongNameRanges(bytes, pe, cli) {
|
|
|
171
164
|
}
|
|
172
165
|
|
|
173
166
|
function updateStrongNameData(signer, bytes, pe, ranges) {
|
|
174
|
-
signer.update(
|
|
175
|
-
|
|
167
|
+
const update = (part) => signer.update(bytesToBinaryString(part));
|
|
168
|
+
update(bytes.subarray(0, pe.peOffset));
|
|
169
|
+
update(bytes.subarray(pe.peOffset, pe.peOffset + 24));
|
|
176
170
|
|
|
177
|
-
const optionalHeader =
|
|
171
|
+
const optionalHeader = Uint8Array.from(bytes.subarray(
|
|
178
172
|
pe.optionalHeaderOffset,
|
|
179
173
|
pe.optionalHeaderOffset + ranges.fixedOptionalHeaderSize
|
|
180
174
|
));
|
|
181
175
|
optionalHeader.fill(0, 64, 68);
|
|
182
|
-
|
|
176
|
+
update(optionalHeader);
|
|
183
177
|
|
|
184
178
|
const directoriesOffset = pe.optionalHeaderOffset + ranges.fixedOptionalHeaderSize;
|
|
185
|
-
const directories =
|
|
179
|
+
const directories = Uint8Array.from(bytes.subarray(directoriesOffset, directoriesOffset + 16 * 8));
|
|
186
180
|
directories.fill(0, 4 * 8, 5 * 8);
|
|
187
|
-
|
|
188
|
-
|
|
181
|
+
update(directories);
|
|
182
|
+
update(bytes.subarray(pe.sectionOffset, pe.sectionOffset + pe.sectionCount * 40));
|
|
189
183
|
|
|
190
184
|
for (const section of pe.sections) {
|
|
191
185
|
const start = section.rawPointer;
|
|
192
186
|
const end = start + section.rawSize;
|
|
193
187
|
const beforeEnd = Math.min(end, ranges.signatureOffset);
|
|
194
|
-
if (start < beforeEnd)
|
|
188
|
+
if (start < beforeEnd) update(bytes.subarray(start, beforeEnd));
|
|
195
189
|
const afterStart = Math.max(start, ranges.signatureEnd);
|
|
196
|
-
if (afterStart < end)
|
|
190
|
+
if (afterStart < end) update(bytes.subarray(afterStart, end));
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
193
|
|
|
@@ -204,9 +198,9 @@ export function signStrongNameImage(bytes, pe, cli, privateKey, hashAlgorithm) {
|
|
|
204
198
|
const view = new DataView(output.buffer, output.byteOffset, output.byteLength);
|
|
205
199
|
view.setUint32(cli.strongNameFlagOffset, cli.flags | 0x08, true);
|
|
206
200
|
|
|
207
|
-
const signer =
|
|
201
|
+
const signer = forge.md[hashName].create();
|
|
208
202
|
updateStrongNameData(signer, output, pe, ranges);
|
|
209
|
-
const signature =
|
|
203
|
+
const signature = binaryStringToBytes(privateKey.sign(signer)).reverse();
|
|
210
204
|
if (signature.length !== cli.strongNameSignature.size) {
|
|
211
205
|
throw new FormatError(
|
|
212
206
|
`Strong-name signature size ${signature.length} does not match reserved slot ${cli.strongNameSignature.size}`
|
|
@@ -222,8 +216,15 @@ export function verifyStrongNameImage(bytes, pe, cli, publicKeyBytes, hashAlgori
|
|
|
222
216
|
const hashName = getStrongNameHashName(hashAlgorithm || key.hashAlgorithm);
|
|
223
217
|
if (cli.strongNameSignature.size !== key.signatureSize) return false;
|
|
224
218
|
const ranges = getStrongNameRanges(bytes, pe, cli);
|
|
225
|
-
const signature =
|
|
226
|
-
|
|
219
|
+
const signature = bytesToBinaryString(
|
|
220
|
+
Uint8Array.from(bytes.subarray(ranges.signatureOffset, ranges.signatureEnd)).reverse()
|
|
221
|
+
);
|
|
222
|
+
const verifier = forge.md[hashName].create();
|
|
227
223
|
updateStrongNameData(verifier, bytes, pe, ranges);
|
|
228
|
-
|
|
224
|
+
try {
|
|
225
|
+
return key.publicKey.verify(verifier.digest().getBytes(), signature);
|
|
226
|
+
} catch (error) {
|
|
227
|
+
if (error instanceof Error && error.message === "Encryption block is invalid.") return false;
|
|
228
|
+
throw error;
|
|
229
|
+
}
|
|
229
230
|
}
|
package/src/pe/headers.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inflateRawSync } from "
|
|
1
|
+
import { inflateRawSync } from "../platform/compression.js";
|
|
2
2
|
import { BinaryReader } from "../binary/reader.js";
|
|
3
3
|
import { FormatError, UnsupportedFormatError } from "../binary/errors.js";
|
|
4
4
|
import { MetadataHeaps, parseMetadataRoot } from "../metadata/streams.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function bytesToBinaryString(bytes) {
|
|
2
|
+
const chunks = [];
|
|
3
|
+
const chunkSize = 0x8000;
|
|
4
|
+
for (let offset = 0; offset < bytes.length; offset += chunkSize) {
|
|
5
|
+
chunks.push(String.fromCharCode(...bytes.subarray(offset, offset + chunkSize)));
|
|
6
|
+
}
|
|
7
|
+
return chunks.join("");
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function binaryStringToBytes(value) {
|
|
11
|
+
const bytes = new Uint8Array(value.length);
|
|
12
|
+
for (let index = 0; index < value.length; index++) bytes[index] = value.charCodeAt(index);
|
|
13
|
+
return bytes;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function equalBytes(left, right) {
|
|
17
|
+
if (left.length !== right.length) return false;
|
|
18
|
+
let difference = 0;
|
|
19
|
+
for (let index = 0; index < left.length; index++) difference |= left[index] ^ right[index];
|
|
20
|
+
return difference === 0;
|
|
21
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { deflateSync, inflateSync } from "fflate";
|
|
2
|
+
|
|
3
|
+
export function deflateRawSync(bytes) {
|
|
4
|
+
return deflateSync(bytes);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function inflateRawSync(bytes, options = {}) {
|
|
8
|
+
const { maxOutputLength } = options;
|
|
9
|
+
if (maxOutputLength === undefined) return inflateSync(bytes);
|
|
10
|
+
if (!Number.isSafeInteger(maxOutputLength) || maxOutputLength < 0 ||
|
|
11
|
+
maxOutputLength === Number.MAX_SAFE_INTEGER) {
|
|
12
|
+
throw new RangeError("maxOutputLength must be a nonnegative safe integer");
|
|
13
|
+
}
|
|
14
|
+
const maximum = maxOutputLength + 1;
|
|
15
|
+
let capacity = Math.min(maximum, 0x10000);
|
|
16
|
+
while (true) {
|
|
17
|
+
const output = inflateSync(bytes, { out: new Uint8Array(capacity) });
|
|
18
|
+
if (output.length < capacity) return output;
|
|
19
|
+
if (capacity === maximum) {
|
|
20
|
+
throw new RangeError(`Decompressed data exceeds ${maxOutputLength} bytes`);
|
|
21
|
+
}
|
|
22
|
+
capacity = Math.min(maximum, capacity * 2);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import forge from "node-forge";
|
|
2
|
+
import { binaryStringToBytes, bytesToBinaryString } from "./bytes.js";
|
|
3
|
+
|
|
4
|
+
export function createHash(name) {
|
|
5
|
+
const factory = forge.md[name];
|
|
6
|
+
if (!factory) throw new RangeError(`Unsupported hash algorithm ${name}`);
|
|
7
|
+
const digest = factory.create();
|
|
8
|
+
return {
|
|
9
|
+
update(bytes) {
|
|
10
|
+
digest.update(bytesToBinaryString(bytes));
|
|
11
|
+
return this;
|
|
12
|
+
},
|
|
13
|
+
digest() {
|
|
14
|
+
return binaryStringToBytes(digest.digest().getBytes());
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function createInstructionEditor(assembly: any, hooks: any): {
|
|
2
|
+
setInstructionOperand(methodRid: any, instructionOffset: any, value: any): any;
|
|
3
|
+
setInstructionOpcode(methodRid: any, instructionOffset: any, opcodeNameOrCode: any): any;
|
|
4
|
+
insertInstruction(methodRid: any, beforeOffset: any, opcodeNameOrCode: any, operand: any): {
|
|
5
|
+
opcode: any;
|
|
6
|
+
operand: {
|
|
7
|
+
kind: string;
|
|
8
|
+
targetOffset: any;
|
|
9
|
+
targetOffsets?: undefined;
|
|
10
|
+
value?: undefined;
|
|
11
|
+
} | {
|
|
12
|
+
kind: string;
|
|
13
|
+
targetOffsets: any[];
|
|
14
|
+
targetOffset?: undefined;
|
|
15
|
+
value?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
kind: any;
|
|
18
|
+
value: any;
|
|
19
|
+
targetOffset?: undefined;
|
|
20
|
+
targetOffsets?: undefined;
|
|
21
|
+
};
|
|
22
|
+
offset: number;
|
|
23
|
+
size: any;
|
|
24
|
+
opcodeSize: number;
|
|
25
|
+
opcodeOffset: any;
|
|
26
|
+
operandOffset: any;
|
|
27
|
+
patchOffsets: any[];
|
|
28
|
+
originalOffset: any;
|
|
29
|
+
isNew: boolean;
|
|
30
|
+
};
|
|
31
|
+
removeInstruction(methodRid: any, instructionOffset: any): any;
|
|
32
|
+
setMethodMaxStack(methodRid: any, maxStack: any): any;
|
|
33
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function createPortablePdbEditor(hooks: any): {
|
|
2
|
+
addEmbeddedPortablePdbDocument(debugEntryIndex: any, name: any, options: any): any;
|
|
3
|
+
insertEmbeddedPortablePdbDocument(debugEntryIndex: any, options: any): any;
|
|
4
|
+
addEmbeddedPortablePdbTypeDefinitionDocuments(debugEntryIndex: any, typeRid: any, documentRids: any): any;
|
|
5
|
+
removeEmbeddedPortablePdbDocument(debugEntryIndex: any, documentRid: any): any;
|
|
6
|
+
replaceEmbeddedPortablePdbTypeDefinitionDocuments(debugEntryIndex: any, typeRid: any, documentRids: any): any;
|
|
7
|
+
replaceEmbeddedPortablePdbDocumentMetadata(debugEntryIndex: any, documentRid: any, options: any): any;
|
|
8
|
+
replaceEmbeddedPortablePdbDocumentName(debugEntryIndex: any, documentRid: any, name: any, separator: any): any;
|
|
9
|
+
replaceEmbeddedPortablePdbSequencePoints(debugEntryIndex: any, methodRid: any, sequencePoints: any): any;
|
|
10
|
+
replaceEmbeddedPortablePdbMethodDocument(debugEntryIndex: any, methodRid: any, documentRid: any): any;
|
|
11
|
+
replaceEmbeddedPortablePdbImportScope(debugEntryIndex: any, importScopeRid: any, options: any): any;
|
|
12
|
+
replaceEmbeddedPortablePdbLocalScope(debugEntryIndex: any, localScopeRid: any, options: any): any;
|
|
13
|
+
replaceEmbeddedPortablePdbLocalVariable(debugEntryIndex: any, localVariableRid: any, options: any): any;
|
|
14
|
+
replaceEmbeddedPortablePdbLocalConstant(debugEntryIndex: any, localConstantRid: any, options: any): any;
|
|
15
|
+
replaceEmbeddedPortablePdbCustomDebugInformation(debugEntryIndex: any, customDebugInformationRid: any, value: any): any;
|
|
16
|
+
replaceEmbeddedPortablePdbSource(debugEntryIndex: any, documentRid: any, source: any, options: any): any;
|
|
17
|
+
addEmbeddedPortablePdbSource(debugEntryIndex: any, documentRid: any, source: any, options: any): any;
|
|
18
|
+
removeEmbeddedPortablePdbSource(debugEntryIndex: any, documentRid: any): any;
|
|
19
|
+
removeEmbeddedPortablePdbCustomDebugInformation(debugEntryIndex: any, recordRid: any): any;
|
|
20
|
+
replaceEmbeddedPortablePdbSourceLink(debugEntryIndex: any, sourceLink: any): any;
|
|
21
|
+
removeEmbeddedPortablePdbSourceLink(debugEntryIndex: any): any;
|
|
22
|
+
addEmbeddedPortablePdbSourceLink(debugEntryIndex: any, sourceLink: any): any;
|
|
23
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export function readCompressedUInt(reader: any): any;
|
|
2
|
+
export function readCompressedInt(reader: any): number;
|
|
3
|
+
export class BinaryReader {
|
|
4
|
+
constructor(input: any, { start, length, baseOffset, context }?: {
|
|
5
|
+
start?: number;
|
|
6
|
+
baseOffset?: number;
|
|
7
|
+
});
|
|
8
|
+
bytes: Uint8Array<any>;
|
|
9
|
+
view: DataView<any>;
|
|
10
|
+
baseOffset: number;
|
|
11
|
+
context: any;
|
|
12
|
+
position: number;
|
|
13
|
+
get remaining(): number;
|
|
14
|
+
get absoluteOffset(): number;
|
|
15
|
+
ensure(size: any): void;
|
|
16
|
+
seek(position: any): void;
|
|
17
|
+
skip(size: any): void;
|
|
18
|
+
align(alignment: any): void;
|
|
19
|
+
u1(): number;
|
|
20
|
+
i1(): number;
|
|
21
|
+
u2(): number;
|
|
22
|
+
i2(): number;
|
|
23
|
+
u4(): number;
|
|
24
|
+
i4(): number;
|
|
25
|
+
u8(): bigint;
|
|
26
|
+
f4(): number;
|
|
27
|
+
f8(): number;
|
|
28
|
+
take(size: any): Uint8Array<any>;
|
|
29
|
+
slice(size: any, context?: any): BinaryReader;
|
|
30
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export function parseMethodBody(input: any, fileOffset: any, methodRva?: any): {
|
|
2
|
+
format: string;
|
|
3
|
+
flags: number;
|
|
4
|
+
maxStack: number;
|
|
5
|
+
codeSize: number;
|
|
6
|
+
localVarSigToken: number;
|
|
7
|
+
headerOffset: any;
|
|
8
|
+
headerSize: number;
|
|
9
|
+
codeOffset: any;
|
|
10
|
+
endOffset: any;
|
|
11
|
+
instructions: {
|
|
12
|
+
opcode: any;
|
|
13
|
+
offset: number;
|
|
14
|
+
size: number;
|
|
15
|
+
opcodeOffset: number;
|
|
16
|
+
opcodeSize: number;
|
|
17
|
+
operandOffset: number;
|
|
18
|
+
patchOffsets: any[];
|
|
19
|
+
operand: {
|
|
20
|
+
kind: string;
|
|
21
|
+
targetOffset: number;
|
|
22
|
+
targetOffsets?: undefined;
|
|
23
|
+
value?: undefined;
|
|
24
|
+
} | {
|
|
25
|
+
kind: string;
|
|
26
|
+
targetOffsets: number[];
|
|
27
|
+
targetOffset?: undefined;
|
|
28
|
+
value?: undefined;
|
|
29
|
+
} | {
|
|
30
|
+
kind: any;
|
|
31
|
+
value: any;
|
|
32
|
+
targetOffset?: undefined;
|
|
33
|
+
targetOffsets?: undefined;
|
|
34
|
+
};
|
|
35
|
+
}[];
|
|
36
|
+
sections: {
|
|
37
|
+
offset: any;
|
|
38
|
+
rva: any;
|
|
39
|
+
size: number;
|
|
40
|
+
fat: boolean;
|
|
41
|
+
moreSections: boolean;
|
|
42
|
+
clauses: {
|
|
43
|
+
flags: number;
|
|
44
|
+
tryOffset: number;
|
|
45
|
+
tryLength: number;
|
|
46
|
+
handlerOffset: number;
|
|
47
|
+
handlerLength: number;
|
|
48
|
+
classTokenOrFilterOffset: number;
|
|
49
|
+
}[];
|
|
50
|
+
}[];
|
|
51
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function decodeInstructions(input: any, { baseOffset, ilOffset }?: {
|
|
2
|
+
baseOffset?: number;
|
|
3
|
+
ilOffset?: number;
|
|
4
|
+
}): {
|
|
5
|
+
opcode: any;
|
|
6
|
+
offset: number;
|
|
7
|
+
size: number;
|
|
8
|
+
opcodeOffset: number;
|
|
9
|
+
opcodeSize: number;
|
|
10
|
+
operandOffset: number;
|
|
11
|
+
patchOffsets: any[];
|
|
12
|
+
operand: {
|
|
13
|
+
kind: string;
|
|
14
|
+
targetOffset: number;
|
|
15
|
+
targetOffsets?: undefined;
|
|
16
|
+
value?: undefined;
|
|
17
|
+
} | {
|
|
18
|
+
kind: string;
|
|
19
|
+
targetOffsets: number[];
|
|
20
|
+
targetOffset?: undefined;
|
|
21
|
+
value?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
kind: any;
|
|
24
|
+
value: any;
|
|
25
|
+
targetOffset?: undefined;
|
|
26
|
+
targetOffsets?: undefined;
|
|
27
|
+
};
|
|
28
|
+
}[];
|
|
29
|
+
export function encodeOpcode(opcode: any): Uint8Array<ArrayBuffer>;
|
|
30
|
+
export function getInstructionSize(opcode: any, operand: any): any;
|
|
31
|
+
export function encodeInstruction(instruction: any): Uint8Array<any>;
|
|
32
|
+
export function formatInstruction(instruction: any): string;
|
|
33
|
+
export function encodeOperand(instruction: any, value: any): Uint8Array<any>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export function createStructuralState(body: any): {
|
|
2
|
+
body: any;
|
|
3
|
+
instructions: any;
|
|
4
|
+
branchTargets: Map<any, any>;
|
|
5
|
+
clauses: any[];
|
|
6
|
+
maxStack: any;
|
|
7
|
+
};
|
|
8
|
+
export function layoutStructuralState(state: any): any;
|
|
9
|
+
export function insertInstruction(state: any, beforeOffset: any, opcode: any, value: any): {
|
|
10
|
+
opcode: any;
|
|
11
|
+
operand: {
|
|
12
|
+
kind: string;
|
|
13
|
+
targetOffset: any;
|
|
14
|
+
targetOffsets?: undefined;
|
|
15
|
+
value?: undefined;
|
|
16
|
+
} | {
|
|
17
|
+
kind: string;
|
|
18
|
+
targetOffsets: any[];
|
|
19
|
+
targetOffset?: undefined;
|
|
20
|
+
value?: undefined;
|
|
21
|
+
} | {
|
|
22
|
+
kind: any;
|
|
23
|
+
value: any;
|
|
24
|
+
targetOffset?: undefined;
|
|
25
|
+
targetOffsets?: undefined;
|
|
26
|
+
};
|
|
27
|
+
offset: number;
|
|
28
|
+
size: any;
|
|
29
|
+
opcodeSize: number;
|
|
30
|
+
opcodeOffset: any;
|
|
31
|
+
operandOffset: any;
|
|
32
|
+
patchOffsets: any[];
|
|
33
|
+
originalOffset: any;
|
|
34
|
+
isNew: boolean;
|
|
35
|
+
};
|
|
36
|
+
export function removeInstruction(state: any, offset: any): any;
|
|
37
|
+
export function updateStructuralOperand(state: any, instruction: any, value: any): void;
|
|
38
|
+
export function encodeMethodBody(state: any, methodRva: any): Uint8Array<ArrayBuffer>;
|