}
}
-typedef BOOL (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
-
-#ifndef _WIN64
-static int is_wow64(void)
-{
- int result = 0;
- LPFN_ISWOW64PROCESS fnIsWow64Process;
-
- /* IsWow64Process is not available on all supported versions of Windows.
- Use GetModuleHandle to get a handle to the DLL that contains the function
- and GetProcAddress to get a pointer to the function if available. */
-
- fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(
- GetModuleHandle(TEXT("kernel32")), "IsWow64Process");
-
- if (!fnIsWow64Process) {
- LOG_WARNING("GetProcAddress(IsWow64Process) failed, %s return false\n",
- __func__);
- return 0;
- }
- /* No need to handle error,
- just check whether is this WoW64 process */
- fnIsWow64Process(GetCurrentProcess(), &result);
-
- return result;
-}
-#endif
-
/* Gets the JavaHome path from the windows registry.
Must call the RegOpenKeyEx by using the following flag.
For details, "http://stackoverflow.com/questions/10533421/
#define MY_KEY_WOW64_64KEY 0x0100
void get_java_path_win32(const char **java_path)
{
-#ifdef _WIN64
- *java_path = "javaw.exe";
-#else
LONG res;
HKEY hKey;
char strKey[PATH_MAX] = {0};
char strVersion[PATH_MAX] = {0};
char strJavaHome[PATH_MAX] = {0};
DWORD dwBufLen = PATH_MAX;
- static char wow64_java_path[PATH_MAX];
+ static char current_java_path[PATH_MAX];
- // we should try it no matter what happens
- *java_path = "javaw.exe";
-
- if (!is_wow64()) {
- return;
- }
-
- if (wow64_java_path[0] != '\0') {
- *java_path = wow64_java_path;
+ if (current_java_path[0] != '\0') {
+ *java_path = current_java_path;
return;
}
PATH_MAX);
if (dwBufLen == 0) {
LOG_WARNING("There is no JavaHome\n");
- // try it with "javaw.exe"
+ /* try it with "javaw.exe" */
+ *java_path = "javaw.exe";
return;
}
}
- g_sprintf(wow64_java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome);
- LOG_INFO("JavaHome: %s\n", wow64_java_path);
+ g_sprintf(current_java_path, "\"%s\\bin\\javaw.exe\"", strJavaHome);
+ LOG_INFO("CurrentVersion JavaHome path: %s\n", current_java_path);
- *java_path = wow64_java_path;
-#endif
+ *java_path = current_java_path;
}