Files
fastfetch/src/common/impl/kmod_windows.c
T

29 lines
840 B
C
Raw Normal View History

2026-03-01 14:01:18 +08:00
#include "common/kmod.h"
#include "common/windows/nt.h"
#include "common/mallocHelper.h"
#include "common/stringUtils.h"
2026-03-29 09:28:49 +08:00
bool ffKmodLoaded(const char* modName) {
2026-03-01 14:01:18 +08:00
ULONG bufferSize = 0;
NtQuerySystemInformation(SystemModuleInformation, NULL, 0, &bufferSize);
2026-03-29 09:28:49 +08:00
if (bufferSize == 0) {
2026-03-01 14:01:18 +08:00
return true; // ignore errors
2026-03-29 09:28:49 +08:00
}
2026-03-01 14:01:18 +08:00
FF_AUTO_FREE RTL_PROCESS_MODULES* buffer = malloc(bufferSize);
2026-03-29 09:28:49 +08:00
if (!NT_SUCCESS(NtQuerySystemInformation(SystemModuleInformation, buffer, bufferSize, &bufferSize))) {
2026-03-01 14:01:18 +08:00
return true; // ignore errors
2026-03-29 09:28:49 +08:00
}
2026-03-01 14:01:18 +08:00
2026-03-29 09:28:49 +08:00
for (ULONG i = 0; i < buffer->NumberOfModules; i++) {
2026-03-01 14:01:18 +08:00
const char* name = (const char*) buffer->Modules[i].FullPathName + buffer->Modules[i].OffsetToFileName;
2026-03-29 09:28:49 +08:00
if (ffStrEqualsIgnCase(name, modName)) {
2026-03-01 14:01:18 +08:00
return true;
2026-03-29 09:28:49 +08:00
}
2026-03-01 14:01:18 +08:00
}
return false;
}