Skip to content

Commit de15866

Browse files
committed
TerminalShell (Windows): print clink version
1 parent 24ee877 commit de15866

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/detection/terminalshell/terminalshell_windows.c

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,33 @@
99
#include <ntstatus.h>
1010
#include <winternl.h>
1111

12+
static bool getProductVersion(const wchar_t* filePath, FFstrbuf* version)
13+
{
14+
DWORD handle;
15+
DWORD size = GetFileVersionInfoSizeW(filePath, &handle);
16+
if(size > 0)
17+
{
18+
FF_AUTO_FREE void* versionData = malloc(size);
19+
if(GetFileVersionInfoW(filePath, handle, size, versionData))
20+
{
21+
VS_FIXEDFILEINFO* verInfo;
22+
UINT len;
23+
if(VerQueryValueW(versionData, L"\\", (void**)&verInfo, &len) && len && verInfo->dwSignature == 0xFEEF04BD)
24+
{
25+
ffStrbufAppendF(version, "%u.%u.%u.%u",
26+
(unsigned)(( verInfo->dwProductVersionMS >> 16 ) & 0xffff),
27+
(unsigned)(( verInfo->dwProductVersionMS >> 0 ) & 0xffff),
28+
(unsigned)(( verInfo->dwProductVersionLS >> 16 ) & 0xffff),
29+
(unsigned)(( verInfo->dwProductVersionLS >> 0 ) & 0xffff)
30+
);
31+
return true;
32+
}
33+
}
34+
}
35+
36+
return false;
37+
}
38+
1239
static bool getProcessInfo(uint32_t pid, uint32_t* ppid, FFstrbuf* pname, FFstrbuf* exe, const char** exeName)
1340
{
1441
HANDLE hProcess = pid == 0
@@ -150,7 +177,9 @@ static uint32_t getShellInfo(const FFinstance* instance, FFTerminalShellResult*
150177
{
151178
if(wcsncmp(module.szModule, L"clink_dll_", strlen("clink_dll_")) == 0)
152179
{
153-
ffStrbufAppendS(&result->shellPrettyName, "CMD (with Clink)");
180+
ffStrbufAppendS(&result->shellPrettyName, "CMD (with Clink ");
181+
getProductVersion(module.szExePath, &result->shellPrettyName);
182+
ffStrbufAppendC(&result->shellPrettyName, ')');
154183
break;
155184
}
156185
}

0 commit comments

Comments
 (0)