8316421: libjava should load shell32.dll eagerly
Reviewed-by: erikj, jwaters, jvernee
This commit is contained in:
parent
378bcd5985
commit
8cbe42b94a
@ -64,7 +64,6 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
|
||||
LDFLAGS := $(LDFLAGS_JDKLIB) \
|
||||
$(call SET_SHARED_LIBRARY_ORIGIN), \
|
||||
LDFLAGS_macosx := -L$(SUPPORT_OUTPUTDIR)/native/$(MODULE)/, \
|
||||
LDFLAGS_windows := -delayload:shell32.dll, \
|
||||
LIBS_unix := -ljvm, \
|
||||
LIBS_linux := $(LIBDL), \
|
||||
LIBS_aix := $(LIBDL) $(LIBM),\
|
||||
@ -72,7 +71,7 @@ $(eval $(call SetupJdkLibrary, BUILD_LIBJAVA, \
|
||||
-framework Foundation \
|
||||
-framework SystemConfiguration, \
|
||||
LIBS_windows := jvm.lib \
|
||||
shell32.lib delayimp.lib \
|
||||
shell32.lib ole32.lib \
|
||||
advapi32.lib version.lib, \
|
||||
))
|
||||
|
||||
|
@ -40,10 +40,6 @@
|
||||
#include "locale_str.h"
|
||||
#include "java_props.h"
|
||||
|
||||
#ifndef VER_PLATFORM_WIN32_WINDOWS
|
||||
#define VER_PLATFORM_WIN32_WINDOWS 1
|
||||
#endif
|
||||
|
||||
#ifndef PROCESSOR_ARCHITECTURE_AMD64
|
||||
#define PROCESSOR_ARCHITECTURE_AMD64 9
|
||||
#endif
|
||||
@ -213,39 +209,13 @@ getHomeFromShell32()
|
||||
*/
|
||||
static WCHAR *u_path = NULL;
|
||||
if (u_path == NULL) {
|
||||
HRESULT hr;
|
||||
|
||||
/*
|
||||
* SHELL32 DLL is delay load DLL and we can use the trick with
|
||||
* __try/__except block.
|
||||
*/
|
||||
__try {
|
||||
/*
|
||||
* For Windows Vista and later (or patched MS OS) we need to use
|
||||
* [SHGetKnownFolderPath] call to avoid MAX_PATH length limitation.
|
||||
* Shell32.dll (version 6.0.6000 or later)
|
||||
*/
|
||||
hr = SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY, NULL, &u_path);
|
||||
} __except(EXCEPTION_EXECUTE_HANDLER) {
|
||||
/* Exception: no [SHGetKnownFolderPath] entry */
|
||||
hr = E_FAIL;
|
||||
}
|
||||
WCHAR *tmpPath = NULL;
|
||||
HRESULT hr = SHGetKnownFolderPath(&FOLDERID_Profile, KF_FLAG_DONT_VERIFY, NULL, &tmpPath);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
WCHAR path[MAX_PATH+1];
|
||||
|
||||
/* fallback solution for WinXP and Windows 2000 */
|
||||
hr = SHGetFolderPathW(NULL, CSIDL_FLAG_DONT_VERIFY | CSIDL_PROFILE, NULL, SHGFP_TYPE_CURRENT, path);
|
||||
if (FAILED(hr)) {
|
||||
/* we can't find the shell folder. */
|
||||
u_path = NULL;
|
||||
} else {
|
||||
/* Just to be sure about the path length until Windows Vista approach.
|
||||
* [S_FALSE] could not be returned due to [CSIDL_FLAG_DONT_VERIFY] flag and UNICODE version.
|
||||
*/
|
||||
path[MAX_PATH] = 0;
|
||||
u_path = _wcsdup(path);
|
||||
}
|
||||
CoTaskMemFree(tmpPath);
|
||||
} else {
|
||||
u_path = tmpPath;
|
||||
}
|
||||
}
|
||||
return u_path;
|
||||
|
Loading…
Reference in New Issue
Block a user