@orkestrel/sea 0.0.26 → 0.0.27
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/server/index.cjs +17 -18
- package/dist/src/server/index.cjs.map +1 -1
- package/dist/src/server/index.js +17 -18
- package/dist/src/server/index.js.map +1 -1
- package/package.json +17 -16
package/dist/src/server/index.js
CHANGED
|
@@ -66,7 +66,7 @@ var PE32_PLUS_MAGIC = 523;
|
|
|
66
66
|
* Holds the ELF magic, 0x7f454c46, the bytes 0x7F `E` `L` `F` read as a 32-bit
|
|
67
67
|
* big-endian value.
|
|
68
68
|
*/
|
|
69
|
-
var ELF_MAGIC =
|
|
69
|
+
var ELF_MAGIC = 0x7f454c46;
|
|
70
70
|
/** Holds the ELF 64-bit class identifier, 2. */
|
|
71
71
|
var ELF_CLASS_64 = 2;
|
|
72
72
|
/** Holds the ELF little-endian data encoding, 1. */
|
|
@@ -82,7 +82,7 @@ var ELF_PF_R = 4;
|
|
|
82
82
|
/** Holds the page size an injected ELF segment is aligned to, 0x1000. */
|
|
83
83
|
var ELF_PAGE_SIZE = 4096;
|
|
84
84
|
/** Holds the Mach-O 64-bit magic, 0xfeedfacf, in little-endian byte order. */
|
|
85
|
-
var MACHO_MAGIC_64 =
|
|
85
|
+
var MACHO_MAGIC_64 = 0xfeedfacf;
|
|
86
86
|
/** Holds the Mach-O `LC_SEGMENT_64` load command, 0x19. */
|
|
87
87
|
var MACHO_LC_SEGMENT_64 = 25;
|
|
88
88
|
/** Holds the PE resource type `RT_RCDATA` for raw data, 10. */
|
|
@@ -99,16 +99,16 @@ var PE_SECTION_HEADER_SIZE = 40;
|
|
|
99
99
|
* Holds the high bit mask marking a resource directory entry offset as a
|
|
100
100
|
* subdirectory, 0x80000000.
|
|
101
101
|
*/
|
|
102
|
-
var PE_RESOURCE_SUBDIR_FLAG =
|
|
102
|
+
var PE_RESOURCE_SUBDIR_FLAG = 0x80000000;
|
|
103
103
|
/**
|
|
104
104
|
* Holds the high bit mask marking a resource entry as named rather than
|
|
105
105
|
* integer-identified, 0x80000000.
|
|
106
106
|
*/
|
|
107
|
-
var PE_RESOURCE_NAME_FLAG =
|
|
107
|
+
var PE_RESOURCE_NAME_FLAG = 0x80000000;
|
|
108
108
|
/** Marks a section as containing initialized data, 0x00000040. */
|
|
109
109
|
var PE_SCN_INITIALIZED_DATA = 64;
|
|
110
110
|
/** Marks a section as readable, 0x40000000. */
|
|
111
|
-
var PE_SCN_MEM_READ =
|
|
111
|
+
var PE_SCN_MEM_READ = 0x40000000;
|
|
112
112
|
/**
|
|
113
113
|
* Holds the platform-specific SEA build configurations, keyed by
|
|
114
114
|
* `process.platform` for `win32`, `darwin`, and `linux`.
|
|
@@ -1352,7 +1352,7 @@ var Injection = class {
|
|
|
1352
1352
|
if (existingResourceRVA >= virtualAddress && existingResourceRVA < virtualAddress + Math.max(virtualSize, rawSize)) this.#rsrcSectionIndex = i;
|
|
1353
1353
|
}
|
|
1354
1354
|
const sectionTableEnd = sectionTableOffset + numberOfSections * 40;
|
|
1355
|
-
const availableHeaderSpace = sections.reduce((min, s) => s.rawOffset > 0 && s.rawOffset < min ? s.rawOffset : min,
|
|
1355
|
+
const availableHeaderSpace = sections.reduce((min, s) => s.rawOffset > 0 && s.rawOffset < min ? s.rawOffset : min, 1e400) - sectionTableEnd;
|
|
1356
1356
|
if (availableHeaderSpace < 40) throw new SEAError("ROOM", `No room in PE header for a new section entry (${String(availableHeaderSpace)} bytes available, need ${String(40)})`, {
|
|
1357
1357
|
executable: this.#options.executable,
|
|
1358
1358
|
availableHeaderSpace,
|
|
@@ -1391,8 +1391,7 @@ var Injection = class {
|
|
|
1391
1391
|
return end > highest ? end : highest;
|
|
1392
1392
|
}, 0), sectionAlignment);
|
|
1393
1393
|
const newVirtualSize = totalRawSize;
|
|
1394
|
-
const
|
|
1395
|
-
const newRawOffset = alignTo(fileSize, fileAlignment);
|
|
1394
|
+
const newRawOffset = alignTo(statSync(this.#options.executable).size, fileAlignment);
|
|
1396
1395
|
const newHeaderOffset = sectionTableEnd;
|
|
1397
1396
|
const headerBuf = Buffer.alloc(40);
|
|
1398
1397
|
headerBuf.write(".rsrc2", 0, 6, "ascii");
|
|
@@ -1451,7 +1450,7 @@ var Injection = class {
|
|
|
1451
1450
|
const typeName = depth === 0 ? entryName : currentTypeName;
|
|
1452
1451
|
const nameId = depth === 1 ? entryId : currentNameId;
|
|
1453
1452
|
const nameName = depth === 1 ? entryName : currentNameName;
|
|
1454
|
-
if ((offsetOrData &
|
|
1453
|
+
if ((offsetOrData & 0x80000000) !== 0) {
|
|
1455
1454
|
const subDirOffset = offsetOrData & ~PE_RESOURCE_SUBDIR_FLAG;
|
|
1456
1455
|
this.#parseResourceDirectory(fd, sectionFileOffset, sectionRva, subDirOffset, leaves, depth + 1, typeId, typeName, nameId, nameName);
|
|
1457
1456
|
} else {
|
|
@@ -1675,7 +1674,7 @@ var Injection = class {
|
|
|
1675
1674
|
const entryOffset = dirOffset + 16 + i * 8;
|
|
1676
1675
|
if (entryOffset + 8 > buf.length) return;
|
|
1677
1676
|
const offsetOrData = buf.readUInt32LE(entryOffset + 4);
|
|
1678
|
-
if ((offsetOrData &
|
|
1677
|
+
if ((offsetOrData & 0x80000000) !== 0) {
|
|
1679
1678
|
const subOffset = offsetOrData & ~PE_RESOURCE_SUBDIR_FLAG;
|
|
1680
1679
|
this.#fixupDataEntries(buf, subOffset, sectionVA);
|
|
1681
1680
|
} else if (offsetOrData + 4 <= buf.length) {
|
|
@@ -1906,7 +1905,7 @@ var Injection = class {
|
|
|
1906
1905
|
const buf = Buffer.alloc(headerSize + preSizeofcmds);
|
|
1907
1906
|
readSync(this.#srcFd, buf, 0, headerSize + preSizeofcmds, 0);
|
|
1908
1907
|
const magic = buf.readUInt32LE(0);
|
|
1909
|
-
if (magic !==
|
|
1908
|
+
if (magic !== 0xfeedfacf) throw new SEAError("FORMAT", `Unsupported Mach-O magic: 0x${magic.toString(16)}`, {
|
|
1910
1909
|
executable: exePath,
|
|
1911
1910
|
magic
|
|
1912
1911
|
});
|
|
@@ -2060,7 +2059,7 @@ var Injection = class {
|
|
|
2060
2059
|
56,
|
|
2061
2060
|
64,
|
|
2062
2061
|
72
|
|
2063
|
-
] : cmd.type === 34 || cmd.type ===
|
|
2062
|
+
] : cmd.type === 34 || cmd.type === 0x80000022 ? [
|
|
2064
2063
|
8,
|
|
2065
2064
|
16,
|
|
2066
2065
|
24,
|
|
@@ -2071,8 +2070,8 @@ var Injection = class {
|
|
|
2071
2070
|
30,
|
|
2072
2071
|
38,
|
|
2073
2072
|
41,
|
|
2074
|
-
|
|
2075
|
-
|
|
2073
|
+
0x80000033,
|
|
2074
|
+
0x80000034
|
|
2076
2075
|
].includes(cmd.type) ? [8] : [];
|
|
2077
2076
|
for (const offset of offsets) {
|
|
2078
2077
|
const fieldOffset = cmd.offset + offset;
|
|
@@ -2180,13 +2179,13 @@ var Injector = class {
|
|
|
2180
2179
|
const magic32 = header.readUInt32BE(0);
|
|
2181
2180
|
const magic32le = header.readUInt32LE(0);
|
|
2182
2181
|
if (magic16 === 23117) return "pe";
|
|
2183
|
-
if (magic32 ===
|
|
2184
|
-
if (magic32le ===
|
|
2185
|
-
if (magic32 ===
|
|
2182
|
+
if (magic32 === 0x7f454c46) return "elf";
|
|
2183
|
+
if (magic32le === 0xfeedfacf) return "macho";
|
|
2184
|
+
if (magic32 === 0xcafebabe || magic32 === 0xbebafeca) throw new SEAError("FORMAT", "Mach-O universal/fat binaries are not supported; provide a thin arm64 or x86_64 binary", {
|
|
2186
2185
|
executable: this.#options.executable,
|
|
2187
2186
|
magic: magic32
|
|
2188
2187
|
});
|
|
2189
|
-
if (magic32le ===
|
|
2188
|
+
if (magic32le === 0xfeedface || magic32le === 0xcefaedfe || magic32 === 0xfeedface || magic32 === 0xcefaedfe) throw new SEAError("FORMAT", "Only 64-bit little-endian Mach-O is supported", {
|
|
2190
2189
|
executable: this.#options.executable,
|
|
2191
2190
|
magic: magic32
|
|
2192
2191
|
});
|