aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/win32
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-10-16 18:15:47 +0200
committerSverker Eriksson <[email protected]>2013-10-16 18:16:26 +0200
commit717cf073d2c4ccbb508a272486ec83369ed1f043 (patch)
tree86d6321d6ab6e906297b602e151630277b78997c /erts/emulator/sys/win32
parentb95da0ad6236be268d63fd960934c787971e1fd0 (diff)
parentb6b0b73ecec7facefb3b9c5a7ef663599cfee4aa (diff)
downloadotp-717cf073d2c4ccbb508a272486ec83369ed1f043.tar.gz
otp-717cf073d2c4ccbb508a272486ec83369ed1f043.tar.bz2
otp-717cf073d2c4ccbb508a272486ec83369ed1f043.zip
Merge branch 'sverk/load-nif-unicode'
OTP-11408 * sverk/load-nif-unicode: erts: Fix bug in atom to filename conversions Fix open_ddll for win erts, crypto: Support NIF library with unicode filename on windows erts: Factor out erts_convert_filename_to_wchar() erts: Fix compiler warning erts: Fix loading of NIF library with unicode in path erts: Remove unused constant DRIVER_TAB_SIZE
Diffstat (limited to 'erts/emulator/sys/win32')
-rw-r--r--erts/emulator/sys/win32/erl_win32_sys_ddll.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/erts/emulator/sys/win32/erl_win32_sys_ddll.c b/erts/emulator/sys/win32/erl_win32_sys_ddll.c
index 4c8d83ab16..2d3f073cc2 100644
--- a/erts/emulator/sys/win32/erl_win32_sys_ddll.c
+++ b/erts/emulator/sys/win32/erl_win32_sys_ddll.c
@@ -38,7 +38,7 @@
#include "erl_nif.h"
#define EXT_LEN 4
-#define FILE_EXT ".dll"
+#define FILE_EXT_WCHAR L".dll"
static DWORD tls_index = 0;
static TWinDynDriverCallbacks wddc;
@@ -57,11 +57,15 @@ void erl_sys_ddll_init(void) {
/*
* Open a shared object
+ * Expecting 'full_name' as an UTF-8 string.
*/
int erts_sys_ddll_open2(const char *full_name, void **handle, ErtsSysDdllError* err)
{
+ HINSTANCE hinstance;
int len;
- char dlname[MAXPATHLEN + 1];
+ wchar_t* wcp;
+ Sint used;
+ int code;
if ((len = sys_strlen(full_name)) >= MAXPATHLEN - EXT_LEN) {
if (err != NULL) {
@@ -69,10 +73,26 @@ int erts_sys_ddll_open2(const char *full_name, void **handle, ErtsSysDdllError*
}
return ERL_DE_LOAD_ERROR_NAME_TO_LONG;
}
- sys_strcpy(dlname, full_name);
- sys_strcpy(dlname+len, FILE_EXT);
- return erts_sys_ddll_open_noext(dlname, handle, err);
+
+ wcp = (wchar_t*)erts_convert_filename_to_wchar((byte*)full_name, len,
+ NULL, 0,
+ ERTS_ALC_T_TMP, &used, EXT_LEN);
+ wcscpy(&wcp[used/2 - 1], FILE_EXT_WCHAR);
+
+ if ((hinstance = LoadLibraryW(wcp)) == NULL) {
+ code = ERL_DE_DYNAMIC_ERROR_OFFSET - GetLastError();
+ if (err != NULL) {
+ err->str = erts_sys_ddll_error(code);
+ }
+ }
+ else {
+ code = ERL_DE_NO_ERROR;
+ *handle = (void *) hinstance;
+ }
+ erts_free(ERTS_ALC_T_TMP, wcp);
+ return code;
}
+
int erts_sys_ddll_open_noext(char *dlname, void **handle, ErtsSysDdllError* err)
{
HINSTANCE hinstance;