Global (Windows): adds more FF_DEBUG

This commit is contained in:
Carter Li
2026-10-03 11:57:46 +08:00
parent b201fd2db9
commit ae1288d087
40 changed files with 290 additions and 61 deletions
+9 -2
View File
@@ -1,4 +1,5 @@
#include "common/binary.h"
#include "common/debug.h"
#include "common/io.h"
#include "common/strutil.h"
#include "common/windows/nt.h"
@@ -17,22 +18,28 @@
const char* ffBinaryExtractStrings(const char* peFile, bool (*cb)(const char* str, uint32_t len, void* userdata), void* userdata, uint32_t minLength) {
FF_AUTO_CLOSE_FD HANDLE hFile = CreateFileA(peFile, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
FF_DEBUG("CreateFileA() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateFileA() failed";
}
FF_AUTO_CLOSE_FD HANDLE hSection = nullptr;
if (!NT_SUCCESS(NtCreateSection(&hSection, SECTION_MAP_READ, nullptr, nullptr, PAGE_READONLY, SEC_COMMIT, hFile))) {
NTSTATUS status = NtCreateSection(&hSection, SECTION_MAP_READ, nullptr, nullptr, PAGE_READONLY, SEC_COMMIT, hFile);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtCreateSection() failed: %s", ffDebugNtStatus(status));
return "NtCreateSection() failed";
}
PVOID base = nullptr;
SIZE_T viewSize = 0;
if (!NT_SUCCESS(NtMapViewOfSection(hSection, NtCurrentProcess(), &base, 0, 0, nullptr, &viewSize, ViewUnmap, 0, PAGE_READONLY))) {
status = NtMapViewOfSection(hSection, NtCurrentProcess(), &base, 0, 0, nullptr, &viewSize, ViewUnmap, 0, PAGE_READONLY);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtMapViewOfSection() failed: %s", ffDebugNtStatus(status));
return "NtMapViewOfSection() failed";
}
PIMAGE_NT_HEADERS ntHeaders = RtlImageNtHeader(base);
if (!ntHeaders) {
FF_DEBUG("RtlImageNtHeader() failed");
NtUnmapViewOfSection(NtCurrentProcess(), base);
return "RtlImageNtHeader() failed";
}
+7 -2
View File
@@ -441,7 +441,9 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
}
while (true) {
if (NtWaitForSingleObject(hInput, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000 }) != STATUS_WAIT_0) {
NTSTATUS status = NtWaitForSingleObject(hInput, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) FF_IO_TERM_RESP_WAIT_MS * -10000 });
if (status != STATUS_WAIT_0) {
FF_DEBUG("NtWaitForSingleObject() failed or timeout: %s", ffDebugNtStatus(status));
SetConsoleMode(hInput, inputMode);
return "NtWaitForSingleObject() failed or timeout";
}
@@ -471,7 +473,9 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
while (true) {
DWORD bytes = 0;
if (!ReadFile(hInput, buffer + bytesRead, (DWORD) (sizeof(buffer) - 1 - bytesRead), &bytes, nullptr) || bytes == 0) {
BOOL readOk = ReadFile(hInput, buffer + bytesRead, (DWORD) (sizeof(buffer) - 1 - bytesRead), &bytes, nullptr);
if (!readOk || bytes == 0) {
FF_DEBUG("ReadFile() %s, bytes=%lu: %s", readOk ? "returned no data" : "failed", bytes, readOk ? "no error" : ffDebugWin32Error(GetLastError()));
va_end(args);
return "ReadFile() failed";
}
@@ -490,6 +494,7 @@ const char* ffGetTerminalResponse(const char* request, int nParams, const char*
if (ret <= 0) {
va_end(args);
FF_DEBUG("vsscanf(buffer, format, args) failed: %s", strerror(errno));
return "vsscanf(buffer, format, args) failed";
}
if (ret >= nParams) {
+16 -11
View File
@@ -14,8 +14,9 @@ static LPFN_CONNECTEX ConnectEx;
static const char* initWsaData(WSADATA* wsaData) {
FF_DEBUG("Initializing WinSock");
if (WSAStartup(MAKEWORD(2, 2), wsaData) != 0) {
FF_DEBUG("WSAStartup() failed");
int ret = WSAStartup(MAKEWORD(2, 2), wsaData);
if (ret != 0) {
FF_DEBUG("WSAStartup() failed: %s", ffDebugWin32Error((DWORD) ret));
return "WSAStartup() failed";
}
@@ -28,7 +29,7 @@ static const char* initWsaData(WSADATA* wsaData) {
// Dummy socket needed for WSAIoctl
SOCKET sockfd = WSASocketW(AF_INET, SOCK_STREAM, 0, nullptr, 0, 0);
if (sockfd == INVALID_SOCKET) {
FF_DEBUG("WSASocketW(AF_INET, SOCK_STREAM) failed");
FF_DEBUG("WSASocketW(AF_INET, SOCK_STREAM) failed: %s", ffDebugWin32Error((DWORD) WSAGetLastError()));
WSACleanup();
return "WSASocketW(AF_INET, SOCK_STREAM) failed";
}
@@ -36,7 +37,7 @@ static const char* initWsaData(WSADATA* wsaData) {
DWORD dwBytes;
GUID guid = WSAID_CONNECTEX;
if (WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER, &guid, sizeof(guid), &ConnectEx, sizeof(ConnectEx), &dwBytes, nullptr, nullptr) != 0) {
FF_DEBUG("WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER) failed");
FF_DEBUG("WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER) failed: %s", ffDebugWin32Error((DWORD) WSAGetLastError()));
closesocket(sockfd);
WSACleanup();
return "WSAIoctl(sockfd, SIO_GET_EXTENSION_FUNCTION_POINTER) failed";
@@ -90,8 +91,9 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho
};
wchar_t hostW[256];
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(hostW, (ULONG) sizeof(hostW), nullptr, host, (ULONG) strlen(host) + 1))) {
FF_DEBUG("Failed to convert host to wide string: %s", host);
NTSTATUS status = RtlUTF8ToUnicodeN(hostW, (ULONG) sizeof(hostW), nullptr, host, (ULONG) strlen(host) + 1);
if (!NT_SUCCESS(status)) {
FF_DEBUG("Failed to convert host to wide string: %s: %s", host, ffDebugNtStatus(status));
return "Failed to convert host to wide string";
}
@@ -99,14 +101,15 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho
_itow(port, portW, 10);
FF_DEBUG("Resolving address: %s:%u (%s)", host, port, state->ipv6 ? "IPv6" : "IPv4");
if (GetAddrInfoW(hostW, portW, &hints, &addr) != 0) {
FF_DEBUG("GetAddrInfoW() failed");
int ret = GetAddrInfoW(hostW, portW, &hints, &addr);
if (ret != 0) {
FF_DEBUG("GetAddrInfoW() failed: %s", ffDebugWin32Error((DWORD) ret));
return "GetAddrInfoW() failed";
}
state->sockfd = WSASocketW(addr->ai_family, addr->ai_socktype, addr->ai_protocol, nullptr, 0, 0);
if (state->sockfd == INVALID_SOCKET) {
FF_DEBUG("WSASocketW() failed");
FF_DEBUG("WSASocketW() failed: %s", ffDebugWin32Error((DWORD) WSAGetLastError()));
FreeAddrInfoW(addr);
return "WSASocketW() failed";
}
@@ -149,8 +152,9 @@ const char* ffNetworkingSendHttpRequest(FFNetworkingState* state, const char* ho
// Initialize overlapped structure with WSA event for asynchronous I/O
state->overlapped = (OVERLAPPED) {};
if (!NT_SUCCESS(NtCreateEvent(&state->overlapped.hEvent, EVENT_ALL_ACCESS, nullptr, NotificationEvent, FALSE))) {
FF_DEBUG("NtCreateEvent() failed");
NTSTATUS eventStatus = NtCreateEvent(&state->overlapped.hEvent, EVENT_ALL_ACCESS, nullptr, NotificationEvent, FALSE);
if (!NT_SUCCESS(eventStatus)) {
FF_DEBUG("NtCreateEvent() failed: %s", ffDebugNtStatus(eventStatus));
closesocket(state->sockfd);
FreeAddrInfoW(addr);
state->sockfd = INVALID_SOCKET;
@@ -417,6 +421,7 @@ const char* ffNetworkingRecvHttpResponse(FFNetworkingState* state, FFstrbuf* buf
}
if (chunked && !ffNetworkingDecodeChunked(buffer, &headerEnd)) {
FF_DEBUG("Failed to decode chunked response");
return "Failed to decode chunked response";
}
+18 -4
View File
@@ -1,4 +1,5 @@
#include "fastfetch.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/processing.h"
#include "common/io.h"
@@ -100,6 +101,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
0,
nullptr);
if (hChildPipeRead == INVALID_HANDLE_VALUE) {
FF_DEBUG("CreateNamedPipeW() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateNamedPipeW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";
}
@@ -116,6 +118,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
0,
nullptr);
if (hChildPipeWrite == INVALID_HANDLE_VALUE) {
FF_DEBUG("CreateFileW() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateFileW(L\"\\\\.\\pipe\\FASTFETCH-$(PID)\") failed";
}
@@ -141,7 +144,9 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
argvToCmdline(argv, &buf);
uint32_t cmdlineBytes = (buf.length + 1) * sizeof(wchar_t);
cmdline = malloc(cmdlineBytes);
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(cmdline, cmdlineBytes, nullptr, buf.chars, buf.length + 1))) {
NTSTATUS status = RtlUTF8ToUnicodeN(cmdline, cmdlineBytes, nullptr, buf.chars, buf.length + 1);
if (!NT_SUCCESS(status)) {
FF_DEBUG("RtlUTF8ToUnicodeN() failed: %s", ffDebugNtStatus(status));
return "RtlUTF8ToUnicodeN() failed";
}
}
@@ -165,6 +170,7 @@ const char* ffProcessSpawn(char* const argv[], bool useStdErr, FFNativeFD stdinF
if (GetLastError() == ERROR_FILE_NOT_FOUND) {
return "command not found";
}
FF_DEBUG("CreateProcessW() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateProcessW() failed";
}
@@ -197,7 +203,9 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
handle->pid = INVALID_HANDLE_VALUE;
handle->pipeRead = INVALID_HANDLE_VALUE;
if (timeout >= 0 && !NT_SUCCESS(NtCreateEvent(&hReadEvent, EVENT_ALL_ACCESS, nullptr, SynchronizationEvent, FALSE))) {
NTSTATUS createStatus = STATUS_SUCCESS;
if (timeout >= 0 && !NT_SUCCESS(createStatus = NtCreateEvent(&hReadEvent, EVENT_ALL_ACCESS, nullptr, SynchronizationEvent, FALSE))) {
FF_DEBUG("NtCreateEvent() failed: %s", ffDebugNtStatus(createStatus));
return "NtCreateEvent() failed";
}
@@ -216,7 +224,8 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
nullptr,
nullptr);
if (status == STATUS_PENDING) {
switch (NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 })) {
NTSTATUS waitStatus = NtWaitForSingleObject(hReadEvent, FALSE, &(LARGE_INTEGER) { .QuadPart = (int64_t) timeout * -10000 });
switch (waitStatus) {
case STATUS_WAIT_0:
status = iosb.Status;
break;
@@ -227,6 +236,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
}
default:
FF_DEBUG("NtWaitForSingleObject(hReadEvent) failed: %s", ffDebugNtStatus(waitStatus));
terminateChildProcess(hProcess, hChildPipeRead, hReadEvent, &iosb);
return "NtWaitForSingleObject(hReadEvent) failed";
}
@@ -237,6 +247,7 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
}
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtReadFile(hChildPipeRead) failed: %s", ffDebugNtStatus(status));
terminateChildProcess(hProcess, hChildPipeRead, nullptr, &iosb);
return "NtReadFile(hChildPipeRead) failed";
}
@@ -248,12 +259,15 @@ const char* ffProcessReadOutput(FFProcessHandle* handle, FFstrbuf* buffer) {
exit: {
PROCESS_BASIC_INFORMATION info = {};
ULONG size;
if (NT_SUCCESS(NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), &size))) {
NTSTATUS status = NtQueryInformationProcess(hProcess, ProcessBasicInformation, &info, sizeof(info), &size);
if (NT_SUCCESS(status)) {
assert(size == sizeof(info));
if (info.ExitStatus != STILL_ACTIVE && info.ExitStatus != 0) {
FF_DEBUG("Child process exited with an error");
return "Child process exited with an error";
}
} else {
FF_DEBUG("NtQueryInformationProcess(ProcessBasicInformation) failed: %s", ffDebugNtStatus(status));
return "NtQueryInformationProcess(ProcessBasicInformation) failed";
}
}
+8
View File
@@ -1,4 +1,5 @@
#include "com.h"
#include "common/debug.h"
#include <stdlib.h>
@@ -14,15 +15,19 @@ static const char* doInitCom() {
if (FAILED(res)) {
switch (res) {
case E_INVALIDARG:
FF_DEBUG("RoInitialize() failed: invalid argument: 0x%08lX (%s)", res, ffDebugHResult(res));
return "RoInitialize() failed: invalid argument";
case E_OUTOFMEMORY:
FF_DEBUG("RoInitialize() failed: out of memory: 0x%08lX (%s)", res, ffDebugHResult(res));
return "RoInitialize() failed: out of memory";
case E_UNEXPECTED:
FF_DEBUG("RoInitialize() failed: unexpected error: 0x%08lX (%s)", res, ffDebugHResult(res));
return "RoInitialize() failed: unexpected error";
case RPC_E_CHANGED_MODE:
// COM was already initialized with a different concurrency model
return nullptr;
default:
FF_DEBUG("RoInitialize() failed: unknown error: 0x%08lX (%s)", res, ffDebugHResult(res));
return "RoInitialize() failed: unknown error";
}
}
@@ -42,13 +47,16 @@ static const char* doInitCom() {
if (FAILED(res)) {
switch (res) {
case E_INVALIDARG:
FF_DEBUG("CoInitializeEx() failed: invalid argument: 0x%08lX (%s)", res, ffDebugHResult(res));
return "CoInitializeEx() failed: invalid argument";
case E_OUTOFMEMORY:
FF_DEBUG("CoInitializeEx() failed: out of memory: 0x%08lX (%s)", res, ffDebugHResult(res));
return "CoInitializeEx() failed: out of memory";
case RPC_E_CHANGED_MODE:
// COM was already initialized with a different concurrency model
return nullptr;
default:
FF_DEBUG("CoInitializeEx() failed: unknown error: 0x%08lX (%s)", res, ffDebugHResult(res));
return "CoInitializeEx() failed: unknown error";
}
}
+1
View File
@@ -66,6 +66,7 @@ static const char* queryWmiAllData(const GUID* guid, [[maybe_unused]] const char
}
if (*pBufferSize == 0) {
FF_DEBUG("WMI: WmiQueryAllDataW(nullptr) returned no data");
return "WmiQueryAllDataW(nullptr) returned no data";
}
+3
View File
@@ -1,4 +1,5 @@
#include "bios.h"
#include "common/debug.h"
#include "common/smbios.h"
#ifdef _WIN32
@@ -46,11 +47,13 @@ static_assert(offsetof(FFSmbiosBios, ExtendedBiosRomSize) == 0x18,
const char* ffDetectBios(FFBiosResult* bios) {
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
if (!smbiosTable) {
FF_DEBUG("BIOS: failed to get SMBIOS data");
return "Failed to get SMBIOS data";
}
const FFSmbiosBios* data = (const FFSmbiosBios*) (*smbiosTable)[FF_SMBIOS_TYPE_BIOS];
if (!data) {
FF_DEBUG("BIOS: section is not found in SMBIOS data");
return "BIOS section is not found in SMBIOS data";
}
@@ -1,4 +1,5 @@
#include "bluetooth.h"
#include "common/debug.h"
#include "common/library.h"
#include "common/mallocHelper.h"
#include "common/windows/unicode.h"
@@ -64,6 +65,7 @@ static const char* detectBattery(FFlist* devices) {
// not in the media class at all, so narrowing the filter would lose it.
CONFIGRET status = CM_Get_Device_ID_List_SizeW(&idListLength, GUID_DEVCLASS_MEDIA_STRING, CM_GETIDLIST_FILTER_PRESENT);
if (status != CR_SUCCESS) {
FF_DEBUG("CM_Get_Device_ID_List_SizeW failed: %s", ffDebugConfigRet(status));
return "CM_Get_Device_ID_List_SizeW failed";
}
@@ -73,11 +75,13 @@ static const char* detectBattery(FFlist* devices) {
FF_AUTO_FREE wchar_t* idList = (wchar_t*) malloc((size_t) idListLength * sizeof(wchar_t));
if (!idList) {
FF_DEBUG("malloc() failed");
return "malloc() failed";
}
status = CM_Get_Device_ID_ListW(GUID_DEVCLASS_MEDIA_STRING, idList, idListLength, CM_GETIDLIST_FILTER_PRESENT);
if (status != CR_SUCCESS) {
FF_DEBUG("CM_Get_Device_ID_ListW failed: %s", ffDebugConfigRet(status));
return "CM_Get_Device_ID_ListW failed";
}
@@ -137,6 +141,7 @@ static const char* detectClassic(FFBluetoothOptions* options, FFlist* devices /*
&btdi);
if (!hFind) {
if (GetLastError() != ERROR_NO_MORE_ITEMS) {
FF_DEBUG("BluetoothFindFirstDevice() failed: %s", ffDebugWin32Error(GetLastError()));
return "BluetoothFindFirstDevice() failed";
}
// "Nothing found" is not an error here: this search only ever sees BR/EDR devices, and a
+14 -4
View File
@@ -1,5 +1,6 @@
extern "C" {
#include "bluetooth.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/percent.h"
#include "common/strutil.h"
@@ -280,24 +281,32 @@ extern "C" const char* ffBluetoothDetectLe(FFBluetoothOptions* options, FFlist*
}
FF_AUTO_RELEASE_COM_OBJECT abi_t<winrt::Windows::Devices::Bluetooth::IBluetoothLEDeviceStatics2>* ledeviceStatics = nullptr;
if (FAILED(ffGetActivationFactory<winrt::Windows::Devices::Bluetooth::IBluetoothLEDeviceStatics2>(L"Windows.Devices.Bluetooth.BluetoothLEDevice", &ledeviceStatics)) || !ledeviceStatics) {
HRESULT ledeviceHr = ffGetActivationFactory<winrt::Windows::Devices::Bluetooth::IBluetoothLEDeviceStatics2>(L"Windows.Devices.Bluetooth.BluetoothLEDevice", &ledeviceStatics);
if (FAILED(ledeviceHr) || !ledeviceStatics) {
FF_DEBUG("winrt: RoGetActivationFactory(BluetoothLEDevice) failed: %s", ffDebugHResult(ledeviceHr));
return "winrt: RoGetActivationFactory(BluetoothLEDevice) failed";
}
[[gnu::cleanup(ffDeleteHstring)]] HSTRING selector = nullptr;
if (FAILED(ledeviceStatics->GetDeviceSelectorFromPairingState(true, reinterpret_cast<void**>(&selector))) || !selector) {
HRESULT selectorHr = ledeviceStatics->GetDeviceSelectorFromPairingState(true, reinterpret_cast<void**>(&selector));
if (FAILED(selectorHr) || !selector) {
FF_DEBUG("winrt: GetDeviceSelectorFromPairingState() failed: %s", ffDebugHResult(selectorHr));
return "winrt: GetDeviceSelectorFromPairingState() failed";
}
// Without additional properties the map carries only the eight generic ones, and every AEP key
// is absent, so the list is not optional.
FF_AUTO_RELEASE_COM_OBJECT abi_t<winrt::Windows::Foundation::Collections::IIterable<winrt::hstring>>* properties = nullptr;
if (FAILED(ffWinrtCreateHstringIterable(ffBluetoothLeProperties, (uint32_t) ARRAY_SIZE(ffBluetoothLeProperties), &properties)) || !properties) {
HRESULT propertiesHr = ffWinrtCreateHstringIterable(ffBluetoothLeProperties, (uint32_t) ARRAY_SIZE(ffBluetoothLeProperties), &properties);
if (FAILED(propertiesHr) || !properties) {
FF_DEBUG("winrt: building the additional-properties list failed: %s", ffDebugHResult(propertiesHr));
return "winrt: building the additional-properties list failed";
}
FF_AUTO_RELEASE_COM_OBJECT abi_t<winrt::Windows::Devices::Enumeration::IDeviceInformationStatics>* enumerationStatics = nullptr;
if (FAILED(ffGetActivationFactory<winrt::Windows::Devices::Enumeration::IDeviceInformationStatics>(L"Windows.Devices.Enumeration.DeviceInformation", &enumerationStatics)) || !enumerationStatics) {
HRESULT deviceInfoHr = ffGetActivationFactory<winrt::Windows::Devices::Enumeration::IDeviceInformationStatics>(L"Windows.Devices.Enumeration.DeviceInformation", &enumerationStatics);
if (FAILED(deviceInfoHr) || !enumerationStatics) {
FF_DEBUG("winrt: RoGetActivationFactory(DeviceInformation) failed: %s", ffDebugHResult(deviceInfoHr));
return "winrt: RoGetActivationFactory(DeviceInformation) failed";
}
@@ -307,6 +316,7 @@ extern "C" const char* ffBluetoothDetectLe(FFBluetoothOptions* options, FFlist*
},
&found);
if (FAILED(hr) || !found) {
FF_DEBUG("winrt: DeviceInformation::FindAllAsync() failed: %s", ffDebugHResult(hr));
return "winrt: DeviceInformation::FindAllAsync() failed";
}
@@ -1,4 +1,5 @@
#include "bluetoothradio.h"
#include "common/debug.h"
#include "common/library.h"
#include "common/io.h"
#include "common/windows/unicode.h"
@@ -64,8 +65,10 @@ const char* ffDetectBluetoothRadio(FFlist* devices /* FFBluetoothRadioResult */)
&hRadio);
if (!hFind) {
if (GetLastError() == ERROR_NO_MORE_ITEMS) {
FF_DEBUG("No Bluetooth radios found or service disabled");
return "No Bluetooth radios found or service disabled";
} else {
FF_DEBUG("BluetoothFindFirstRadio() failed: %s", ffDebugWin32Error(GetLastError()));
return "BluetoothFindFirstRadio() failed";
}
}
+3
View File
@@ -1,4 +1,5 @@
#include "board.h"
#include "common/debug.h"
#include "common/smbios.h"
typedef struct [[gnu::packed]] FFSmbiosBaseboard {
@@ -23,11 +24,13 @@ static_assert(offsetof(FFSmbiosBaseboard, ContainedObjectHandles) == 0x0F,
const char* ffDetectBoard(FFBoardResult* board) {
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
if (!smbiosTable) {
FF_DEBUG("Baseboard information: failed to get SMBIOS data");
return "Failed to get SMBIOS data";
}
const FFSmbiosBaseboard* data = (const FFSmbiosBaseboard*) (*smbiosTable)[FF_SMBIOS_TYPE_BASEBOARD_INFO];
if (!data) {
FF_DEBUG("Baseboard information: section is not found in SMBIOS data");
return "Baseboard information section is not found in SMBIOS data";
}
+16 -4
View File
@@ -1,4 +1,5 @@
#include "bootmgr.h"
#include "common/debug.h"
#include "efi_helper.h"
#include "common/io.h"
#include "common/windows/nt.h"
@@ -8,7 +9,9 @@
const char* enablePrivilege(const wchar_t* privilege) {
FF_AUTO_CLOSE_FD HANDLE token = nullptr;
if (!NT_SUCCESS(NtOpenProcessToken(NtCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token))) {
NTSTATUS status = NtOpenProcessToken(NtCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &token);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtOpenProcessToken() failed: %s", ffDebugNtStatus(status));
return "NtOpenProcessToken() failed";
}
@@ -18,15 +21,18 @@ const char* enablePrivilege(const wchar_t* privilege) {
(LUID_AND_ATTRIBUTES) { .Attributes = SE_PRIVILEGE_ENABLED } },
};
if (!LookupPrivilegeValueW(nullptr, privilege, &tp.Privileges[0].Luid)) {
FF_DEBUG("LookupPrivilegeValue() failed: %s", ffDebugWin32Error(GetLastError()));
return "LookupPrivilegeValue() failed";
}
NTSTATUS status = NtAdjustPrivilegesToken(token, false, &tp, sizeof(tp), nullptr, nullptr);
status = NtAdjustPrivilegesToken(token, false, &tp, sizeof(tp), nullptr, nullptr);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtAdjustPrivilegesToken() failed: %s", ffDebugNtStatus(status));
return "NtAdjustPrivilegesToken() failed";
}
if (status == STATUS_NOT_ALL_ASSIGNED) {
FF_DEBUG("NtAdjustPrivilegesToken() did not assign the privilege: %s", ffDebugNtStatus(status));
return "The token does not have the specified privilege; try sudo please";
}
@@ -47,10 +53,13 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
};
ULONG size = sizeof(result->order);
if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"BootCurrent"), &efiGlobalGuid, &result->order, &size, nullptr))) {
NTSTATUS status = NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(L"BootCurrent"), &efiGlobalGuid, &result->order, &size, nullptr);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtQuerySystemEnvironmentValueEx(BootCurrent) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemEnvironmentValueEx(BootCurrent) failed";
}
if (size != sizeof(result->order)) {
FF_DEBUG("NtQuerySystemEnvironmentValueEx(BootCurrent) returned unexpected size");
return "NtQuerySystemEnvironmentValueEx(BootCurrent) returned unexpected size";
}
@@ -58,10 +67,13 @@ const char* ffDetectBootmgr(FFBootmgrResult* result) {
wchar_t key[9];
swprintf(key, ARRAY_SIZE(key), L"Boot%04X", result->order);
size = sizeof(buffer);
if (!NT_SUCCESS(NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(key), &efiGlobalGuid, buffer, &size, nullptr))) {
status = NtQuerySystemEnvironmentValueEx(&(UNICODE_STRING) RTL_CONSTANT_STRING(key), &efiGlobalGuid, buffer, &size, nullptr);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtQuerySystemEnvironmentValueEx(Boot####) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemEnvironmentValueEx(Boot####) failed";
}
if (size < sizeof(FFEfiLoadOption) || size == ARRAY_SIZE(buffer)) {
FF_DEBUG("NtQuerySystemEnvironmentValueEx(Boot####) returned unexpected size");
return "NtQuerySystemEnvironmentValueEx(Boot####) returned unexpected size";
}
+11 -4
View File
@@ -1,5 +1,6 @@
extern "C" {
#include "camera.h"
#include "common/debug.h"
#include "common/library.h"
#include "common/windows/com.h"
}
@@ -22,20 +23,26 @@ extern "C" const char* ffDetectCamera([[maybe_unused]] FFlist* result) {
}
FF_AUTO_RELEASE_COM_OBJECT IMFAttributes* attrs = nullptr;
if (FAILED(ffMFCreateAttributes(&attrs, 1))) {
HRESULT hr = ffMFCreateAttributes(&attrs, 1);
if (FAILED(hr)) {
FF_DEBUG("MFCreateAttributes() failed: %s", ffDebugHResult(hr));
return "MFCreateAttributes() failed";
}
if (FAILED(attrs->SetGUID(
hr = attrs->SetGUID(
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID))) {
MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID);
if (FAILED(hr)) {
FF_DEBUG("SetGUID(MF_*) failed: %s", ffDebugHResult(hr));
return "SetGUID(MF_*) failed";
}
IMFActivate** devices = nullptr;
uint32_t count;
if (FAILED(ffMFEnumDeviceSources(attrs, &devices, &count))) {
hr = ffMFEnumDeviceSources(attrs, &devices, &count);
if (FAILED(hr)) {
FF_DEBUG("MFEnumDeviceSources() failed: %s", ffDebugHResult(hr));
return "MFEnumDeviceSources() failed";
}
+3
View File
@@ -1,4 +1,5 @@
#include "chassis.h"
#include "common/debug.h"
#include "common/smbios.h"
// 7.4
@@ -32,11 +33,13 @@ static_assert(offsetof(FFSmbiosSystemEnclosure, ContainedElements) == 0x15,
const char* ffDetectChassis(FFChassisResult* result) {
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
if (!smbiosTable) {
FF_DEBUG("System enclosure: failed to get SMBIOS data");
return "Failed to get SMBIOS data";
}
const FFSmbiosSystemEnclosure* data = (const FFSmbiosSystemEnclosure*) (*smbiosTable)[FF_SMBIOS_TYPE_SYSTEM_ENCLOSURE];
if (!data) {
FF_DEBUG("System enclosure: section is not found in SMBIOS data");
return "System enclosure is not found in SMBIOS data";
}
+5 -1
View File
@@ -1,5 +1,6 @@
extern "C" {
#include "codec.h"
#include "common/debug.h"
#include "common/library.h"
#include "common/windows/com.h"
#include "common/windows/unicode.h"
@@ -523,6 +524,7 @@ const char* detectD3d12va(FFCodecOptions* options, FFlist* result /*list of FFCo
});
if (result->length == resultLengthBefore) {
FF_DEBUG("No D3D12 video acceleration support");
return "No D3D12 video acceleration support";
}
@@ -539,7 +541,9 @@ const char* ffDetectCodecNative(FFCodecOptions* options, FFlist* result /*list o
}
FF_AUTO_RELEASE_COM_OBJECT IDXGIFactory1* factory = nullptr;
if (FAILED(ffCreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**) &factory)) || !factory) {
HRESULT hr = ffCreateDXGIFactory1(__uuidof(IDXGIFactory1), (void**) &factory);
if (FAILED(hr) || !factory) {
FF_DEBUG("CreateDXGIFactory1() failed: %s", ffDebugHResult(hr));
return "CreateDXGIFactory1() failed";
}
+37 -8
View File
@@ -1,4 +1,5 @@
#include "cpu.h"
#include "common/debug.h"
#include "common/endian.h"
#include "common/windows/registry.h"
#include "common/windows/nt.h"
@@ -34,23 +35,30 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
};
if (options->tempSensor.length > 0) {
if (!NT_SUCCESS(RtlUTF8ToUnicodeN(querySpec.Name, (ULONG) sizeof(querySpec.Name), nullptr, options->tempSensor.chars, (ULONG) options->tempSensor.length + 1))) {
NTSTATUS status = RtlUTF8ToUnicodeN(querySpec.Name, (ULONG) sizeof(querySpec.Name), nullptr, options->tempSensor.chars, (ULONG) options->tempSensor.length + 1);
if (!NT_SUCCESS(status)) {
FF_DEBUG("Invalid temp sensor string: %s", ffDebugNtStatus(status));
return "Invalid temp sensor string";
}
}
DWORD dataSize = 0;
if (PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
DWORD ret = PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, nullptr, 0, &dataSize);
if (ret != ERROR_NOT_ENOUGH_MEMORY) {
FF_DEBUG("PerfEnumerateCounterSetInstances() failed: %s", ffDebugWin32Error(ret));
return "PerfEnumerateCounterSetInstances() failed";
}
if (dataSize <= sizeof(PERF_INSTANCE_HEADER)) {
FF_DEBUG("No `Thermal Zone Information` instances found");
return "No `Thermal Zone Information` instances found";
}
{
FF_AUTO_FREE PERF_INSTANCE_HEADER* const pHead = malloc(dataSize);
if (PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, pHead, dataSize, &dataSize) != ERROR_SUCCESS) {
ret = PerfEnumerateCounterSetInstances(nullptr, &querySpec.Identifier.CounterSetGuid, pHead, dataSize, &dataSize);
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfEnumerateCounterSetInstances() failed to get instance headers: %s", ffDebugWin32Error(ret));
return "PerfEnumerateCounterSetInstances() failed to get instance headers";
}
@@ -70,6 +78,7 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
if (dataSize == 0) {
if (options->tempSensor.length > 0) {
FF_DEBUG("Unable to find CPU sensor");
return "Unable to find CPU sensor";
}
@@ -81,34 +90,45 @@ const char* detectThermalTemp(const FFCPUOptions* options, double* result) {
[[gnu::cleanup(ffPerfCloseQueryHandle)]]
HANDLE hQuery = nullptr;
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
ret = PerfOpenQueryHandle(nullptr, &hQuery);
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfOpenQueryHandle() failed: %s", ffDebugWin32Error(ret));
return "PerfOpenQueryHandle() failed";
}
if (PerfAddCounters(hQuery, &querySpec.Identifier, sizeof(querySpec)) != ERROR_SUCCESS) {
ret = PerfAddCounters(hQuery, &querySpec.Identifier, sizeof(querySpec));
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfAddCounters() failed: %s", ffDebugWin32Error(ret));
return "PerfAddCounters() failed";
}
if (querySpec.Identifier.Status != ERROR_SUCCESS) {
FF_DEBUG("PerfAddCounters() reports invalid identifier: %s", ffDebugWin32Error(querySpec.Identifier.Status));
return "PerfAddCounters() reports invalid identifier";
}
if (PerfQueryCounterData(hQuery, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
ret = PerfQueryCounterData(hQuery, nullptr, 0, &dataSize);
if (ret != ERROR_NOT_ENOUGH_MEMORY) {
FF_DEBUG("PerfQueryCounterData(nullptr) failed: %s", ffDebugWin32Error(ret));
return "PerfQueryCounterData(nullptr) failed";
}
if (dataSize <= sizeof(PERF_DATA_HEADER) + sizeof(PERF_COUNTER_HEADER)) { // PERF_ERROR_RETURN, should not happen
FF_DEBUG("instance doesn't exist");
return "instance doesn't exist";
}
FF_AUTO_FREE PERF_DATA_HEADER* const pDataHeader = malloc(dataSize);
if (PerfQueryCounterData(hQuery, pDataHeader, dataSize, &dataSize) != ERROR_SUCCESS) {
ret = PerfQueryCounterData(hQuery, pDataHeader, dataSize, &dataSize);
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfQueryCounterData(pDataHeader) failed: %s", ffDebugWin32Error(ret));
return "PerfQueryCounterData(pDataHeader) failed";
}
PERF_COUNTER_HEADER* pCounterHeader = (PERF_COUNTER_HEADER*) (pDataHeader + 1);
if (pCounterHeader->dwType != PERF_MULTIPLE_COUNTERS) {
FF_DEBUG("Invalid counter type");
return "Invalid counter type";
}
@@ -190,18 +210,21 @@ static_assert(offsetof(FFSmbiosProcessorInfo, ThreadEnabled) == 0x30,
static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu) {
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
if (!smbiosTable) {
FF_DEBUG("Failed to get SMBIOS data");
return "Failed to get SMBIOS data";
}
const FFSmbiosProcessorInfo* data = (const FFSmbiosProcessorInfo*) (*smbiosTable)[FF_SMBIOS_TYPE_PROCESSOR_INFO];
if (!data) {
FF_DEBUG("Processor information is not found in SMBIOS data");
return "Processor information is not found in SMBIOS data";
}
while (data->ProcessorType != 0x03 /*Central Processor*/ || (data->Status & 0b00000111) != 1 /*Enabled*/) {
data = (const FFSmbiosProcessorInfo*) ffSmbiosNextEntry(&data->Header);
if (data->Header.Type != FF_SMBIOS_TYPE_PROCESSOR_INFO) {
FF_DEBUG("No active CPU is found in SMBIOS data");
return "No active CPU is found in SMBIOS data";
}
}
@@ -209,6 +232,7 @@ static const char* detectMaxSpeedBySmbios(FFCPUResult* cpu) {
uint32_t speed = FF_READ_LE(data->MaxSpeed);
// Sometimes SMBIOS reports invalid value. We assume that max speed is small than 2x of base
if (speed < cpu->frequencyBase || speed > cpu->frequencyBase * 2) {
FF_DEBUG("Possible invalid CPU max speed in SMBIOS data. See #800");
return "Possible invalid CPU max speed in SMBIOS data. See #800";
}
@@ -236,13 +260,16 @@ static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) {
ULONG length = 0;
NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), nullptr, 0, &length);
if (length == 0) {
FF_DEBUG("GetLogicalProcessorInformationEx(RelationAll, nullptr, &length) failed");
return "GetLogicalProcessorInformationEx(RelationAll, nullptr, &length) failed";
}
FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length);
if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) {
NTSTATUS status = NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length);
if (!NT_SUCCESS(status)) {
FF_DEBUG("GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed: %s", ffDebugNtStatus(status));
return "GetLogicalProcessorInformationEx(RelationAll, pProcessorInfo, &length) failed";
}
@@ -283,6 +310,7 @@ static const char* detectNCores(const FFCPUOptions* options, FFCPUResult* cpu) {
static const char* detectByRegistry(FFCPUResult* cpu) {
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
if (!ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", &hKey, nullptr)) {
FF_DEBUG("ffRegOpenKeyForRead() failed for HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
return "ffRegOpenKeyForRead(HKEY_LOCAL_MACHINE, L\"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0\", &hKey, nullptr) failed";
}
@@ -294,6 +322,7 @@ static const char* detectByRegistry(FFCPUResult* cpu) {
nullptr)) {
ffStrbufTrimRightSpace(&cpu->vendor);
} else {
FF_DEBUG("ffRegReadValues() failed for CPU registry key");
return "ffRegReadValues() failed for CPU registry key";
}
+5 -1
View File
@@ -1,4 +1,5 @@
#include "cpucache.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/windows/nt.h"
@@ -7,13 +8,16 @@ const char* ffDetectCPUCache(FFCPUCacheResult* result) {
DWORD length = 0;
NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), nullptr, 0, &length);
if (length == 0) {
FF_DEBUG("GetLogicalProcessorInformationEx(RelationCache, nullptr, &length) failed");
return "GetLogicalProcessorInformationEx(RelationCache, nullptr, &length) failed";
}
FF_AUTO_FREE SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*
pProcessorInfo = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*) malloc(length);
if (!NT_SUCCESS(NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length))) {
NTSTATUS status = NtQuerySystemInformationEx(SystemLogicalProcessorAndGroupInformation, &lpr, sizeof(lpr), pProcessorInfo, length, &length);
if (!NT_SUCCESS(status)) {
FF_DEBUG("GetLogicalProcessorInformationEx(RelationCache, pProcessorInfo, &length) failed: %s", ffDebugNtStatus(status));
return "GetLogicalProcessorInformationEx(RelationCache, pProcessorInfo, &length) failed";
}
+25 -6
View File
@@ -10,12 +10,16 @@
static const char* getInfoByNqsi(FFlist* cpuTimes) {
ULONG size = 0;
if (NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr, 0, &size) != STATUS_INFO_LENGTH_MISMATCH) {
NTSTATUS status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr, 0, &size);
if (status != STATUS_INFO_LENGTH_MISMATCH) {
FF_DEBUG("NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, nullptr) failed";
}
FF_AUTO_FREE SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION* pinfo = (SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION*) malloc(size);
if (!NT_SUCCESS(NtQuerySystemInformation(SystemProcessorPerformanceInformation, pinfo, size, &size))) {
status = NtQuerySystemInformation(SystemProcessorPerformanceInformation, pinfo, size, &size);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtQuerySystemInformation(SystemProcessorPerformanceInformation, size) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessorPerformanceInformation, size) failed";
}
@@ -57,19 +61,24 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
.Name = PERF_WILDCARD_INSTANCE,
};
if (PerfOpenQueryHandle(nullptr, &hQuery) != ERROR_SUCCESS) {
DWORD ret = PerfOpenQueryHandle(nullptr, &hQuery);
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfOpenQueryHandle() failed: %s", ffDebugWin32Error(ret));
PerfCloseQueryHandle(hQuery);
hQuery = INVALID_HANDLE_VALUE;
return "PerfOpenQueryHandle() failed";
}
if (PerfAddCounters(hQuery, &querySpec.Identifier, sizeof(querySpec)) != ERROR_SUCCESS) {
ret = PerfAddCounters(hQuery, &querySpec.Identifier, sizeof(querySpec));
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfAddCounters() failed: %s", ffDebugWin32Error(ret));
PerfCloseQueryHandle(hQuery);
hQuery = INVALID_HANDLE_VALUE;
return "PerfAddCounters() failed";
}
if (querySpec.Identifier.Status != ERROR_SUCCESS) {
FF_DEBUG("PerfAddCounters() reports invalid identifier: %s", ffDebugWin32Error(querySpec.Identifier.Status));
PerfCloseQueryHandle(hQuery);
hQuery = INVALID_HANDLE_VALUE;
return "PerfAddCounters() reports invalid identifier";
@@ -77,35 +86,44 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
}
if (hQuery == INVALID_HANDLE_VALUE) {
FF_DEBUG("Init hQuery failed");
return "Init hQuery failed";
}
DWORD dataSize = 0;
if (PerfQueryCounterData(hQuery, nullptr, 0, &dataSize) != ERROR_NOT_ENOUGH_MEMORY) {
DWORD ret = PerfQueryCounterData(hQuery, nullptr, 0, &dataSize);
if (ret != ERROR_NOT_ENOUGH_MEMORY) {
FF_DEBUG("PerfQueryCounterData(nullptr) failed: %s", ffDebugWin32Error(ret));
return "PerfQueryCounterData(nullptr) failed";
}
if (dataSize <= sizeof(PERF_DATA_HEADER) + sizeof(PERF_COUNTER_HEADER)) {
FF_DEBUG("instance doesn't exist");
return "instance doesn't exist";
}
FF_AUTO_FREE PERF_DATA_HEADER* const pDataHeader = (PERF_DATA_HEADER*) malloc(dataSize);
if (PerfQueryCounterData(hQuery, pDataHeader, dataSize, &dataSize) != ERROR_SUCCESS) {
ret = PerfQueryCounterData(hQuery, pDataHeader, dataSize, &dataSize);
if (ret != ERROR_SUCCESS) {
FF_DEBUG("PerfQueryCounterData(pDataHeader) failed: %s", ffDebugWin32Error(ret));
return "PerfQueryCounterData(pDataHeader) failed";
}
PERF_COUNTER_HEADER* pCounterHeader = (PERF_COUNTER_HEADER*) (pDataHeader + 1);
if (pCounterHeader->dwType != PERF_COUNTERSET) {
FF_DEBUG("Invalid counter type");
return "Invalid counter type";
}
PERF_MULTI_COUNTERS* pMultiCounters = (PERF_MULTI_COUNTERS*) (pCounterHeader + 1);
if (pMultiCounters->dwCounters == 0) {
FF_DEBUG("No CPU counters found");
return "No CPU counters found";
}
PERF_MULTI_INSTANCES* pMultiInstances = (PERF_MULTI_INSTANCES*) ((BYTE*) pMultiCounters + pMultiCounters->dwSize);
if (pMultiInstances->dwInstances == 0) {
FF_DEBUG("No CPU instances found");
return "No CPU instances found";
}
@@ -135,6 +153,7 @@ static const char* getInfoByPerflib(FFlist* cpuTimes) {
if (wcschr(instanceName, L'_') == nullptr /* ignore `_Total` */) {
if (processorUtility == UINT64_MAX) {
FF_DEBUG("Counter \"%% Processor Utility\" are not supported");
return "Counter \"% Processor Utility\" are not supported";
}
+4 -1
View File
@@ -1,4 +1,5 @@
#include "disk.h"
#include "common/debug.h"
#include "common/io.h"
#include "common/time.h"
#include "common/windows/unicode.h"
@@ -12,7 +13,9 @@
const char* ffDetectDisksImpl(FFDiskOptions* options, FFlist* disks) {
PROCESS_DEVICEMAP_INFORMATION_EX info = {};
ULONG size = 0;
if (!NT_SUCCESS(NtQueryInformationProcess(NtCurrentProcess(), ProcessDeviceMap, &info, sizeof(info), &size))) {
NTSTATUS status = NtQueryInformationProcess(NtCurrentProcess(), ProcessDeviceMap, &info, sizeof(info), &size);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtQueryInformationProcess(ProcessDeviceMap) failed: %s", ffDebugNtStatus(status));
return "NtQueryInformationProcess(ProcessDeviceMap) failed";
}
+7 -2
View File
@@ -198,16 +198,21 @@ const char* ffDetectDNS(FFDNSOptions* options, FFlist* results) {
ifIndex = (NET_IFINDEX) ffNetifGetDefaultRouteV6()->ifIndex;
}
if (!ifIndex) {
FF_DEBUG("Failed to detect default route");
return "Failed to detect default route";
}
NET_LUID luid;
if (ConvertInterfaceIndexToLuid(ifIndex, &luid) != NO_ERROR) {
DWORD ret = ConvertInterfaceIndexToLuid(ifIndex, &luid);
if (ret != NO_ERROR) {
FF_DEBUG("ConvertInterfaceIndexToLuid() failed: %s", ffDebugWin32Error(ret));
return "ConvertInterfaceIndexToLuid() failed";
}
GUID guid;
if (ConvertInterfaceLuidToGuid(&luid, &guid) != NO_ERROR) {
ret = ConvertInterfaceLuidToGuid(&luid, &guid);
if (ret != NO_ERROR) {
FF_DEBUG("ConvertInterfaceLuidToGuid() failed: %s", ffDebugWin32Error(ret));
return "ConvertInterfaceLuidToGuid() failed";
}
+3
View File
@@ -1,4 +1,5 @@
#include "font.h"
#include "common/debug.h"
#include "common/windows/unicode.h"
#include "common/windows/registry.h"
@@ -23,6 +24,7 @@ static void generateString(FFFontResult* font) {
const char* ffDetectFontImpl(FFFontResult* result) {
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop\\WindowMetrics", &hKey, nullptr)) {
FF_DEBUG("ffRegOpenKeyForRead(Control Panel\\Desktop\\WindowMetrics) failed");
return "ffRegOpenKeyForRead(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed";
}
@@ -41,6 +43,7 @@ const char* ffDetectFontImpl(FFFontResult* result) {
FF_ARG(fontBuffers[3], L"StatusFont"),
},
nullptr)) {
FF_DEBUG("ffRegReadValues(CaptionFont/MenuFont/MessageFont/StatusFont) failed");
return "ffRegReadValues(HKEY_CURRENT_USER\\Control Panel\\Desktop\\WindowMetrics) failed";
}
+4
View File
@@ -1,4 +1,5 @@
#include "gamepad.h"
#include "common/debug.h"
#include "common/io.h"
#include "common/mallocHelper.h"
#include "common/time.h"
@@ -339,13 +340,16 @@ static FFGamepadBatteryKind detectBatteryKind(uint32_t vendorId, uint32_t produc
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
UINT nDevices = 0;
if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) {
FF_DEBUG("GetRawInputDeviceList(nullptr) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(nullptr) failed";
}
if (nDevices == 0) {
FF_DEBUG("No HID devices found");
return "No HID devices found";
}
FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices);
if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) {
FF_DEBUG("GetRawInputDeviceList(pRawInputDeviceList) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(pRawInputDeviceList) failed";
}
+3
View File
@@ -1,4 +1,5 @@
#include "host.h"
#include "common/debug.h"
#include "common/endian.h"
#include "common/smbios.h"
@@ -32,11 +33,13 @@ static_assert(offsetof(FFSmbiosSystemInfo, Family) == 0x1A,
const char* ffDetectHost(FFHostResult* host) {
const FFSmbiosHeaderTable* smbiosTable = ffGetSmbiosHeaderTable();
if (!smbiosTable) {
FF_DEBUG("System information: failed to get SMBIOS data");
return "Failed to get SMBIOS data";
}
const FFSmbiosSystemInfo* data = (const FFSmbiosSystemInfo*) (*smbiosTable)[FF_SMBIOS_TYPE_SYSTEM_INFO];
if (!data) {
FF_DEBUG("System information: section is not found in SMBIOS data");
return "System information is not found in SMBIOS data";
}
@@ -1,4 +1,5 @@
#include "initsystem.h"
#include "common/debug.h"
#include "common/windows/unicode.h"
#include "common/windows/nt.h"
#include "common/windows/version.h"
@@ -52,6 +53,7 @@ fallback:
ULONG size = sizeof(buffer);
NTSTATUS status = NtQuerySystemInformation(SystemProcessInformation, buffer, size, &size);
if (status != STATUS_INFO_LENGTH_MISMATCH && !NT_SUCCESS(status)) {
FF_DEBUG("NtQuerySystemInformation(SystemProcessInformation) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessInformation) failed";
}
@@ -1,6 +1,7 @@
#define INITGUID
#include "keyboard.h"
#include "common/debug.h"
#include "common/io.h"
#include "common/mallocHelper.h"
#include "common/windows/unicode.h"
@@ -13,14 +14,17 @@
const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) {
UINT nDevices = 0;
if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) {
FF_DEBUG("GetRawInputDeviceList(nullptr) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(nullptr) failed";
}
if (nDevices == 0) {
FF_DEBUG("No HID devices found");
return "No HID devices found";
}
FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices);
if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) {
FF_DEBUG("GetRawInputDeviceList(pRawInputDeviceList) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(pRawInputDeviceList) failed";
}
+2
View File
@@ -1,4 +1,5 @@
#include "detection/locale/locale.h"
#include "common/debug.h"
#include "common/windows/unicode.h"
#include <winnls.h>
@@ -17,6 +18,7 @@ const char* ffDetectLocale(FFstrbuf* result) {
wchar_t name[LOCALE_NAME_MAX_LENGTH];
int size = GetUserDefaultLocaleName(name, LOCALE_NAME_MAX_LENGTH);
if (size <= 1) { // including '\0'
FF_DEBUG("GetUserDefaultLocaleName() failed");
return "GetUserDefaultLocaleName() failed";
}
ffStrbufAppendNWS(result, (uint32_t) size - 1, name);
+2
View File
@@ -1,5 +1,6 @@
extern "C" {
#include "media.h"
#include "common/debug.h"
#include "common/time.h"
#include "common/windows/unicode.h"
#include "common/windows/com.h"
@@ -410,6 +411,7 @@ static const char* getMedia(FFMediaResult* result, bool saveCover) {
#else
static const char* getMedia(FFMediaResult* media, bool saveCover) {
FF_UNUSED(media, saveCover);
FF_DEBUG("Fastfetch is not compiled with WinRT support");
return "Fastfetch is not compiled with WinRT support";
}
#endif // FF_HAVE_WINRT
+5 -1
View File
@@ -1,4 +1,5 @@
#include "memory.h"
#include "common/debug.h"
#include "common/windows/nt.h"
@@ -6,8 +7,11 @@ const char* ffDetectMemory(FFMemoryResult* ram) {
// Note: GlobalMemoryStatusEx() internally uses SystemMemoryUsageInformation in Win 10
SYSTEM_BASIC_PERFORMANCE_INFORMATION sbpi;
if (!NT_SUCCESS(NtQuerySystemInformation(SystemBasicPerformanceInformation, &sbpi, sizeof(sbpi), NULL)))
NTSTATUS status = NtQuerySystemInformation(SystemBasicPerformanceInformation, &sbpi, sizeof(sbpi), NULL);
if (!NT_SUCCESS(status)) {
FF_DEBUG("Failed to query memory information: %s", ffDebugNtStatus(status));
return "Failed to query memory information";
}
uint64_t phyPages =
#if _WIN64
+4
View File
@@ -1,6 +1,7 @@
#define INITGUID
#include "mouse.h"
#include "common/debug.h"
#include "common/io.h"
#include "common/mallocHelper.h"
#include "common/windows/unicode.h"
@@ -13,13 +14,16 @@
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */) {
UINT nDevices = 0;
if (GetRawInputDeviceList(nullptr, &nDevices, sizeof(RAWINPUTDEVICELIST))) {
FF_DEBUG("GetRawInputDeviceList(nullptr) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(nullptr) failed";
}
if (nDevices == 0) {
FF_DEBUG("No HID devices found");
return "No HID devices found";
}
FF_AUTO_FREE RAWINPUTDEVICELIST* pRawInputDeviceList = (RAWINPUTDEVICELIST*) malloc(sizeof(RAWINPUTDEVICELIST) * nDevices);
if ((nDevices = GetRawInputDeviceList(pRawInputDeviceList, &nDevices, sizeof(RAWINPUTDEVICELIST))) == (UINT) -1) {
FF_DEBUG("GetRawInputDeviceList(pRawInputDeviceList) failed: %s", ffDebugWin32Error(GetLastError()));
return "GetRawInputDeviceList(pRawInputDeviceList) failed";
}
+4 -1
View File
@@ -1,5 +1,6 @@
#include "netio.h"
#include "common/debug.h"
#include "common/netif.h"
#include "common/windows/unicode.h"
@@ -54,7 +55,9 @@ const char* ffNetIOGetIoCounters(FFlist* result, FFNetIOOptions* options) {
// address at all, and those cannot be told apart from real adapters by any MIB_IF_ROW2 field.
// GetUnicastIpAddressTable() costs about 72 us, GetIfTable2() about 860 us.
PMIB_UNICASTIPADDRESS_TABLE addressTable = nullptr;
if (!NETIO_SUCCESS(GetUnicastIpAddressTable(AF_UNSPEC, &addressTable))) {
DWORD ret = GetUnicastIpAddressTable(AF_UNSPEC, &addressTable);
if (!NETIO_SUCCESS(ret)) {
FF_DEBUG("GetUnicastIpAddressTable() failed: %s", ffDebugWin32Error(ret));
return "GetUnicastIpAddressTable() failed";
}
+11
View File
@@ -1,4 +1,5 @@
#include "opengl.h"
#include "common/debug.h"
#include "common/library.h"
#include "common/printing.h"
#include "common/windows/nt.h"
@@ -17,11 +18,13 @@ void ffOpenGLHandleResult(FFOpenGLResult* result, typeof(&glGetString) ffglGetSt
static const char* wglHandleContext(WGLData* wglData, FFOpenGLResult* result, HDC hdc, HGLRC context) {
if (wglData->ffwglMakeCurrent(hdc, context) == FALSE) {
FF_DEBUG("wglMakeCurrent() failed: %s", ffDebugWin32Error(GetLastError()));
return "wglMakeCurrent() failed";
}
ffOpenGLHandleResult(result, wglData->ffglGetString);
ffStrbufSetStatic(&result->library, "WGL 1.0");
if (wglData->ffwglMakeCurrent(nullptr, nullptr) == FALSE) {
FF_DEBUG("wglMakeCurrent(nullptr, nullptr) failed: %s", ffDebugWin32Error(GetLastError()));
return "wglMakeCurrent(nullptr, nullptr) failed";
}
return nullptr;
@@ -31,6 +34,7 @@ static const char* wglHandlePixelFormat(WGLData* wglData, FFOpenGLResult* result
HDC hdc = GetDC(hWnd);
if (hdc == nullptr) {
FF_DEBUG("GetDC() failed: %s", ffDebugWin32Error(GetLastError()));
return "GetDC() failed";
}
@@ -45,17 +49,20 @@ static const char* wglHandlePixelFormat(WGLData* wglData, FFOpenGLResult* result
};
int pixelFormat = ChoosePixelFormat(hdc, &pfd);
if (pixelFormat == 0) {
FF_DEBUG("ChoosePixelFormat() failed: %s", ffDebugWin32Error(GetLastError()));
ReleaseDC(hWnd, hdc);
return "ChoosePixelFormat() failed";
}
if (SetPixelFormat(hdc, pixelFormat, &pfd) == FALSE) {
FF_DEBUG("SetPixelFormat() failed: %s", ffDebugWin32Error(GetLastError()));
ReleaseDC(hWnd, hdc);
return "SetPixelFormat() failed";
}
HGLRC context = wglData->ffwglCreateContext(hdc);
if (context == nullptr) {
FF_DEBUG("wglCreateContext() failed: %s", ffDebugWin32Error(GetLastError()));
ReleaseDC(hWnd, hdc);
return "wglCreateContext() failed";
}
@@ -88,11 +95,13 @@ static const char* wglDetectOpenGL(FFOpenGLResult* result) {
.style = CS_OWNDC,
};
if (!RegisterClassW(&wc)) {
FF_DEBUG("RegisterClassW() failed: %s", ffDebugWin32Error(GetLastError()));
return "RegisterClassW() failed";
}
HWND hWnd = CreateWindowW(wc.lpszClassName, L"ogl_version_check", 0, 0, 0, FF_OPENGL_BUFFER_WIDTH, FF_OPENGL_BUFFER_HEIGHT, nullptr, nullptr, hInstance, nullptr);
if (!hWnd) {
FF_DEBUG("CreateWindowW() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateWindowW() failed";
}
@@ -112,9 +121,11 @@ const char* ffDetectOpenGL(FFOpenGLOptions* options, FFOpenGLResult* result) {
const char* ffOpenGLDetectByEGL(FFOpenGLResult * result);
return ffOpenGLDetectByEGL(result);
#else
FF_DEBUG("fastfetch was compiled without egl support");
return "fastfetch was compiled without egl support";
#endif
} else {
FF_DEBUG("Unsupported OpenGL library");
return "Unsupported OpenGL library";
}
}
@@ -12,6 +12,7 @@
static const char* detectPhysicalDisk(const char* physicalType, const wchar_t* szDevice, FFlist* result, FFPhysicalDiskOptions* options) {
FF_AUTO_CLOSE_FD HANDLE hDevice = CreateFileW(szDevice, FILE_READ_ATTRIBUTES, FILE_SHARE_READ, nullptr, OPEN_EXISTING, 0, nullptr);
if (hDevice == INVALID_HANDLE_VALUE) {
FF_DEBUG("CreateFileW() failed: %s", ffDebugWin32Error(GetLastError()));
return "CreateFileW() failed";
}
@@ -1,4 +1,5 @@
#include "processes.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/windows/nt.h"
@@ -34,6 +35,7 @@ const char* ffDetectProcesses(const FFProcessesOptions* options, FFProcessesResu
} else if (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4) {
size += sizeof(SYSTEM_PROCESS_INFORMATION) * 5;
} else {
FF_DEBUG("NtQuerySystemInformation(SystemProcessInformation) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessInformation) failed";
}
}
+25 -8
View File
@@ -1,5 +1,6 @@
extern "C" {
#include "sound.h"
#include "common/debug.h"
#include "common/windows/com.h"
}
#include "common/windows/unicode.hpp"
@@ -21,17 +22,23 @@ static void ffCoTaskMemFreeWrapper(void* pptr) {
static const char* detectSoundDevice(FFlist* devices /* List of FFSoundDevice */, IMMDevice* immDevice, LPWSTR mainDeviceId) {
FF_COTASK_AUTO_FREE LPWSTR immDeviceId = nullptr;
if (FAILED(immDevice->GetId(&immDeviceId))) {
HRESULT hr = immDevice->GetId(&immDeviceId);
if (FAILED(hr)) {
FF_DEBUG("immDevice->GetId() failed: %s", ffDebugHResult(hr));
return "immDevice->GetId() failed";
}
FF_AUTO_RELEASE_COM_OBJECT IPropertyStore* immPropStore = nullptr;
if (FAILED(immDevice->OpenPropertyStore(STGM_READ, &immPropStore))) {
hr = immDevice->OpenPropertyStore(STGM_READ, &immPropStore);
if (FAILED(hr)) {
FF_DEBUG("immDevice->OpenPropertyStore() failed: %s", ffDebugHResult(hr));
return "immDevice->OpenPropertyStore() failed";
}
DWORD immState;
if (FAILED(immDevice->GetState(&immState))) {
hr = immDevice->GetState(&immState);
if (FAILED(hr)) {
FF_DEBUG("immDevice->GetState() failed: %s", ffDebugHResult(hr));
return "immDevice->GetState() failed";
}
@@ -76,7 +83,9 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
FF_AUTO_RELEASE_COM_OBJECT IMMDeviceEnumerator* pEnum = nullptr;
if (FAILED(CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pEnum)))) {
HRESULT hr = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, CLSCTX_ALL, IID_PPV_ARGS(&pEnum));
if (FAILED(hr)) {
FF_DEBUG("CoCreateInstance(CLSID_MMDeviceEnumerator) failed: %s", ffDebugHResult(hr));
return "CoCreateInstance(CLSID_MMDeviceEnumerator) failed";
}
@@ -85,7 +94,9 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
{
FF_AUTO_RELEASE_COM_OBJECT IMMDevice* pDefaultDevice = nullptr;
if (FAILED(pEnum->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDefaultDevice))) {
HRESULT hrDefault = pEnum->GetDefaultAudioEndpoint(eRender, eMultimedia, &pDefaultDevice);
if (FAILED(hrDefault)) {
FF_DEBUG("GetDefaultAudioEndpoint() failed: %s", ffDebugHResult(hrDefault));
return "GetDefaultAudioEndpoint() failed";
}
@@ -93,19 +104,25 @@ const char* ffDetectSound(FFSoundOptions* options, FFlist* devices /* List of FF
return detectSoundDevice(devices, pDefaultDevice, nullptr);
}
if (FAILED(pDefaultDevice->GetId(&mainDeviceId))) {
hrDefault = pDefaultDevice->GetId(&mainDeviceId);
if (FAILED(hrDefault)) {
FF_DEBUG("pDefaultDevice->GetId() failed: %s", ffDebugHResult(hrDefault));
return "pDefaultDevice->GetId() failed";
}
}
FF_AUTO_RELEASE_COM_OBJECT IMMDeviceCollection* pDevices = nullptr;
if (FAILED(pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | (options->soundType & FF_SOUND_TYPE_ACTIVE ? 0 : DEVICE_STATE_DISABLED), &pDevices))) {
hr = pEnum->EnumAudioEndpoints(eRender, DEVICE_STATE_ACTIVE | (options->soundType & FF_SOUND_TYPE_ACTIVE ? 0 : DEVICE_STATE_DISABLED), &pDevices);
if (FAILED(hr)) {
FF_DEBUG("EnumAudioEndpoints() failed: %s", ffDebugHResult(hr));
return "EnumAudioEndpoints() failed";
}
uint32_t deviceCount;
if (FAILED(pDevices->GetCount(&deviceCount))) {
hr = pDevices->GetCount(&deviceCount);
if (FAILED(hr)) {
FF_DEBUG("pDevices->GetCount() failed: %s", ffDebugHResult(hr));
return "pDevices->GetCount() failed";
}
+4 -1
View File
@@ -1,4 +1,5 @@
#include "swap.h"
#include "common/debug.h"
#include "common/windows/unicode.h"
#include <winternl.h>
@@ -10,7 +11,9 @@ const char* ffDetectSwap(FFlist* result) {
alignas(SYSTEM_PAGEFILE_INFORMATION) uint8_t buffer[4096];
ULONG size = sizeof(buffer);
SYSTEM_PAGEFILE_INFORMATION* pstart = (SYSTEM_PAGEFILE_INFORMATION*) buffer;
if (!NT_SUCCESS(NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size))) {
NTSTATUS status = NtQuerySystemInformation(SystemPagefileInformation, pstart, size, &size);
if (!NT_SUCCESS(status)) {
FF_DEBUG("NtQuerySystemInformation(SystemPagefileInformation, size) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemPagefileInformation, size) failed";
}
@@ -1,3 +1,4 @@
#include "common/debug.h"
#include "common/library.h"
#include "common/io.h"
#include "common/path.h"
@@ -116,6 +117,7 @@ static inline void wrapYyjsonFree(yyjson_doc** doc) {
static const char* detectFromWTSettings(FFstrbuf* content, const FFstrbuf* wtProfileId, FFTerminalFontWT* result) {
[[gnu::cleanup(wrapYyjsonFree)]] yyjson_doc* doc = yyjson_read_opts(content->chars, content->length, YYJSON_READ_ALLOW_COMMENTS | YYJSON_READ_ALLOW_TRAILING_COMMAS, nullptr, nullptr);
if (!doc) {
FF_DEBUG("Failed to parse WT JSON config file");
return "Failed to parse WT JSON config file";
}
@@ -124,6 +126,7 @@ static const char* detectFromWTSettings(FFstrbuf* content, const FFstrbuf* wtPro
yyjson_val* profiles = yyjson_obj_get(root, "profiles");
if (!profiles) {
FF_DEBUG("yyjson_obj_get(root, \"profiles\") failed");
return "yyjson_obj_get(root, \"profiles\") failed";
}
+2
View File
@@ -1,5 +1,6 @@
#include "top.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/windows/unicode.h"
@@ -24,6 +25,7 @@ const char* ffTopGetProcessSnapshot(FFlist* snapshots, FFTopTypes) {
} else if (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4) {
size += sizeof(SYSTEM_PROCESS_INFORMATION) * 5;
} else {
FF_DEBUG("NtQuerySystemInformation(SystemProcessInformation) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessInformation) failed";
}
}
+2
View File
@@ -1,4 +1,5 @@
#include "users.h"
#include "common/debug.h"
#include "common/windows/unicode.h"
#include "common/time.h"
@@ -12,6 +13,7 @@ const char* ffDetectUsers(FFUsersOptions* options, FFlist* users) {
DWORD level = 1;
if (!WTSEnumerateSessionsExW(WTS_CURRENT_SERVER_HANDLE, &level, 0, &sessionInfo, &sessionCount)) {
FF_DEBUG("WTSEnumerateSessionsExW() failed: %s", ffDebugWin32Error(GetLastError()));
return "WTSEnumerateSessionsW(WTS_CURRENT_SERVER_HANDLE) failed";
}
@@ -1,13 +1,16 @@
#include "wallpaper.h"
#include "common/debug.h"
#include "common/windows/registry.h"
const char* ffDetectWallpaper(FFstrbuf* result) {
FF_AUTO_CLOSE_FD HANDLE hKey = nullptr;
if (!ffRegOpenKeyForRead(HKEY_CURRENT_USER, L"Control Panel\\Desktop", &hKey, nullptr)) {
FF_DEBUG("ffRegOpenKeyForRead(Control Panel\\Desktop) failed");
return "ffRegOpenKeyForRead(Control Panel\\Desktop) failed";
}
if (!ffRegReadStrbuf(hKey, L"WallPaper", result, nullptr)) {
FF_DEBUG("ffRegReadStrbuf(WallPaper) failed");
return "ffRegReadStrbuf(WallPaper) failed";
}
+4
View File
@@ -1,4 +1,5 @@
#include "wm.h"
#include "common/debug.h"
#include "common/mallocHelper.h"
#include "common/io.h"
#include "common/library.h"
@@ -208,6 +209,7 @@ fallback:
} else if (status == STATUS_INFO_LENGTH_MISMATCH && attempts < 4) {
size += sizeof(SYSTEM_PROCESS_INFORMATION) * 5;
} else {
FF_DEBUG("NtQuerySystemInformation(SystemProcessInformation) failed: %s", ffDebugNtStatus(status));
return "NtQuerySystemInformation(SystemProcessInformation) failed";
}
}
@@ -228,6 +230,7 @@ fallback:
const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_unused]] FFWMOptions* options) {
if (!wmName) {
FF_DEBUG("No WM detected");
return "No WM detected";
}
@@ -238,5 +241,6 @@ const char* ffDetectWMVersion(const FFstrbuf* wmName, FFstrbuf* result, [[maybe_
return nullptr;
}
FF_DEBUG("Not supported on this platform");
return "Not supported on this platform";
}