/** * The network hook library in the game copy: the exe patch * online/network-hook-library makes aces.exe load win64/wto_ws.dll, which reads its settings * from win64/wto_ws.cfg: the local server port, and the values its LocalMP modules need from the * executable (native/native-settings.ts). Both files are written next to the executable; the DLL * is built from native/wto-net (build.ps1). */ import type { PeImage } from '@wto/exepatch'; import { nativeSettingsLines } from '../native/native-settings.ts'; import type { LocalEndpoint } from './local-endpoint.ts'; export const NETWORK_HOOK_LIBRARY = 'wto_ws.dll'; const SETTINGS = 'wto_ws.cfg'; /** `stock` is the unpatched executable the native values were resolved against. */ export function networkHookSettings( endpoint: LocalEndpoint, stock: PeImage, nativeValues: ReadonlyMap, options?: { readonly loggingEnabled?: boolean }, ): { name: string; content: Uint8Array } { const lines = [ `port=${endpoint.port}`, ...(options?.loggingEnabled === false ? ['log=0'] : []), ...nativeSettingsLines(stock, nativeValues), ]; return { name: SETTINGS, content: new TextEncoder().encode(`${lines.join('\n')}\n`) }; }