This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-daemon.git
commit 39edeec2590966d9ace3ec9788eb555c32f4347f Author: Mark Thomas <[email protected]> AuthorDate: Wed May 22 22:26:56 2019 +0100 Fix DAEMON-396 problem 1 Based on fix for DAEMON-401. --- src/changes/changes.xml | 5 +++++ src/native/windows/apps/prunsrv/prunsrv.c | 2 -- src/native/windows/include/apxwin.h | 2 ++ src/native/windows/src/utils.c | 12 ++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 24bed12..456926a 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -79,6 +79,11 @@ Procrun. Ensure that JAVA_HOME/bin is on the path when running in jvm mode so that additional DLLs, such as awt.dll, can be found if required. </action> + <action issue="DAEMON-396" type="fix" dev="markt"> + Procrun. Ensure that the java.library.path environment variable is + correctly configured when running on a JRE that depends on the Universal + CRT. + </action> <action type="add" dev="markt"> Procrun. Log the error code returned if JVM creation fails to aid debugging. diff --git a/src/native/windows/apps/prunsrv/prunsrv.c b/src/native/windows/apps/prunsrv/prunsrv.c index b125850..dab90e5 100644 --- a/src/native/windows/apps/prunsrv/prunsrv.c +++ b/src/native/windows/apps/prunsrv/prunsrv.c @@ -58,8 +58,6 @@ typedef struct APX_STDWRAP { FILE *fpStdErrFile; } APX_STDWRAP; -typedef int (__stdcall *WPUTENV) (const wchar_t *env); - /* Use static variables instead of #defines */ static LPCWSTR PRSRV_AUTO = L"auto"; static LPCWSTR PRSRV_JAVA = L"java"; diff --git a/src/native/windows/include/apxwin.h b/src/native/windows/include/apxwin.h index ca7552a..f291aa4 100644 --- a/src/native/windows/include/apxwin.h +++ b/src/native/windows/include/apxwin.h @@ -120,6 +120,8 @@ LPSTR MzWideToANSI(LPCWSTR ws); typedef struct APXMULTISZ APXMULTISZ; typedef APXMULTISZ* LPAPXMULTISZ; +typedef int (__stdcall *WPUTENV) (const wchar_t *env); + DWORD apxMultiSzToArrayW(APXHANDLE hPool, LPCWSTR lpString, LPWSTR **lppArray); LPWSTR apxMultiSzCombine(APXHANDLE hPool, LPCWSTR lpStrA, LPCWSTR lpStrB, diff --git a/src/native/windows/src/utils.c b/src/native/windows/src/utils.c index 2e0d2bf..1e1f3cd 100644 --- a/src/native/windows/src/utils.c +++ b/src/native/windows/src/utils.c @@ -60,6 +60,8 @@ BOOL apxAddToPathW(APXHANDLE hPool, LPCWSTR szAdd) LPWSTR wsAdd; DWORD rc; DWORD al; + HMODULE hmodUcrt; + WPUTENV wputenv_ucrt; rc = GetEnvironmentVariableW(L"PATH", NULL, 0); if (rc == 0 && GetLastError() == ERROR_ENVVAR_NOT_FOUND) @@ -75,8 +77,18 @@ BOOL apxAddToPathW(APXHANDLE hPool, LPCWSTR szAdd) apxFree(wsAdd); return FALSE; } + + hmodUcrt = LoadLibraryExA("ucrtbase.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (hmodUcrt != NULL) { + wputenv_ucrt = (WPUTENV) GetProcAddress(hmodUcrt, "_wputenv"); + } + SetEnvironmentVariableW(L"PATH", wsAdd + 5); _wputenv(wsAdd); + if (wputenv_ucrt != NULL) { + wputenv_ucrt(wsAdd); + } + apxFree(wsAdd); return TRUE; }
