Skip to content

Commit

Permalink
win, dl: proper error messages on some systems
Browse files Browse the repository at this point in the history
On some localized Windows 10 machines FormatMessage can fail with
ERROR_RESOURCE_TYPE_NOT_FOUND when trying to generate dlopen error
message. This adds support for this corner case.

PR-URL: libuv#2052
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
bzoz committed Nov 1, 2018
1 parent 8a647d4 commit ebb818b
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/win/dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ static int uv__dlerror(uv_lib_t* lib, const char* filename, DWORD errorno) {
MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
(LPSTR) &lib->errmsg, 0, NULL);

if (!res && GetLastError() == ERROR_MUI_FILE_NOT_FOUND) {
if (!res && (GetLastError() == ERROR_MUI_FILE_NOT_FOUND ||
GetLastError() == ERROR_RESOURCE_TYPE_NOT_FOUND)) {
res = FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errorno,
Expand Down

0 comments on commit ebb818b

Please sign in to comment.