equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
346 } |
346 } |
347 } |
347 } |
348 |
348 |
349 JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); |
349 JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); |
350 return JNI_FALSE; |
350 return JNI_FALSE; |
351 |
|
352 } |
351 } |
353 |
352 |
354 /* |
353 /* |
355 * Given a JRE location and a JVM type, construct what the name the |
354 * Given a JRE location and a JVM type, construct what the name the |
356 * JVM shared library will be. Return true, if such a library |
355 * JVM shared library will be. Return true, if such a library |
421 { |
420 { |
422 char *cp; |
421 char *cp; |
423 *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ |
422 *JLI_StrRChr(buf, '\\') = '\0'; /* remove .exe file name */ |
424 if ((cp = JLI_StrRChr(buf, '\\')) == 0) { |
423 if ((cp = JLI_StrRChr(buf, '\\')) == 0) { |
425 /* This happens if the application is in a drive root, and |
424 /* This happens if the application is in a drive root, and |
426 * there is no bin directory. */ |
425 * there is no bin directory. */ |
427 buf[0] = '\0'; |
426 buf[0] = '\0'; |
428 return JNI_FALSE; |
427 return JNI_FALSE; |
429 } |
428 } |
430 *cp = '\0'; /* remove the bin\ part */ |
429 *cp = '\0'; /* remove the bin\ part */ |
431 return JNI_TRUE; |
430 return JNI_TRUE; |
432 } |
431 } |
433 |
432 |
434 /* |
433 /* |
435 * Retrieves the path to the JRE home by locating the executable file |
434 * Retrieves the path to the JRE home by locating the executable file |
447 * then truncating the path to JLI.DLL |
446 * then truncating the path to JLI.DLL |
448 */ |
447 */ |
449 jboolean |
448 jboolean |
450 GetApplicationHomeFromDll(char *buf, jint bufsize) |
449 GetApplicationHomeFromDll(char *buf, jint bufsize) |
451 { |
450 { |
452 HMODULE hModule; |
451 HMODULE module; |
453 DWORD dwFlags = |
452 DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
454 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | |
453 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; |
455 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; |
454 |
456 |
455 if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) { |
457 if (GetModuleHandleEx(dwFlags, (LPCSTR)&GetJREPath, &hModule) == 0) { |
456 if (GetModuleFileName(module, buf, bufsize) != 0) { |
458 return JNI_FALSE; |
457 return TruncatePath(buf); |
459 }; |
458 } |
460 GetModuleFileName(hModule, buf, bufsize); |
459 } |
461 return TruncatePath(buf); |
460 return JNI_FALSE; |
462 } |
461 } |
463 |
462 |
464 /* |
463 /* |
465 * Support for doing cheap, accurate interval timing. |
464 * Support for doing cheap, accurate interval timing. |
466 */ |
465 */ |