/** * The lines of the hook library's settings file that carry the resolved native values. * * exe.time_date_stamp=0x... the executable the values were resolved for (PE file header); * exe.size_of_image=0x... the library compares both with the running executable and * leaves every LocalMP module off when they differ * native.=0x... one line per value (native-resolve.ts), signed values as -0x... */ import type { PeImage } from '@wto/exepatch'; export function nativeSettingsLines(image: PeImage, values: ReadonlyMap): string[] { const view = new DataView(image.data.buffer, image.data.byteOffset, image.data.byteLength); const peHeader = view.getUint32(0x3c, true); const timeDateStamp = view.getUint32(peHeader + 8, true); const sizeOfImage = view.getUint32(peHeader + 24 + 56, true); const lines = [`exe.time_date_stamp=${hex(timeDateStamp)}`, `exe.size_of_image=${hex(sizeOfImage)}`]; for (const [name, value] of [...values].sort(([left], [right]) => left.localeCompare(right))) lines.push(`native.${name}=${hex(value)}`); return lines; } function hex(value: number): string { return value < 0 ? `-0x${(-value).toString(16)}` : `0x${value.toString(16)}`; }