From 4e84249de5d824e6fe4ecd1f2f91d0d8170193d5 Mon Sep 17 00:00:00 2001 From: Jinhyung Jo Date: Mon, 25 Jan 2016 19:44:25 +0900 Subject: [PATCH] osutil-win32: always get java path from registry Regardless of the architecture of the emulator(32bit or 64bit), always gets the java execution path from Windows registry. This commit would be helpful to reduce the java execution failure. Conflicts: tizen/src/util/osutil-win32.c Change-Id: I4680c888292a0c11d85f7a662708faf8973c6bc4 Signed-off-by: Jinhyung Jo (cherry picked from commit 6eb715fd787c0f25a519903b8a552d8e95d0e6b7) --- tizen/src/util/osutil-win32.c | 54 +++++++------------------------------------ 1 file changed, 8 insertions(+), 46 deletions(-) diff --git a/tizen/src/util/osutil-win32.c b/tizen/src/util/osutil-win32.c index a4c522a..f1e3f80 100644 --- a/tizen/src/util/osutil-win32.c +++ b/tizen/src/util/osutil-win32.c @@ -238,34 +238,6 @@ int remove_sdcard_lock_os(char *sdcard) } } -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/ @@ -273,26 +245,16 @@ static int is_wow64(void) #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; } @@ -349,13 +311,13 @@ javahome_not_found: 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; } -- 2.7.4