File size: 728 Bytes
277dba7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { readFile, writeFile } from "node:fs/promises";

const controlPath = new URL("./control.armnn", import.meta.url);
const triggerPath = new URL("./trigger.armnn", import.meta.url);
const bytes = await readFile(controlPath);

const discriminatorOffset = 763;
if (bytes.length !== 908 || bytes[discriminatorOffset] !== 0x09) {
  throw new Error(
    `unexpected control fixture at offset ${discriminatorOffset}: ` +
      `length=${bytes.length}, byte=0x${bytes[discriminatorOffset]?.toString(16)}`,
  );
}

bytes[discriminatorOffset] = 0x7b;
await writeFile(triggerPath, bytes);

console.log(
  `wrote ${bytes.length} bytes; AnyLayer.layer_type byte ` +
    `at offset ${discriminatorOffset} changed from 0x09 to 0x7b`,
);