mirror of
https://github.com/stablyai/orca.git
synced 2026-11-13 09:27:29 +00:00
* refactor(tooling): organize test runtime and maintenance owners * test(tooling): preserve relocated runtime fixture dependency edges * refactor(tooling): preserve xterm routing owner checks * ci(tooling): include routing owner in sparse checkout * test(tooling): preserve copied workflow dependency closures * fix(tooling): normalize hashed JSON assets in release parity * fix(tooling): distinguish asset aliases from literal references * fix(tooling): frame normalized asset reference payloads * fix(tooling): normalize decoded JSON asset references * refactor(tooling): organize build, CI and release owners * fix(tooling): align moved generator and workflow path contracts * fix(tooling): update generated plugin bundle owner banners * test(tooling): create relocated mobile verifier fixture directories * test(tooling): copy headless detector dependency closure * test(tooling): align native batch policy fixtures with owner path * fix(tooling): link moved reliability command to historical evidence * fix(tooling): preserve nested sandbox owners and canonical guide source * fix(tooling): target release version owners in checkout fixture
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
'use strict'
|
|
|
|
const { closeSync, openSync, readSync } = require('node:fs')
|
|
|
|
/** PE `IMAGE_FILE_HEADER.Machine` values, so a cross-build cannot silently emit host arch. */
|
|
const PE_MACHINE = { x64: 0x8664, arm64: 0xaa64 }
|
|
|
|
// Return null for truncated/non-PE input so caller can classify external artifact instead of crashing.
|
|
function readPeMachine(binaryPath) {
|
|
const fd = openSync(binaryPath, 'r')
|
|
try {
|
|
const dosHeader = Buffer.alloc(0x40)
|
|
if (readSync(fd, dosHeader, 0, 0x40, 0) < 0x40 || dosHeader.toString('latin1', 0, 2) !== 'MZ') {
|
|
return null
|
|
}
|
|
const peOffset = dosHeader.readUInt32LE(0x3c)
|
|
const peHeader = Buffer.alloc(6)
|
|
if (
|
|
readSync(fd, peHeader, 0, 6, peOffset) < 6 ||
|
|
peHeader.toString('latin1', 0, 4) !== 'PE\0\0'
|
|
) {
|
|
return null
|
|
}
|
|
return peHeader.readUInt16LE(4)
|
|
} finally {
|
|
closeSync(fd)
|
|
}
|
|
}
|
|
|
|
function describePeMachine(machine) {
|
|
return machine === null ? 'not a PE image' : `machine 0x${machine.toString(16)}`
|
|
}
|
|
|
|
module.exports = { PE_MACHINE, describePeMachine, readPeMachine }
|