Files
orca/config/scripts/native-build/windows/windows-pe-image-fixture.mjs
Neil 9bd6272fdf refactor(tooling): organize build, CI, and test owners (#38130)
* 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
2026-11-04 21:08:19 -08:00

17 lines
755 B
JavaScript

import { createRequire } from 'node:module'
const { PE_MACHINE } = createRequire(import.meta.url)('./windows-pe-machine.cjs')
// Give fixture real PE machine header: architecture determines whether loader reaches an addon, so arbitrary bytes cannot model it.
export function peImage({ arch = 'x64', machine, peOffset = 0x80, signature = 'PE\0\0' } = {}) {
if (machine === undefined && PE_MACHINE[arch] === undefined) {
throw new Error(`No PE machine value for ${arch}; a fixture must not invent one.`)
}
const image = Buffer.alloc(peOffset + 8)
image.write('MZ', 0, 'latin1')
image.writeUInt32LE(peOffset, 0x3c)
image.write(signature, peOffset, 'latin1')
image.writeUInt16LE(machine ?? PE_MACHINE[arch], peOffset + 4)
return image
}