Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Voyager7 as the default terminal without console delegation (hook)

Status: proposed. Date: 2026-11-29. Owner approved: no.

ADR 0014 makes Voyager7 the default terminal where Windows has console delegation (HKCU\Console\%%Startup): Windows 11 and Windows 10 22H2. Windows 7, 8.1 and older Windows 10 builds have no delegation: a console program started from Explorer (Run box, Start menu, a double-click) always opens in a console window. This ADR adds an opt-in replacement for them, in the spirit of ConEmu's "Default terminal" feature, written from Microsoft's documentation in our own code.

Prior art (ConEmu's public documentation only)

ConEmu's page (conemu.github.io/en/DefaultTerminal.html) describes: turn on "Force ConEmu as default terminal", list the "parent" programs that start console tools (for example explorer.exe|devenv.exe|totalcmd.exe), and its hook DLL (ConEmuHk.dll/ConEmuHk64.dll) is loaded into those parents. "Register on OS startup" covers mostly explorer.exe. Elevated ("As administrator") consoles "can't be hooked". It warns: "Enabling 'Default terminal' feature may cause false alarms in some antiviral programs." A started program is rewritten to run through ConEmu or its console helper (ConEmuC64.exe … /ROOT "cmd.exe"), because the parent "does not really need to get started process handle". Nothing of ConEmu's code is used or read.

How it works

Microsoft sources for every call: CreateProcessW/CreateProcessA (processthreadsapi.h), STARTUPINFOW, process creation flags, the PE format (IMAGE_OPTIONAL_HEADER64.Subsystem), NtQueryInformationProcess with ProcessBasicInformation and the PEB/RTL_USER_PROCESS_PARAMETERS fields that winternl.h documents (ProcessParameters, ImagePathName, CommandLine), CreateRemoteThread, VirtualAllocEx, WriteProcessMemory, EnumProcessModules, DuplicateHandle, the Run key (HKCU\Software\Microsoft\Windows\CurrentVersion\Run).

  1. Watcher. Choosing "Voyager7 (hook)" writes one per-user Run value, Voyager7 default terminal = "<dir>\voyager7.exe" --v7-defterm-watch, and starts that command now. The watcher has no window. It copies v7-defterm.dll from beside voyager7.exe into %LOCALAPPDATA%\Voyager7DefTerm-<SHA-256>\ (a directory only the user can open, like the console hook's cache) and loads it into every host process of the user's session: explorer.exe. It looks again every 3 seconds (one Toolhelp snapshot), so a restarted Explorer is hooked again. One watcher per session and class; it ends when told to stop.
  2. Hook. v7-defterm.dll (no_std Rust, kernel32 only) is loaded with CreateRemoteThread(LoadLibraryW); a second remote thread calls its Voyager7DefaultTerminalInstall export with a configuration block (voyager7.exe's path, the watcher's --class/--config, the exclusion list). It replaces the import-table entries of CreateProcessW and CreateProcessA in every loaded module (matched by value, kernel32 or kernelbase; Windows 7's shell32.dll imports CreateProcessW through API-MS-Win-Core-ProcessThreads-L1-1-0, Windows 10's windows.storage.dll the same way), and of the four LoadLibrary* calls, after which it patches the modules that were loaded. GetProcAddress is not hooked (Windows 7's kernel32 version depends on its caller); on Windows 10 kernel32's own CreateProcessW stub jumps through a patched entry anyway. Nothing else is hooked; DllMain does nothing.
  3. Decision, per call. A start is left alone (the original call, unchanged) unless it would open a new console window:
    • no DETACHED_PROCESS, CREATE_NO_WINDOW, DEBUG_* or protected-process flag. CREATE_SUSPENDED and EXTENDED_STARTUPINFO_PRESENT are allowed: Windows 7's ShellExecuteEx (Explorer, the Run box) starts every program with 0x04080414 = both of them plus CREATE_NEW_CONSOLE, CREATE_UNICODE_ENVIRONMENT and CREATE_DEFAULT_ERROR_MODE, with an empty attribute list, and resumes the thread itself (traced on the VM);
    • the caller has no console, or asks for CREATE_NEW_CONSOLE;
    • STARTUPINFO does not redirect standard handles (STARTF_USESTDHANDLES) and does not ask for a hidden or minimized window;
    • then the program is created suspended with the caller's exact arguments, and its image is checked: console subsystem (IMAGE_SUBSYSTEM_WINDOWS_CUI), not voyager7.exe, voyager7.com, conhost.exe or OpenConsole.exe, not on the exclusion list. A GUI program (or anything else) is simply resumed: the caller gets its real process, created exactly as asked.
  4. Hand-over. For a console program the hook reads the suspended process's exact image path and command line (the PEB's process parameters; this also covers a .bat started directly, which Windows runs as cmd.exe /c), and starts the agent instead: voyager7.exe --v7-defterm-agent <image> <command line> [--class/--config] with the caller's working directory, environment block (and its CREATE_UNICODE_ENVIRONMENT), handle inheritance, security attributes, desktop, attribute list and suspension (the caller resumes the agent as it would have resumed the program), a hidden console and no busy cursor. Only when the agent started is the suspended program terminated (it has run no code); otherwise it is resumed and opens in its console window as before.
  5. Agent. The agent is the Win7 Backend's console agent (the hidden console that each Voyager7 tab on Windows 7 already has) started by the hook instead of by Voyager7. It makes its two pipes and an event, and starts voyager7.exe [--class/--config] --v7-agent=<pid>,<event>,<in>,<out>, which, like any second Voyager7, hands that argument to the running instance of its class as a +new-window request or opens its own first window (ADR 0014's path). The receiving Voyager7 duplicates the pipe ends out of the agent (DUPLICATE_CLOSE_SOURCE) and signals the event; from then on it is an ordinary Win7 tab, and the agent starts the program in its console with the hook DLL of the scraper, as for any tab.
  6. Fallback. If Voyager7 cannot be started, exits with an error, or does not take the console within 20 s, the agent shows its console window and runs the program there, unhooked: the program runs in a normal console window and nothing is lost.

What callers see

CreateProcess returns the agent's process and thread (handles and ids). The agent lives exactly as long as the program and exits with the program's exit code (closing the tab ends both, as with any tab), so a caller that waits for the process or reads its exit code gets the program's. The process id is the agent's, not the program's, and the program's parent is the agent; a caller that inspects the process image sees voyager7.exe.

Decision

  • Opt-in, off by default. Settings' "Default terminal" drop-down on Windows 7/8.1/older Windows 10 (where ADR 0014's delegation is absent) offers "Windows Console Host" and "Voyager7 (hook)". There is no configuration key for it: loading a config must never change a Windows setting (ADR 0014). --diag-default-terminal=show|conhost|voyager7 does the same for tests.
  • Per user, no administrator. Only HKCU: the Run value and the cache directory. No services, no AppInit_DLLs, no system-wide or HKLM change.
  • Off leaves no trace. Choosing "Windows Console Host" (or uninstalling the directory whose watcher it is) deletes the Run value, stops the watcher, unloads the DLL from every process that has it (an export restores every patched entry, waits until no call is inside the hook plus 500 ms, then FreeLibraryAndExitThread), and deletes the cache directory. If another hook has since replaced one of our entries, the DLL stays loaded and passes every call through until the process ends, rather than risk a crash.
  • Hosts: explorer.exe (Windows 7's Explorer and its folder windows run in it). --v7-defterm-hosts=a.exe,b.exe on the watcher's command line names others (tests use their own host program).
  • Exclusions: the built-in names above, plus v7-default-terminal-exclude (a comma-separated list of program file names that keep their console window). The watcher reads it when it starts.
  • New instance behaviour: like ADR 0014: a +new-window request to the running instance of the class, or a first window.
  • Bitness: x64 only. Voyager7 is a 64-bit program; Windows 7 x64's Explorer is 64-bit. 32-bit (WOW64) hosts are skipped: hooking them would need a second, 32-bit DLL and a 32-bit loader. 32-bit console programs started by a 64-bit host are handed over normally.
  • Robustness: every hook passes through to the original call when the decision says no, on any error before the hand-over, and when the hook is turned off; the hook never waits for Voyager7 (the agent does), so Explorer cannot hang on it. The DLL has no panicking code path (no indexing, no unwrap; workspace lints) and no allocation beyond HeapAlloc for one command line.
  • Antivirus: loading a DLL into Explorer with CreateRemoteThread and patching import tables is what malware does too, and behaviour-based antivirus products can flag or block it (the watcher, the DLL, or Explorer's hand-over). Voyager7 is unsigned for the alpha, which makes that likelier. Settings says so when the hook is chosen; if it is blocked, consoles keep opening in console windows.
  • Size: the DLL ships in the Setup and the ZIP (v7-defterm.dll, core component). standalone-min carries only the code in voyager7.exe (watcher, agent mode, adoption); there the choice needs v7-defterm.dll beside it, and Settings says so (ADR 0014's OpenConsole precedent).
  • Setup: an upgrade stops the directory's watcher before replacing files and starts it again afterwards (Explorer keeps its loaded copy from the cache, so files in the install directory are never locked by it); uninstall turns the hook off as above.

Not covered

  • Elevated programs ("Run as administrator", or a manifest asking for it): Explorer starts them through the AppInfo service, not CreateProcess, and a medium-integrity Voyager7 could not host them anyway. They keep conhost.
  • Programs started by processes that are not hosts (Task Manager's "New task", a console's own children, services, scheduled tasks), and starts through CreateProcessAsUserW/CreateProcessWithLogonW ("Run as different user"). Only Explorer's own CreateProcessW/A calls are hooked.
  • Shortcut console properties (STARTF_TITLEISLINKNAME: font, colours, buffer size) and STARTUPINFO's title and window position: the tab uses Voyager7's settings.
  • Hosts that start after the watcher ended (for example after it was killed).

Consequences and risks

  • Every program Explorer starts (with eligible flags) is created suspended first and resumed after a header read: a GUI program starts a fraction of a millisecond later, unchanged otherwise.
  • A console program is created twice: once suspended (terminated before it ran), once by the agent. Process-creation auditing and antivirus see both.
  • The watcher is a resident voyager7.exe process (no window, idle except for a snapshot every 3 s). Setup stops it for upgrades.
  • Explorer keeps the DLL loaded while the choice is on. A crash inside it would take Explorer down (Windows restarts Explorer); see Robustness.
  • The agent never closes its pipe ends: its input wake thread can still be blocked in a synchronous ReadFile when the program exits, and closing a synchronous handle waits for that read (which waits for Voyager7, which waits for the agent). Process exit closes them.
  • Measured with a stand-in host (not Explorer, see Testing): Windows 7 SP1 ShellExecuteExW of cmd /k → Voyager7 window in 322–423 ms; Windows 10 22H2 514 ms. Fallback (Voyager7 failing at once) → console window, program run, in 2 s.
  • Evidence: build/fixes/win7-defterm/NOTES.md.

Testing

Nothing is loaded into the owner's Explorer in tests: the watcher takes --v7-defterm-hosts=v7dt_host.exe, a windowless test program (the v7dt_host example) that starts one program as Explorer would (ShellExecuteExW, CreateProcessW/A, hidden). The registration is tested with --diag-default-terminal=voyager7|conhost and --diag-defterm-run-key= pointing at a key of the test's own. The DLL's trace feature (test builds) notes each decision step in a file.