Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,14 +171,13 @@ jobs:
run: cmake --build . --target fastfetch --target flashfetch # Makes no sense to install exes to /usr/bin for Windows

- name: copy necessary dlls
run: cp /usr/bin/msys-2.0.dll /clang64/bin/*.dll .
run: cp /usr/bin/msys-2.0.dll /clang64/bin/{libcjson,libOpenCL,vulkan-1}.dll .

# Crashes on start for some reason, but it provides binaries at least. Needs investigation.
# - name: run fastfetch
# run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all
- name: run fastfetch
run: ./fastfetch --recache --disable-linewrap false --hide-cursor false --show-errors true --load-config presets/all

# - name: run flashfetch
# run: ./flashfetch
- name: run flashfetch
run: ./flashfetch

- name: upload artifacts
uses: actions/upload-artifact@v3
Expand Down
6 changes: 4 additions & 2 deletions src/detection/battery/battery_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
ffStrbufInit(&battery->modelName);
ffGetWmiObjString(pclsObj, L"Name", &battery->modelName);

uint64_t chemistry;
uint64_t chemistry = 0;
ffGetWmiObjUnsigned(pclsObj, L"Chemistry", &chemistry);
switch(chemistry)
{
Expand All @@ -38,6 +38,7 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
case 6: ffStrbufInitS(&battery->technology, "Lithium-ion"); break;
case 7: ffStrbufInitS(&battery->technology, "Zinc air"); break;
case 8: ffStrbufInitS(&battery->technology, "Lithium Polymer"); break;
default: ffStrbufInit(&battery->technology); break;
}

uint64_t capacity;
Expand All @@ -59,12 +60,13 @@ const char* ffDetectBatteryImpl(FFinstance* instance, FFlist* results)
case 9: ffStrbufInitS(&battery->status, "Charging and Critical"); break;
case 10: ffStrbufInitS(&battery->status, "Undefined"); break;
case 11: ffStrbufInitS(&battery->status, "Partially Charged"); break;
default: ffStrbufInit(&battery->status); break;
}

battery->temperature = FF_BATTERY_TEMP_UNSET;
}

pclsObj->Release();
if(pclsObj) pclsObj->Release();
pEnumerator->Release();
return nullptr;
}
4 changes: 1 addition & 3 deletions src/detection/font/font_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ void ffDetectFontImpl(const FFinstance* instance, FFFontResult* result)
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;

pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);

if(uReturn == 0)
if(FAILED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) || uReturn == 0)
{
ffStrbufInitS(&result->error, "No WMI result returned");
pEnumerator->Release();
Expand Down
2 changes: 1 addition & 1 deletion src/detection/gpu/gpu_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const char* ffDetectGPUImpl(FFlist* gpus, const FFinstance* instance)
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
}

pclsObj->Release();
if(pclsObj) pclsObj->Release();
pEnumerator->Release();
return nullptr;
}
4 changes: 1 addition & 3 deletions src/detection/host/host_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ extern "C" void ffDetectHostImpl(FFHostResult* host)
IWbemClassObject *pclsObj = NULL;
ULONG uReturn = 0;

pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);

if(uReturn == 0)
if(FAILED(pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn)) || uReturn == 0)
{
ffStrbufInitS(&host->error, "No Wmi result returned");
pEnumerator->Release();
Expand Down
17 changes: 12 additions & 5 deletions src/detection/localip/localip_windows.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,18 @@ static void addNewIp(FFlist* list, const wchar_t* name, const char* addr, bool i
FFLocalIpResult* ip = (FFLocalIpResult*) ffListAdd(list);

int len = (int)wcslen(name);
int size_needed = WideCharToMultiByte(CP_UTF8, 0, name, len, NULL, 0, NULL, NULL);
ffStrbufInitA(&ip->name, (uint32_t)size_needed + 1);
WideCharToMultiByte(CP_UTF8, 0, name, len, ip->name.chars, size_needed, NULL, NULL);
ip->name.length = (uint32_t)size_needed;
ip->name.chars[size_needed] = '\0';
if(len > 0)
{
int size_needed = WideCharToMultiByte(CP_UTF8, 0, name, len, NULL, 0, NULL, NULL);
ffStrbufInitA(&ip->name, (uint32_t)size_needed + 1);
WideCharToMultiByte(CP_UTF8, 0, name, len, ip->name.chars, size_needed, NULL, NULL);
ip->name.length = (uint32_t)size_needed;
ip->name.chars[size_needed] = '\0';
}
else
{
ffStrbufInitS(&ip->name, "*");
}

ffStrbufInitS(&ip->addr, addr);
ip->ipv6 = ipv6;
Expand Down
12 changes: 10 additions & 2 deletions src/detection/os/os_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,21 @@ void ffDetectOSImpl(FFOSResult* os, const FFinstance* instance)
return;
}

ffGetWmiObjString(pclsObj, L"Caption", &os->variant); // Microsoft Windows 11 家庭中文版
ffGetWmiObjString(pclsObj, L"Caption", &os->variant);
if(ffStrbufStartsWithS(&os->variant, "Microsoft Windows "))
{
ffStrbufAppendS(&os->name, "Microsoft Windows");
ffStrbufAppendS(&os->prettyName, "Windows");

ffStrbufSubstrAfter(&os->variant, strlen("Microsoft Windows ") - 1); // 11 家庭中文版
ffStrbufSubstrAfter(&os->variant, strlen("Microsoft Windows ") - 1);

if(ffStrbufStartsWithS(&os->variant, "Server "))
{
ffStrbufAppendS(&os->name, " Server");
ffStrbufAppendS(&os->prettyName, " Server");
ffStrbufSubstrAfter(&os->variant, strlen(" Server") - 1);
}

uint32_t index = ffStrbufFirstIndexC(&os->variant, ' ');
ffStrbufAppendNS(&os->version, index, os->variant.chars);
ffStrbufSubstrAfter(&os->variant, index);
Expand Down
10 changes: 9 additions & 1 deletion src/detection/terminalshell/terminalshell_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,15 @@ static uint32_t getShellInfo(FFTerminalShellResult* result, uint32_t pid)
}
else if(ffStrbufIgnCaseCompS(&result->shellPrettyName, "powershell") == 0)
ffStrbufSetS(&result->shellPrettyName, "Windows PowerShell");
else if(ffStrbufIgnCaseCompS(&result->shellPrettyName, "powershell_ise") == 0)
ffStrbufSetS(&result->shellPrettyName, "Windows PowerShell ISE");
else if(ffStrbufIgnCaseCompS(&result->shellPrettyName, "cmd") == 0)
ffStrbufSetS(&result->shellPrettyName, "Command Prompt");
else if(ffStrbufIgnCaseCompS(&result->terminalPrettyName, "explorer") == 0)
{
ffStrbufSetS(&result->terminalPrettyName, "Windows Explorer"); // Started without shell
return 0;
}

return ppid;
}
Expand All @@ -99,6 +106,8 @@ static uint32_t getTerminalInfo(FFTerminalShellResult* result, uint32_t pid)
ffStrbufSetS(&result->terminalPrettyName, "Windows Terminal");
else if(ffStrbufIgnCaseCompS(&result->terminalPrettyName, "conhost") == 0)
ffStrbufSetS(&result->terminalPrettyName, "Console Window Host");
else if(ffStrbufIgnCaseCompS(&result->terminalPrettyName, "explorer") == 0)
ffStrbufSetS(&result->terminalPrettyName, "Windows Explorer");

return ppid;
}
Expand Down Expand Up @@ -148,7 +157,6 @@ const FFTerminalShellResult* ffDetectTerminalShell(const FFinstance* instance)
return &result;

// TODO: handle nested shells
// TODO: handle running without shells ( dblclick exe in Windows Explorer )

ppid = getTerminalInfo(&result, ppid);
if(ppid == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/detection/users/users_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ void ffDetectUsers(FFlist* users, FFstrbuf* error)
if(users->length == 0)
ffStrbufAppendS(error, "Unable to detect users");

pclsObj->Release();
if(pclsObj) pclsObj->Release();
pEnumerator->Release();
}
7 changes: 4 additions & 3 deletions src/util/windows/wmi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <synchapi.h>
#include <wchar.h>
#include <math.h>

//https://learn.microsoft.com/en-us/windows/win32/wmisdk/example--getting-wmi-data-from-the-local-computer
//https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/computer-system-hardware-classes
Expand Down Expand Up @@ -232,7 +233,7 @@ bool ffGetWmiObjSigned(IWbemClassObject* obj, const wchar_t* key, int64_t* integ
case VT_UI4: *integer = (int64_t)vtProp.uintVal; break;
case VT_UI8: *integer = (int64_t)vtProp.ullVal; break;
case VT_BOOL: *integer = vtProp.boolVal != VARIANT_FALSE; break;
default: result = false;
default: *integer = 0; result = false;
}
}
VariantClear(&vtProp);
Expand Down Expand Up @@ -266,7 +267,7 @@ bool ffGetWmiObjUnsigned(IWbemClassObject* obj, const wchar_t* key, uint64_t* in
case VT_UI4: *integer = vtProp.uintVal; break;
case VT_UI8: *integer = vtProp.ullVal; break;
case VT_BOOL: *integer = vtProp.boolVal != VARIANT_FALSE; break;
default: result = false;
default: *integer = 0; result = false;
}
}
VariantClear(&vtProp);
Expand Down Expand Up @@ -302,7 +303,7 @@ bool ffGetWmiObjReal(IWbemClassObject* obj, const wchar_t* key, double* real)
case VT_R4: *real = vtProp.fltVal; break;
case VT_R8: *real = vtProp.dblVal; break;
case VT_BOOL: *real = vtProp.boolVal != VARIANT_FALSE; break;
default: result = false;
default: *real = NAN; result = false;
}
}
VariantClear(&vtProp);
Expand Down