From f245492679b1d5c754ade7e33389da486b105b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 12:41:48 +0800 Subject: [PATCH 1/7] TerminalShell: fix shell detection when installed with scoop --- src/detection/terminalshell/terminalshell_windows.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/detection/terminalshell/terminalshell_windows.cpp b/src/detection/terminalshell/terminalshell_windows.cpp index abc22a0074..cb2da1ca48 100644 --- a/src/detection/terminalshell/terminalshell_windows.cpp +++ b/src/detection/terminalshell/terminalshell_windows.cpp @@ -120,6 +120,8 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid) ffStrbufIgnCaseEqualS(&result->shellPrettyName, "gdb") || ffStrbufIgnCaseEqualS(&result->shellPrettyName, "lldb") || ffStrbufIgnCaseEqualS(&result->shellPrettyName, "guake-wrapped") || + ffStrbufIgnCaseEqualS(&result->shellPrettyName, "fastfetch") || //scoop warps the real binaries with a "shim" exe + ffStrbufIgnCaseEqualS(&result->shellPrettyName, "flashfetch") || ffStrbufContainIgnCaseS(&result->shellPrettyName, "debug") ) { ffStrbufClear(&result->shellProcessName); From 53265f6b7f043946d2511c6508528d6224289002 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 17:35:25 +0800 Subject: [PATCH 2/7] Users: fix memleaks (Windows) --- CMakeLists.txt | 1 + src/detection/users/users_windows.c | 24 ++------------ src/detection/users/wtsapi32_extend.h | 45 +++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 22 deletions(-) create mode 100644 src/detection/users/wtsapi32_extend.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a0b6966e4..7152118713 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -654,6 +654,7 @@ if(APPLE) PRIVATE "-weak_framework MediaRemote -F /System/Library/PrivateFrameworks" ) elseif(WIN32) + target_compile_definitions(libfastfetch PRIVATE -D_WIN32_WINNT=0x0601) target_link_libraries(libfastfetch PRIVATE "dwmapi" PRIVATE "gdi32" diff --git a/src/detection/users/users_windows.c b/src/detection/users/users_windows.c index 0b4316c10f..7ed1c70faa 100644 --- a/src/detection/users/users_windows.c +++ b/src/detection/users/users_windows.c @@ -2,27 +2,7 @@ #include "util/windows/unicode.h" #include - -//at the time of writing, of MinGW doesn't have the definition of WTSEnumerateSessionsExW -typedef struct _WTS_SESSION_INFO_1W { - DWORD ExecEnvId; - WTS_CONNECTSTATE_CLASS State; - DWORD SessionId; - LPWSTR pSessionName; - LPWSTR pHostName; - LPWSTR pUserName; - LPWSTR pDomainName; - LPWSTR pFarmName; -} WTS_SESSION_INFO_1W, * PWTS_SESSION_INFO_1W; - -BOOL -WINAPI -WTSEnumerateSessionsExW( - HANDLE hServer, - DWORD* pLevel, - DWORD Filter, - PWTS_SESSION_INFO_1W* ppSessionInfo, - DWORD* pCount); +#include "wtsapi32_extend.h" void ffDetectUsers(FFlist* users, FFstrbuf* error) { @@ -48,7 +28,7 @@ void ffDetectUsers(FFlist* users, FFstrbuf* error) ffStrbufInitF((FFstrbuf*)ffListAdd(users), "%s\\%s", domainName.chars, userName.chars); } - WTSFreeMemory(sessionInfo); + WTSFreeMemoryExW(WTSTypeSessionInfoLevel1, sessionInfo, 1); if(users->length == 0) ffStrbufAppendS(error, "Unable to detect users"); diff --git a/src/detection/users/wtsapi32_extend.h b/src/detection/users/wtsapi32_extend.h new file mode 100644 index 0000000000..5c89beb2f0 --- /dev/null +++ b/src/detection/users/wtsapi32_extend.h @@ -0,0 +1,45 @@ +#pragma once + +//at the time of writing, of MinGW doesn't have the definition of WTSEnumerateSessionsExW and friends + +#if (_WIN32_WINNT >= 0x0601) + +typedef struct _WTS_SESSION_INFO_1A { + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPSTR pSessionName; + LPSTR pHostName; + LPSTR pUserName; + LPSTR pDomainName; + LPSTR pFarmName; +} WTS_SESSION_INFO_1A, *PWTS_SESSION_INFO_1A; + +typedef struct _WTS_SESSION_INFO_1W { + DWORD ExecEnvId; + WTS_CONNECTSTATE_CLASS State; + DWORD SessionId; + LPWSTR pSessionName; + LPWSTR pHostName; + LPWSTR pUserName; + LPWSTR pDomainName; + LPWSTR pFarmName; +} WTS_SESSION_INFO_1W, * PWTS_SESSION_INFO_1W; + +#define WTS_SESSION_INFO_1 __MINGW_NAME_AW(WTS_SESSION_INFO_1) +#define PWTS_SESSION_INFO_1 __MINGW_NAME_AW(PWTS_SESSION_INFO_1) + +WINBOOL WINAPI WTSEnumerateSessionsExA(HANDLE hServer,DWORD* pLevel,DWORD Filter,PWTS_SESSION_INFO_1A* ppSessionInfo,DWORD* pCount); +WINBOOL WINAPI WTSEnumerateSessionsExW(HANDLE hServer,DWORD* pLevel,DWORD Filter,PWTS_SESSION_INFO_1W* ppSessionInfo,DWORD* pCount); +#define WTSEnumerateSessionsEx __MINGW_NAME_AW(WTSEnumerateSessionsEx) + +typedef enum _WTS_TYPE_CLASS { + WTSTypeProcessInfoLevel0, + WTSTypeProcessInfoLevel1, + WTSTypeSessionInfoLevel1 +} WTS_TYPE_CLASS; +BOOL WTSFreeMemoryExA(WTS_TYPE_CLASS WTSTypeClass,PVOID pMemory,ULONG NumberOfEntries); +BOOL WTSFreeMemoryExW(WTS_TYPE_CLASS WTSTypeClass,PVOID pMemory,ULONG NumberOfEntries); +#define WTSFreeMemoryEx __MINGW_NAME_AW(WTSFreeMemoryEx) + +#endif /*(_WIN32_WINNT >= 0x0601)*/ From f8174a67d7ae31550651b0b8475cfd7909ee0d5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 17:43:35 +0800 Subject: [PATCH 3/7] Wifi: don't use libcJSON as wlanapi's dll name --- src/detection/wifi/wifi_windows.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/wifi/wifi_windows.c b/src/detection/wifi/wifi_windows.c index f113197f50..92322440f6 100644 --- a/src/detection/wifi/wifi_windows.c +++ b/src/detection/wifi/wifi_windows.c @@ -40,9 +40,9 @@ static void convertIfStateToString(WLAN_INTERFACE_STATE state, FFstrbuf* result) } } -const char* ffDetectWifi(const FFinstance* instance, FFlist* result) +const char* ffDetectWifi(FF_UNUSED_PARAM const FFinstance* instance, FFlist* result) { - FF_LIBRARY_LOAD(wlanapi, &instance->config.libcJSON, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1) + FF_LIBRARY_LOAD(wlanapi, NULL, "dlopen wlanapi"FF_LIBRARY_EXTENSION" failed", "wlanapi"FF_LIBRARY_EXTENSION, 1) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanOpenHandle) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanEnumInterfaces) FF_LIBRARY_LOAD_SYMBOL_MESSAGE(wlanapi, WlanQueryInterface) From 01df2ae3e413466097523023103cd0dca3226c74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 14:59:02 +0800 Subject: [PATCH 4/7] CI: align artifact names to other platforms (Windows) --- .github/workflows/push.yml | 17 +++++++++-------- README.md | 18 +++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index b3b601f46c..006e26d227 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -189,16 +189,16 @@ jobs: run: ctest - name: create zip archive - run: zip fastfetch-windows.zip *.dll fastfetch.exe flashfetch.exe + run: zip fastfetch-$(./fastfetch --version-raw)-Windows.zip *.dll fastfetch.exe flashfetch.exe - name: upload artifacts uses: actions/upload-artifact@v3 with: name: fastfetch-windows - path: ./fastfetch-windows.zip + path: ./fastfetch-*-Windows.zip - windows-old: - name: Windows-old + win7: + name: Win7 runs-on: windows-latest permissions: security-events: write @@ -263,13 +263,13 @@ jobs: run: ctest - name: create zip archive - run: zip fastfetch-windows-old.zip *.dll fastfetch.exe flashfetch.exe + run: zip fastfetch-$(./fastfetch --version-raw)-Win7.zip *.dll fastfetch.exe flashfetch.exe - name: upload artifacts uses: actions/upload-artifact@v3 with: - name: fastfetch-windows-old - path: ./fastfetch-windows-old.zip + name: fastfetch-win7 + path: ./fastfetch-*-Win7.zip release: if: github.event_name == 'push' && github.ref == 'refs/heads/master' && github.repository == 'LinusDierheimer/fastfetch' @@ -280,6 +280,7 @@ jobs: - macos - freebsd - windows + - win7 permissions: contents: write steps: @@ -299,4 +300,4 @@ jobs: tag: ${{ needs.linux.outputs.ffversion }} commit: ${{ github.sha }} artifactErrorsFailBuild: true - artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-windows/* + artifacts: fastfetch-linux/*,fastfetch-macos/*,fastfetch-freebsd/*,fastfetch-windows/*,fastfetch-win7/* diff --git a/README.md b/README.md index 472d62ce9a..d7719aa763 100644 --- a/README.md +++ b/README.md @@ -12,16 +12,16 @@ Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for ## Customization -With customization and speed being two competing goals, this project actually builds two executables. -The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `~/.config/fastfetch/config.conf`. To view the available options run `fastfetch --help`. -The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). -At the moment the performance difference is measurable, but too small to be human recognizable. But the leap will get bigger with more and more options coming, and on slow machines this might actually make a difference. +With customization and speed being two competing goals, this project actually builds two executables. +The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `~/.config/fastfetch/config.conf`. To view the available options run `fastfetch --help`. +The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). +At the moment the performance difference is measurable, but too small to be human recognizable. But the leap will get bigger with more and more options coming, and on slow machines this might actually make a difference. There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config `. They may also serve as a good example for format arguments. ## Dependencies -Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions. +Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions. The following libraries are used if present at runtime: @@ -66,9 +66,9 @@ For the image logo, iTerm with iterm image protocol should work. Apple Terminal * [`libvulkan`](https://www.vulkan.org/): Vulkan module. Usually has been provided by GPU drivers. [`vulkan-loader`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-loader) [`vulkan-headers`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-vulkan-headers) * [`libOpenCL`](https://www.khronos.org/opencl/): OpenCL module. [`opencl-icd`](https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-opencl-icd) -Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, special build `fastfetch-windows-old` in [Github Actions](https://github.com/LinusDierheimer/fastfetch/actions) is provided to support these old systems, which +Note: In Windows 7, 8 and 8.1, [ConEmu](https://conemu.github.io/en/AnsiEscapeCodes.html) is required to run fastfetch due to [the lack of ASCII escape code native support](https://en.wikipedia.org/wiki/ANSI_escape_code#DOS,_OS/2,_and_Windows). In addition, special build `fastfetch-win7` is provided to support these old systems, which -1. Build with the ancient MSVCRT C runtime library, instead of the modern [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library +1. Build with the ancient [MSVCRT](https://en.wikipedia.org/wiki/Microsoft_Windows_library_files#MSVCRT.DLL,_MSVCP*.DLL_and_CRTDLL.DLL) C runtime library, instead of the modern [UCRT](https://learn.microsoft.com/en-us/cpp/windows/universal-crt-deployment) C runtime library 2. Disable stdout application buffer, which seems to problematic for ConEmu. For the image logo, only chafa is supported due to [the design flaw of ConPTY](https://github.com/microsoft/terminal/issues/1173). In addition, chafa support is not built by default due to the massive dependencies of imagemagick. You must built it yourself. @@ -118,7 +118,7 @@ Konsole, Gnome Terminal, Tilix, XFCE4 Terminal, Alacritty, Kitty, LXTerminal, De ## Building -fastfetch uses [`cmake`](https://cmake.org/) for building. [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is recommended for better library detection. The simplest steps to build the fastfetch and flashfetch binaries are: +fastfetch uses [`cmake`](https://cmake.org/) for building. [`pkg-config`](https://www.freedesktop.org/wiki/Software/pkg-config/) is recommended for better library detection. The simplest steps to build the fastfetch and flashfetch binaries are: ```bash mkdir -p build cd build @@ -134,7 +134,7 @@ Currently GCC or clang is required (MSVC is not supported). MSYS2 with CLANG64 s 1. Install [MSYS2](https://www.msys2.org/#installation) 1. Open `MSYS2 CLANG64` (not `MSYS2 / MSYS`, which targets cygwin C runtime) -1. Install dependencies +1. Install dependencies ```bash pacman -Syu mingw-w64-clang-x86_64-cmake mingw-w64-clang-x86_64-pkgconf mingw-w64-clang-x86_64-clang mingw-w64-clang-x86_64-cjson mingw-w64-clang-x86_64-vulkan-loader mingw-w64-clang-x86_64-opencl-icd ``` From c0d3dc30e104fa4faad27589c88c56404a325e9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 18:50:35 +0800 Subject: [PATCH 5/7] Changelog: update 1.8.2 --- CHANGELOG.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1934c9fc63..f4f01fb0d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.8.2 + +Bugfixes: + +* Fix memleaks Users module (Windows) +* Fix shell detection when installed with scoop (Windows) +* Don't use libcJSON as wlanapi's dll name (Windows) +* Align artifact names to other platforms (Windows) + # 1.8.1 Notable Changes: @@ -61,7 +70,7 @@ Logos: Bugfixes: * Fixes disk size detection on 32bit Linux (#337) -* Fixes cpu freq detection in WSL +* Fixes cpu freq detection in WSL * Fixes internal bug of FFstrbuf * Fixes some memory leaks * Fixes segfault if 0 is given as argument index @@ -137,12 +146,12 @@ Other: # 1.7.0 -This release brings support for MacOS! +This release brings support for MacOS! The basics things are working, but it is far from feature parity with Linux. I developed this in a VM, so bugs on real hardware are likely. If you have a Mac and no idea what to do with your free time, i am very happy to accept pull requests / work on issues. -A lot of things were changed under the hood to make this possible, which should bring better performance and stability on all platforms. +A lot of things were changed under the hood to make this possible, which should bring better performance and stability on all platforms. Besides that, the following things have changed: @@ -208,7 +217,7 @@ Features: * Load `/etc/fastfetch/config.conf` before user config * Disk: print one decimal point if size < 100GB * `--title-fqdn` option, to print fully qualified domain name instead of host name in title - + Logos: * updated old NixOS logo From e292470adebdaf68c4d6c3a254425c347d401991 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 19:25:59 +0800 Subject: [PATCH 6/7] Release 1.8.2 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7152118713..3b777ba3b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.12.0) # target_link_libraries with OBJECT libs & project homepage url project(fastfetch - VERSION 1.8.1 + VERSION 1.8.2 LANGUAGES C DESCRIPTION "Fast system information tool" HOMEPAGE_URL "https://github.com/LinusDierheimer/fastfetch" From c04b421f2627abac276b89ede275012cee1bf62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sat, 31 Dec 2022 19:33:44 +0800 Subject: [PATCH 7/7] README: fix unexpectedly concated paragraphs --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index d7719aa763..54d51b7eca 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,10 @@ Fastfetch is a [neofetch](https://github.com/dylanaraps/neofetch)-like tool for ## Customization With customization and speed being two competing goals, this project actually builds two executables. -The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `~/.config/fastfetch/config.conf`. To view the available options run `fastfetch --help`. -The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). + +* The main one being `fastfetch`, which can be very greatly configured via flags. These flags can be made persistent in `~/.config/fastfetch/config.conf`. To view the available options run `fastfetch --help`. +* The second executable being built is called `flashfetch`, which is configured at compile time to eliminate any possible overhead. Configuration of it can be very easily done in [`src/flashfetch.c`](src/flashfetch.c). + At the moment the performance difference is measurable, but too small to be human recognizable. But the leap will get bigger with more and more options coming, and on slow machines this might actually make a difference. There are some premade config files in [`presets`](presets), including the ones used for the screenshots above. You can load them using `--load-config `. They may also serve as a good example for format arguments. @@ -23,7 +25,6 @@ There are some premade config files in [`presets`](presets), including the ones Fastfetch dynamically loads needed libraries if they are available. On Linux, its only hard dependencies are `libc` (any implementation of the c standard library), `libdl` and [`libpthread`](https://man7.org/linux/man-pages/man7/pthreads.7.html) (if built with multithreading support). They are all shipped with [`glibc`](https://www.gnu.org/software/libc/), which is already installed on most linux distributions. - The following libraries are used if present at runtime: ### Linux and FreeBSD