livery.toolroom.store._trampoline¶
livery.toolroom.store._trampoline ¶
Native Windows PE32+ executable trampoline for tool launchers.
On Windows, a .cmd launcher routes every invocation through cmd.exe,
which interprets ^ as an escape character, expands %VAR%, and re-parses
quotes before forwarding %*. Replacing .cmd with a tiny PE32+ console
executable for native binary targets lets Windows start the target directly
through CreateProcessW with the caller's raw command-line tail byte-for-byte
unchanged.
Batch targets (.cmd and .bat) stay behind .cmd wrappers because
CreateProcessW does not execute batch scripts directly without cmd.exe.
Each trampoline binary carries a small trailer appended after the PE image::
[PE32+ image]
[UTF-8 target path][NUL][UTF-8 quoted command-line prefix]
[uint32_le payload_byte_length]
[4-byte magic: b"LSHM"]
Functions:
| Name | Description |
|---|---|
is_script_target |
Whether target is a Windows batch script that still needs a |
format_command_prefix |
Format target and leading args as a Windows |
write_trampoline |
Write a native Windows |
read_trampoline |
Read |
Attributes:
| Name | Type | Description |
|---|---|---|
TRAILER_MAGIC |
bytes
|
|
SCRIPT_SUFFIXES |
tuple[str, ...]
|
|
is_script_target ¶
Whether target is a Windows batch script that still needs a .cmd shim.
format_command_prefix ¶
Format target and leading args as a Windows CreateProcessW prefix.
Source code in packages/toolroom-store/src/livery/toolroom/store/_trampoline.py
write_trampoline ¶
Write a native Windows .exe trampoline at dest forwarding to target.
Any existing symlink or file at dest is unlinked before writing so the write never follows an existing link. Returns dest.
Source code in packages/toolroom-store/src/livery/toolroom/store/_trampoline.py
read_trampoline ¶
Read (target, command_prefix) from a trampoline at path, or None.