From 0a8056d835792377bc0621a43dbde042d80ac7a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Mon, 25 Mar 2024 14:09:53 +0800 Subject: [PATCH] TerminalShell (Windows): adjustments 1. Don't pretty print CMD 2. Print conhost as Windows Console --- CHANGELOG.md | 4 ++++ src/detection/terminalshell/terminalshell_windows.c | 8 +++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 583283942..6c534c9c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ Changes: * Use MS-DOS device name as mountFrom result, instead of useless GUID volume name (Windows, Disk) +* Some adjustments to Terminal detection (Terminal, Windows) + * Don't pretty print CMD + * Print conhost as Windows Console + * Don't detect `wininit` as Terminal Bugfixes: * Don't display 0.00 GHz (CPU, FreeBSD) diff --git a/src/detection/terminalshell/terminalshell_windows.c b/src/detection/terminalshell/terminalshell_windows.c index 053c62a7f..bd92f0829 100644 --- a/src/detection/terminalshell/terminalshell_windows.c +++ b/src/detection/terminalshell/terminalshell_windows.c @@ -143,7 +143,7 @@ static void setShellInfoDetails(FFShellResult* result) ffStrbufSetS(&result->prettyName, "Windows PowerShell ISE"); else if(ffStrbufIgnCaseEqualS(&result->prettyName, "cmd")) { - ffStrbufClear(&result->prettyName); + ffStrbufSetS(&result->prettyName, "CMD"); FF_AUTO_CLOSE_FD HANDLE snapshot = NULL; while(!(snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, result->pid)) && GetLastError() == ERROR_BAD_LENGTH) {} @@ -156,15 +156,13 @@ static void setShellInfoDetails(FFShellResult* result) { if(wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0) { - ffStrbufAppendS(&result->prettyName, "CMD (with Clink "); + ffStrbufAppendS(&result->prettyName, " (with Clink "); getProductVersion(module.szExePath, &result->prettyName); ffStrbufAppendC(&result->prettyName, ')'); break; } } } - if(result->prettyName.length == 0) - ffStrbufAppendS(&result->prettyName, "Command Prompt"); } else if(ffStrbufIgnCaseEqualS(&result->prettyName, "nu")) ffStrbufSetS(&result->prettyName, "nushell"); @@ -345,7 +343,7 @@ static void setTerminalInfoDetails(FFTerminalResult* result) : "Windows Terminal" ); else if(ffStrbufIgnCaseEqualS(&result->prettyName, "conhost")) - ffStrbufSetStatic(&result->prettyName, "Console Window Host"); + ffStrbufSetStatic(&result->prettyName, "Windows Console"); else if(ffStrbufIgnCaseEqualS(&result->prettyName, "Code")) ffStrbufSetStatic(&result->prettyName, "Visual Studio Code"); else if(ffStrbufIgnCaseEqualS(&result->prettyName, "explorer"))