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