Maybe we should follow this approach (i.e. prefer GetModuleHandleEx to
GetModuleHandle) in other places as well.
I found there suspect cases:
./jdk/src/windows/native/java/lang/java_props_md.c:
GetModuleHandle(TEXT("kernel32.dll")),
./jdk/test/java/util/Locale/data/deflocale.c: HMODULE hmod =
GetModuleHandle(L"kernel32");
./hotspot/src/os/windows/vm/perfMemory_windows.cpp:
GetProcAddress(GetModuleHandle(TEXT("advapi32.dll")),
./hotspot/src/os/windows/vm/os_windows.cpp: hmod =
GetModuleHandle("NTDLL.DLL");
./hotspot/src/os/windows/vm/os_windows.cpp: HMODULE hKernel32 =
GetModuleHandle(TEXT("kernel32.dll"));
./hotspot/src/os/windows/vm/os_windows.cpp: HINSTANCE kernel32 =
LoadLibrary("Kernel32.DLL") ;
./hotspot/src/os/windows/vm/os_windows.cpp: HINSTANCE psapi = LoadLibrary(
"PSAPI.DLL" ) ;
Regards,
Dmytro
Date: Tue, 29 Mar 2011 16:49:50 +0100
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: 7030249: Eliminate use of LoadLibrary and other clean-ups
Message body
Dmytro Sheyko wrote:
:
Why we obtain HMODULE for kernel32 this way:
// get handle to kernel32
if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT),
(LPCWSTR)&CreateFileW, &h) != 0)
{
...
instead of
handle = GetModuleHandle("kernel32");
GetModuleHandleExW allows you to provide the address of a function in
the library that you need the handle for and so you avoid issues when
multiple libraries with the same name are loaded.
:
Also according to MSDN GetModuleHandleEx requires at minimum "Windows
XP" or "Windows Server 2003". It means that we do not support "Windows
2000", right?
I don't think it's been possible to install or run jdk7 on Windows 2000
for some time.
-Alan