Library (Windows): load dlls at current exe path

This commit is contained in:
李通洲
2024-11-04 09:56:44 +08:00
committed by 李通洲
parent 17d6153353
commit 47b9d0a3a4
3 changed files with 14 additions and 1 deletions
+2
View File
@@ -9,6 +9,8 @@ Features:
* Fastfetch now supports all major BSD variants
* Support DiskIO, NetIO, GPU and Users module on OpenBSD
* Report SD8E SOC name (CPU, Android)
* On Windows, try loading dlls from current exe path (Windows)
* Fix Media module when installed with winget
Bugfixes:
* Fix the VIM version detection on Ubuntu (Editor, Linux)
+11
View File
@@ -29,6 +29,17 @@ static void* libraryLoad(const char* path, int maxVersion)
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
FF_UNUSED(maxVersion)
if(result != NULL)
return result;
uint32_t pathLen = ffStrbufLastIndexC(&instance.state.platform.exePath, '/');
if (pathLen == instance.state.platform.exePath.length)
return result;
char absPath[MAX_PATH + 1];
strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path);
return dlopen(absPath, FF_DLOPEN_FLAGS);
#else
if(result != NULL || maxVersion < 0)
+1 -1
View File
@@ -379,7 +379,7 @@ static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf
static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c)
{
if(strbuf->length == 0)
return strbuf->length;
return 0;
return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c);
}