mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +02:00
8316421: libjava should load shell32.dll eagerly
Reviewed-by: erikj, jwaters, jvernee
This commit is contained in:
parent
378bcd5985
commit
8cbe42b94a
2 changed files with 6 additions and 37 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue