Skip to main content

Module windows

Module windows 

Source
Expand description

Windows rules that are pure text and path logic, compiled on every platform so the Linux and macOS legs test them: the verbatim-prefix strip, the wt directory argument, PATHEXT resolution, the cmd.exe /c wrap and the .ps1 wrapper.

Enums§

WindowsShell

Constants§

BOOT_EXPR_PS1
The spec’s boot value: LastBootUpTime as epoch seconds truncated to the minute (the same expression SystemProbe::boot_id runs).
DEFAULT_PATHEXT 🔒
START_EXPR_PS1
The start time as FILETIME, the number SystemProbe::starttime reads from GetProcessTimes.

Functions§

cmd_line
The single command line cmd.exe /c receives for a .cmd controller. cmd /c strips the first and the last quote of a line that holds more than two, so a quoted executable followed by any quoted argument breaks (MEASURED, Task 25: 'C:\Users\x' is not recognized, and a quoted a&echo INJECTED ran), hence the ONE outer pair. The executable is always quoted, an argument only when it is empty or has whitespace, and a backslash run at the end of a quoted argument is doubled so it cannot escape the closing quote. The launcher already refuses " % & | < > ^ and newlines in controller arguments.
cmd_wrap
cmd.exe /c <exe> <args> (spec Launcher step 5: a .cmd controller).
controller_command
The argv that starts the controller. Off Windows the bare name and the arguments (the OS finds the executable). On Windows the executable is resolved through PATHEXT here, and a .cmd/.bat goes through cmd.exe /c; None is CONTROLLER_NOT_FOUND.
controller_process
The process for an argv from controller_command. A cmd.exe /c <script> <args> argv on Windows gets the raw command line of cmd_line (the standard argument quoting breaks cmd /c); anything else is the plain program and arguments.
is_cmd_ext 🔒
quote_ps
Single-quote a value for PowerShell, doubling EVERY quote character it recognises: U+0027 and the typographic U+2018, U+2019, U+201A, U+201B (a lone one ends the string, or lets text after it run).
resolve_executable
The Windows lookup of a bare command name: every directory of path (;-separated) in order, and in each, the name as is when it already ends in a pathext extension, then the name plus each pathext extension in order. The flag is true for a .cmd/.bat script, which CreateProcess cannot start by bare name and cmd_wrap runs through cmd.exe /c.
select_windows_shell
pwsh when it is on PATH, else the stock powershell.exe.
strip_verbatim
\\?\C:\x -> C:\x and \\?\UNC\server\share -> \\server\share (what std::fs::canonicalize returns on Windows); any other path is returned unchanged.
wrapper_script_ps1
The .ps1 tab wrapper (UTF-8 text, no BOM: write_wrapper prepends it). The sentinels are written with [System.IO.File]::WriteAllText, which writes UTF-8 without a BOM and without a newline on both PowerShell editions; Out-File, > and Set-Content do not.
wt_directory_arg
The -d argument of wt, passed through unchanged. MEASURED on Windows 11 with wt: a bare C:\ opens the drive root, while the C: this once produced opens the drive’s current directory (C:\WINDOWS\system32 there). The trailing-backslash worry applies only to a hand-quoted "C:\", and Command quotes only arguments that contain whitespace, which a drive root never does.