# HG changeset patch # User Tassilo Philipp # Date 1578659457 -3600 # Node ID 655cafde08591ce338444bd18b141a40b789c1c2 # Parent fb70995ac92373f6273246c9557579ac0fd8c329 - dynload/windows: dlLoadLibrary behaviour now more in line with other platforms by not trying to load provided path with .dll suffix - cosmetics, cr update diff -r fb70995ac923 -r 655cafde0859 dynload/dynload_windows.c --- a/dynload/dynload_windows.c Wed Jan 08 18:20:49 2020 +0100 +++ b/dynload/dynload_windows.c Fri Jan 10 13:30:57 2020 +0100 @@ -6,7 +6,7 @@ Description: License: - Copyright (c) 2007-2018 Daniel Adler , + Copyright (c) 2007-2020 Daniel Adler , Tassilo Philipp Permission to use, copy, modify, and distribute this software for any @@ -45,7 +45,7 @@ if(libPath == NULL) return (DLLib*)GetModuleHandle(NULL); else { - /* convert from UTF-8 to wide chars, so count required size... */ + /* convert from UTF-8 to wide chars, so count required size */ DLLib* pLib; wchar_t* ws; int r = MultiByteToWideChar(CP_UTF8, 0, libPath, -1, NULL, 0); @@ -53,14 +53,21 @@ return NULL; } - /* ... reserve temp space, ... */ - ws = (wchar_t*)dlAllocMem(r * sizeof(wchar_t)); + /* Reserve temp space with room for extra '.' suffix (see below) */ + ws = (wchar_t*)dlAllocMem((r+1) * sizeof(wchar_t)); if(!ws) return NULL; - /* ... convert (and use r as success flag), ... */ - r = (MultiByteToWideChar(CP_UTF8, 0, libPath, -1, ws, r) == r); - pLib = (DLLib*)(r ? LoadLibraryW(ws) : NULL); + /* Convert path and add a '.' suffix, needed to tell windows not to add + .dll to any path that doesn't have it (see MS doc for LoadLibraryW). + This is to get same behaviour as on other platforms which don't do any + magic like this. Library search path behaviour stays unaffected, though */ + pLib = NULL; + if(MultiByteToWideChar(CP_UTF8, 0, libPath, -1, ws, r) == r) { + ws[r-1] = '.'; + ws[r] = 0; + pLib = (DLLib*)LoadLibraryW(ws); + } /* ... free temp space and return handle */ dlFreeMem(ws); diff -r fb70995ac923 -r 655cafde0859 test/dynload_plain/Nmakefile --- a/test/dynload_plain/Nmakefile Wed Jan 08 18:20:49 2020 +0100 +++ b/test/dynload_plain/Nmakefile Fri Jan 10 13:30:57 2020 +0100 @@ -1,6 +1,6 @@ #////////////////////////////////////////////////////////////////////////////// # -# Copyright (c) 2017 Tassilo Philipp +# Copyright (c) 2017-2020 Tassilo Philipp # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above