Skip to content

Commit 47b9d0a

Browse files
committed
Library (Windows): load dlls at current exe path
1 parent 17d6153 commit 47b9d0a

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Features:
99
* Fastfetch now supports all major BSD variants
1010
* Support DiskIO, NetIO, GPU and Users module on OpenBSD
1111
* Report SD8E SOC name (CPU, Android)
12+
* On Windows, try loading dlls from current exe path (Windows)
13+
* Fix Media module when installed with winget
1214

1315
Bugfixes:
1416
* Fix the VIM version detection on Ubuntu (Editor, Linux)

src/common/library.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,17 @@ static void* libraryLoad(const char* path, int maxVersion)
2929
// libX.dll.1 never exists on Windows, while libX-1.dll may exist
3030
FF_UNUSED(maxVersion)
3131

32+
if(result != NULL)
33+
return result;
34+
35+
uint32_t pathLen = ffStrbufLastIndexC(&instance.state.platform.exePath, '/');
36+
if (pathLen == instance.state.platform.exePath.length)
37+
return result;
38+
39+
char absPath[MAX_PATH + 1];
40+
strcpy(mempcpy(absPath, instance.state.platform.exePath.chars, pathLen + 1), path);
41+
return dlopen(absPath, FF_DLOPEN_FLAGS);
42+
3243
#else
3344

3445
if(result != NULL || maxVersion < 0)

src/util/FFstrbuf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ static inline FF_C_NODISCARD uint32_t ffStrbufFirstIndexS(const FFstrbuf* strbuf
379379
static inline FF_C_NODISCARD uint32_t ffStrbufLastIndexC(const FFstrbuf* strbuf, char c)
380380
{
381381
if(strbuf->length == 0)
382-
return strbuf->length;
382+
return 0;
383383

384384
return ffStrbufPreviousIndexC(strbuf, strbuf->length - 1, c);
385385
}

0 commit comments

Comments
 (0)