Attaching to target process
To control overlay, you first need to attach overlay dll to target process.
The @asdf-overlay/core package provides a function for attaching overlay and initialize IPC connection.
Following code connects overlay to target process.
import { defaultDllDir, Overlay } from '@asdf-overlay/core';
const overlay = await Overlay.attach(
defaultDllDir().replace('app.asar', 'app.asar.unpacked'),
/* target process id */ 12345,
/* optional timeout in ms */ 5000,
);
Some caveats included below:
@asdf-overlay/corepackage includes overlay dll files for x64, ia32 and arm64 architectures. Asdf overlay will choose appropriate one based on the target process architecture. ThedefaultDllDirfunction returns path to the directory containing these dll files.- Onced injected, the dll will not be unloaded until the target process exits and maybe reused later if another connection is established.
- If optional timeout is not provided, it will wait indefinitely.
- The
Overlay.attachfunction returns anOverlayinstance upon successful attachment and can be used to control the overlay. - On Electron,
@asdf-overlay/coremust be specified as external to work correctly. - On Electron,
defaultDllDirfunction may return path insideapp.asararchive. In such cases, you need to replaceapp.asarwithapp.asar.unpackedto access the dll files.