diff options
author | Ron Yorston <rmy@pobox.com> | 2021-03-01 09:07:58 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2021-03-01 09:07:58 +0000 |
commit | aa1512610a7d5081f0b721e7dc24a95527c07a95 (patch) | |
tree | 6b3217fbc78f9531a96391cb082204b5d7349e91 | |
parent | 38eafd3ff110e2802fe85167013be9b0e49665f9 (diff) | |
download | busybox-w32-aa1512610a7d5081f0b721e7dc24a95527c07a95.tar.gz busybox-w32-aa1512610a7d5081f0b721e7dc24a95527c07a95.tar.bz2 busybox-w32-aa1512610a7d5081f0b721e7dc24a95527c07a95.zip |
win32: workaround for lazy loading issue on Windows 7
Investigating why free(1) wasn't working on Windows 7 I found it's
possible for LoadLibraryEx to fail with exactly the flags we're
using. Work around this.
This probably also explains GitHub issue #204.
-rw-r--r-- | win32/mingw.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/win32/mingw.c b/win32/mingw.c index b01198bd2..6e1dc6a9a 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1878,6 +1878,20 @@ void *get_proc_addr(const char *dll, const char *function, | |||
1878 | /* only do this once */ | 1878 | /* only do this once */ |
1879 | if (!proc->initialized) { | 1879 | if (!proc->initialized) { |
1880 | HANDLE hnd = LoadLibraryExA(dll, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); | 1880 | HANDLE hnd = LoadLibraryExA(dll, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); |
1881 | |||
1882 | /* The documentation for LoadLibraryEx says the above may fail | ||
1883 | * on Windows 7. If it does, retry using LoadLibrary with an | ||
1884 | * explicit, backslash-separated path. */ | ||
1885 | if (!hnd) { | ||
1886 | char dir[PATH_MAX], *path; | ||
1887 | |||
1888 | GetSystemDirectory(dir, PATH_MAX); | ||
1889 | path = concat_path_file(dir, dll); | ||
1890 | slash_to_bs(path); | ||
1891 | hnd = LoadLibrary(path); | ||
1892 | free(path); | ||
1893 | } | ||
1894 | |||
1881 | if (hnd) | 1895 | if (hnd) |
1882 | proc->pfunction = GetProcAddress(hnd, function); | 1896 | proc->pfunction = GetProcAddress(hnd, function); |
1883 | proc->initialized = 1; | 1897 | proc->initialized = 1; |