void dumpWindowsVersion()

in src/shared/WindowsVersion.cc [189:252]


void dumpWindowsVersion() {
    if (!isTracingEnabled()) {
        return;
    }
    const auto info = getWindowsVersionInfo();
    StringBuilder b;
    b << info.dwMajorVersion << '.' << info.dwMinorVersion
      << '.' << info.dwBuildNumber << ' '
      << "SP" << info.wServicePackMajor << '.' << info.wServicePackMinor
      << ' ';
    switch (info.wProductType) {
        case VER_NT_WORKSTATION:        b << "Client"; break;
        case VER_NT_DOMAIN_CONTROLLER:  b << "DomainController"; break;
        case VER_NT_SERVER:             b << "Server"; break;
        default:
            b << "product=" << info.wProductType; break;
    }
    b << ' ';
#if WINPTY_ARCH == WINPTY_IA32
    b << "IA32";
    OsModule kernel32(L"kernel32.dll");
    IsWow64Process_t *pIsWow64Process =
        reinterpret_cast<IsWow64Process_t*>(
            kernel32.proc("IsWow64Process"));
    if (pIsWow64Process != nullptr) {
        BOOL result = false;
        const BOOL success = pIsWow64Process(GetCurrentProcess(), &result);
        if (!success) {
            b << " WOW64:error";
        } else if (success && result) {
            b << " WOW64";
        }
    } else {
        b << " WOW64:missingapi";
    }
#elif WINPTY_ARCH == WINPTY_X64
    b << "X64";
#endif
    const auto dllVersion = [](const wchar_t *dllPath) -> std::string {
        try {
            const auto info = getFixedFileInfo(dllPath);
            StringBuilder fb(64);
            fb << utf8FromWide(dllPath) << ':';
            fb << "F:" << versionToString(fileVersionFromInfo(info)) << '/'
               << "P:" << versionToString(productVersionFromInfo(info));
            return fb.str_moved();
        } catch (const ModuleNotFound&) {
            return utf8FromWide(dllPath) + ":none";
        } catch (const WinptyException &e) {
            trace("Error getting %s version: %s",
                utf8FromWide(dllPath).c_str(), utf8FromWide(e.what()).c_str());
            return utf8FromWide(dllPath) + ":error";
        }
    };
    b << ' ' << dllVersion(L"kernel32.dll");
    // ConEmu provides a DLL that hooks many Windows APIs, especially console
    // APIs.  Its existence and version number could be useful in debugging.
#if WINPTY_ARCH == WINPTY_IA32
    b << ' ' << dllVersion(L"ConEmuHk.dll");
#elif WINPTY_ARCH == WINPTY_X64
    b << ' ' << dllVersion(L"ConEmuHk64.dll");
#endif
    trace("Windows version: %s", b.c_str());
}