• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision95 (tree)
Time2020-09-14 13:47:30
Authorhirukawa_ryo

Log Message

* exewrap 1.6.3
-l オプションでJavaVMを検索する方法を指定できるようになりました。

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/exewrap.c (revision 94)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 95)
@@ -101,6 +101,7 @@
101101 L" -s \t Create Windows Service application.\r\n"
102102 L" -A <architecture> \t Select exe-file architecture. (default %ls)\r\n"
103103 L" -t <version> \t Set target java runtime version. (default 1.5)\r\n"
104+ L" -l <search-flags> \t Set Java VM search location flags\r\n"
104105 L" -M <main-class> \t Set main-class.\r\n"
105106 L" -L <ext-dirs> \t Set ext-dirs.\r\n"
106107 L" -e <ext-flags> \t Set extended flags.\r\n"
@@ -292,7 +293,7 @@
292293 free(utf8);
293294 }
294295
295- is_java_enabled = create_java_vm(NULL, FALSE, TRUE, NULL, NULL) != NULL;
296+ is_java_enabled = create_java_vm(NULL, FALSE, VM_SEARCH_ALL, NULL, NULL) != NULL;
296297 if(is_java_enabled)
297298 {
298299 LOAD_RESULT result;
@@ -489,6 +490,13 @@
489490 free(utf8);
490491 free(ext_flags);
491492
493+ if(opt['l'] != NULL && *opt['l'] != L'-' && *opt['l'] != L'\0')
494+ {
495+ utf8 = to_utf8(opt['l']);
496+ set_resource(exe_file, L"VM_SEARCH_LOCATIONS", RT_RCDATA, (BYTE*)utf8, (DWORD)(strlen(utf8) + 1));
497+ free(utf8);
498+ }
499+
492500 vmargs = (wchar_t*)malloc(BUFFER_SIZE * sizeof(wchar_t));
493501 if(vmargs == NULL)
494502 {
--- exewrap/trunk/exewrap/src/image_console.c (revision 94)
+++ exewrap/trunk/exewrap/src/image_console.c (revision 95)
@@ -31,7 +31,7 @@
3131 wchar_t* vm_args_opt = NULL;
3232 wchar_t* utilities = NULL;
3333 BOOL use_server_vm;
34- BOOL use_side_by_side_jre;
34+ DWORD vm_search_locations = 0;
3535 BOOL is_security_manager_required = FALSE;
3636 HANDLE synchronize_mutex_handle = NULL;
3737 HANDLE singleton_mutex_handle = NULL;
@@ -57,8 +57,24 @@
5757 relative_extdirs = from_utf8((char*)get_resource(L"EXTDIRS", NULL));
5858 ext_flags = from_utf8((char*)get_resource(L"EXTFLAGS", NULL));
5959 use_server_vm = (ext_flags != NULL && wcsstr(ext_flags, L"SERVER") != NULL);
60- use_side_by_side_jre = (ext_flags == NULL) || (wcsstr(ext_flags, L"NOSIDEBYSIDE") == NULL);
61- initialize_path(relative_classpath, relative_extdirs, use_server_vm, use_side_by_side_jre);
60+ {
61+ wchar_t* s = from_utf8((char*)get_resource(L"VM_SEARCH_LOCATIONS", NULL));
62+ if(s != NULL)
63+ {
64+ vm_search_locations += wcsstr(s, L"APPDIR") == NULL ? 0 : VM_SEARCH_APPDIR;
65+ vm_search_locations += wcsstr(s, L"PARENTDIR") == NULL ? 0 : VM_SEARCH_PARENTDIR;
66+ vm_search_locations += wcsstr(s, L"JAVAHOME") == NULL ? 0 : VM_SEARCH_JAVAHOME;
67+ vm_search_locations += wcsstr(s, L"REGISTRY") == NULL ? 0 : VM_SEARCH_REGISTRY;
68+ vm_search_locations += wcsstr(s, L"PATHENV") == NULL ? 0 : VM_SEARCH_PATHENV;
69+ vm_search_locations += wcsstr(s, L"JARASSOC") == NULL ? 0 : VM_SEARCH_JARASSOC;
70+ }
71+ if(vm_search_locations == 0)
72+ {
73+ vm_search_locations = VM_SEARCH_ALL;
74+ }
75+ free(s);
76+ }
77+ initialize_path(relative_classpath, relative_extdirs, use_server_vm, vm_search_locations);
6278
6379 if(ext_flags != NULL)
6480 {
@@ -128,7 +144,7 @@
128144 //wcscat_s(utilities, BUFFER_SIZE, UTIL_EVENT_LOG_HANDLER);
129145
130146 vm_args_opt = from_utf8((char*)get_resource(L"VMARGS", NULL));
131- create_java_vm(vm_args_opt, use_server_vm, use_side_by_side_jre, &is_security_manager_required, &error);
147+ create_java_vm(vm_args_opt, use_server_vm, vm_search_locations, &is_security_manager_required, &error);
132148 if(error != JNI_OK)
133149 {
134150 get_jni_error_message(error, &result.msg_id, result.msg, BUFFER_SIZE);
--- exewrap/trunk/exewrap/src/image_gui.c (revision 94)
+++ exewrap/trunk/exewrap/src/image_gui.c (revision 95)
@@ -53,7 +53,7 @@
5353 wchar_t* vm_args_opt = NULL;
5454 wchar_t* utilities = NULL;
5555 BOOL use_server_vm;
56- BOOL use_side_by_side_jre;
56+ DWORD vm_search_locations = 0;
5757 BOOL is_security_manager_required = FALSE;
5858 HANDLE synchronize_mutex_handle = NULL;
5959 HANDLE singleton_mutex_handle = NULL;
@@ -84,8 +84,24 @@
8484 relative_extdirs = from_utf8((char*)get_resource(L"EXTDIRS", NULL));
8585 ext_flags = from_utf8((char*)get_resource(L"EXTFLAGS", NULL));
8686 use_server_vm = (ext_flags != NULL && wcsstr(ext_flags, L"SERVER") != NULL);
87- use_side_by_side_jre = (ext_flags == NULL) || (wcsstr(ext_flags, L"NOSIDEBYSIDE") == NULL);
88- initialize_path(relative_classpath, relative_extdirs, use_server_vm, use_side_by_side_jre);
87+ {
88+ wchar_t* s = from_utf8((char*)get_resource(L"VM_SEARCH_LOCATIONS", NULL));
89+ if(s != NULL)
90+ {
91+ vm_search_locations += wcsstr(s, L"APPDIR") == NULL ? 0 : VM_SEARCH_APPDIR;
92+ vm_search_locations += wcsstr(s, L"PARENTDIR") == NULL ? 0 : VM_SEARCH_PARENTDIR;
93+ vm_search_locations += wcsstr(s, L"JAVAHOME") == NULL ? 0 : VM_SEARCH_JAVAHOME;
94+ vm_search_locations += wcsstr(s, L"REGISTRY") == NULL ? 0 : VM_SEARCH_REGISTRY;
95+ vm_search_locations += wcsstr(s, L"PATHENV") == NULL ? 0 : VM_SEARCH_PATHENV;
96+ vm_search_locations += wcsstr(s, L"JARASSOC") == NULL ? 0 : VM_SEARCH_JARASSOC;
97+ }
98+ if(vm_search_locations == 0)
99+ {
100+ vm_search_locations = VM_SEARCH_ALL;
101+ }
102+ free(s);
103+ }
104+ initialize_path(relative_classpath, relative_extdirs, use_server_vm, vm_search_locations);
89105
90106 if(ext_flags != NULL)
91107 {
@@ -190,7 +206,7 @@
190206 }
191207
192208 vm_args_opt = from_utf8((char*)get_resource(L"VMARGS", NULL));
193- create_java_vm(vm_args_opt, use_server_vm, use_side_by_side_jre, &is_security_manager_required, &error);
209+ create_java_vm(vm_args_opt, use_server_vm, vm_search_locations, &is_security_manager_required, &error);
194210 if(error != JNI_OK)
195211 {
196212 get_jni_error_message(error, &result.msg_id, result.msg, BUFFER_SIZE);
--- exewrap/trunk/exewrap/src/image_service.c (revision 94)
+++ exewrap/trunk/exewrap/src/image_service.c (revision 95)
@@ -205,7 +205,7 @@
205205 wchar_t* vm_args_opt = NULL;
206206 wchar_t* utilities = NULL;
207207 BOOL use_server_vm;
208- BOOL use_side_by_side_jre;
208+ DWORD vm_search_locations = 0;
209209 BOOL is_security_manager_required = FALSE;
210210 RESOURCE res;
211211 LOAD_RESULT result = { 0 };
@@ -243,8 +243,24 @@
243243 relative_extdirs = from_utf8((char*)get_resource(L"EXTDIRS", NULL));
244244 ext_flags = from_utf8((char*)get_resource(L"EXTFLAGS", NULL));
245245 use_server_vm = (ext_flags != NULL && wcsstr(ext_flags, L"SERVER") != NULL);
246- use_side_by_side_jre = (ext_flags == NULL) || (wcsstr(ext_flags, L"NOSIDEBYSIDE") == NULL);
247- initialize_path(relative_classpath, relative_extdirs, use_server_vm, use_side_by_side_jre);
246+ {
247+ wchar_t* s = from_utf8((char*)get_resource(L"VM_SEARCH_LOCATIONS", NULL));
248+ if(s != NULL)
249+ {
250+ vm_search_locations += wcsstr(s, L"APPDIR") == NULL ? 0 : VM_SEARCH_APPDIR;
251+ vm_search_locations += wcsstr(s, L"PARENTDIR") == NULL ? 0 : VM_SEARCH_PARENTDIR;
252+ vm_search_locations += wcsstr(s, L"JAVAHOME") == NULL ? 0 : VM_SEARCH_JAVAHOME;
253+ vm_search_locations += wcsstr(s, L"REGISTRY") == NULL ? 0 : VM_SEARCH_REGISTRY;
254+ vm_search_locations += wcsstr(s, L"PATHENV") == NULL ? 0 : VM_SEARCH_PATHENV;
255+ vm_search_locations += wcsstr(s, L"JARASSOC") == NULL ? 0 : VM_SEARCH_JARASSOC;
256+ }
257+ if(vm_search_locations == 0)
258+ {
259+ vm_search_locations = VM_SEARCH_ALL;
260+ }
261+ free(s);
262+ }
263+ initialize_path(relative_classpath, relative_extdirs, use_server_vm, vm_search_locations);
248264
249265 if(ext_flags == NULL || wcsstr(ext_flags, L"NOENCODINGFIX") == NULL)
250266 {
@@ -276,7 +292,7 @@
276292 {
277293 vm_args_opt = from_utf8((char*)get_resource(L"VMARGS", NULL));
278294 }
279- create_java_vm(vm_args_opt, use_server_vm, use_side_by_side_jre, &is_security_manager_required, &error);
295+ create_java_vm(vm_args_opt, use_server_vm, vm_search_locations, &is_security_manager_required, &error);
280296 if(error != JNI_OK)
281297 {
282298 get_jni_error_message(error, &result.msg_id, result.msg, BUFFER_SIZE);
--- exewrap/trunk/exewrap/src/include/jvm.h (revision 94)
+++ exewrap/trunk/exewrap/src/include/jvm.h (revision 95)
@@ -5,6 +5,13 @@
55
66 #define JVM_ELOADLIB (+1)
77
8+#define VM_SEARCH_APPDIR (0x00000001)
9+#define VM_SEARCH_PARENTDIR (0x00000002)
10+#define VM_SEARCH_JAVAHOME (0x00000004)
11+#define VM_SEARCH_REGISTRY (0x00000008)
12+#define VM_SEARCH_PATHENV (0x00000010)
13+#define VM_SEARCH_JARASSOC (0x00000020)
14+#define VM_SEARCH_ALL (0xFFFFFFFF)
815
916 #ifdef __cplusplus
1017 extern "C" {
@@ -13,8 +20,8 @@
1320
1421 extern int get_process_architecture(void);
1522 extern int get_platform_architecture(void);
16-extern BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, BOOL use_side_by_side_jre);
17-extern JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, BOOL use_side_by_side_jre, BOOL* is_security_manager_required, int* error);
23+extern BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, DWORD vm_search_locations);
24+extern JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, DWORD vm_search_locations, BOOL* is_security_manager_required, int* error);
1825 extern jint destroy_java_vm(void);
1926 extern JNIEnv* attach_java_vm(void);
2027 extern jint detach_java_vm(void);
--- exewrap/trunk/exewrap/src/jvm.c (revision 94)
+++ exewrap/trunk/exewrap/src/jvm.c (revision 95)
@@ -6,13 +6,22 @@
66 #include <jni.h>
77
88 #define JVM_ELOADLIB (+1)
9+
10+#define VM_SEARCH_APPDIR (0x00000001)
11+#define VM_SEARCH_PARENTDIR (0x00000002)
12+#define VM_SEARCH_JAVAHOME (0x00000004)
13+#define VM_SEARCH_REGISTRY (0x00000008)
14+#define VM_SEARCH_PATHENV (0x00000010)
15+#define VM_SEARCH_JARASSOC (0x00000020)
16+#define VM_SEARCH_ALL (0xFFFFFFFF)
17+
918 #define BUFFER_SIZE 32768
1019 #define MAX_LONG_PATH 32768
1120
1221 int get_process_architecture(void);
1322 int get_platform_architecture(void);
14-BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, BOOL use_side_by_side_jre);
15-JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, BOOL use_side_by_side_jre, BOOL* is_security_manager_required, int* error);
23+BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, DWORD vm_search_locations);
24+JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, DWORD vm_search_locations, BOOL* is_security_manager_required, int* error);
1625 jint destroy_java_vm(void);
1726 JNIEnv* attach_java_vm(void);
1827 jint detach_java_vm(void);
@@ -94,7 +103,7 @@
94103 }
95104
96105
97-JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, BOOL use_side_by_side_jre, BOOL* is_security_manager_required, int* error)
106+JNIEnv* create_java_vm(const wchar_t* vm_args_opt, BOOL use_server_vm, DWORD vm_search_locations, BOOL* is_security_manager_required, int* error)
98107 {
99108 JNIGetDefaultJavaVMInitArgs GetDefaultJavaVMInitArgs;
100109 JNICreateJavaVM CreateJavaVM;
@@ -111,7 +120,7 @@
111120
112121 if(!path_initialized)
113122 {
114- initialize_path(NULL, L"lib", use_server_vm, use_side_by_side_jre);
123+ initialize_path(NULL, L"lib", use_server_vm, vm_search_locations);
115124 }
116125
117126 if(jvmdll == NULL)
@@ -831,7 +840,7 @@
831840 }
832841
833842
834-BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, BOOL use_side_by_side_jre)
843+BOOL initialize_path(const wchar_t* relative_classpath, const wchar_t* relative_extdirs, BOOL use_server_vm, DWORD vm_search_locations)
835844 {
836845 wchar_t* module_path = NULL;
837846 wchar_t* buffer = NULL;
@@ -914,7 +923,7 @@
914923 jvmpath[0] = L'\0';
915924
916925 // Find local JDK
917- if(use_side_by_side_jre && jvmpath[0] == L'\0')
926+ if((vm_search_locations & VM_SEARCH_APPDIR) && jvmpath[0] == L'\0')
918927 {
919928 wcscpy_s(buffer, BUFFER_SIZE, module_path);
920929 wcscpy_s(search, MAX_LONG_PATH, buffer);
@@ -988,7 +997,7 @@
988997 }
989998
990999 // Find local JRE
991- if(use_side_by_side_jre && jvmpath[0] == L'\0')
1000+ if((vm_search_locations & VM_SEARCH_APPDIR) && jvmpath[0] == L'\0')
9921001 {
9931002 wcscpy_s(buffer, BUFFER_SIZE, module_path);
9941003 wcscpy_s(search, MAX_LONG_PATH, buffer);
@@ -1031,12 +1040,12 @@
10311040 }
10321041 }
10331042
1034- // Find local JRE (from parent folder)
1035- if(use_side_by_side_jre && jvmpath[0] == 0)
1043+ // Find local JDK (from parent folder)
1044+ if((vm_search_locations & VM_SEARCH_PARENTDIR) && jvmpath[0] == L'\0')
10361045 {
10371046 wcscpy_s(buffer, BUFFER_SIZE, module_path);
10381047 wcscpy_s(search, MAX_LONG_PATH, buffer);
1039- wcscat_s(search, MAX_LONG_PATH, L"\\..\\jre*");
1048+ wcscat_s(search, MAX_LONG_PATH, L"\\..\\jdk*");
10401049 hSearch = FindFirstFile(search, &fd);
10411050 if(hSearch != INVALID_HANDLE_VALUE)
10421051 {
@@ -1075,74 +1084,28 @@
10751084 }
10761085 }
10771086
1078- // Find JDK/JRE from JAVA_HOME or registry
1079- if(jvmpath[0] == L'\0')
1087+ // Find local JRE (from parent folder)
1088+ if((vm_search_locations & VM_SEARCH_PARENTDIR) && jvmpath[0] == L'\0')
10801089 {
1081- buffer[0] = L'\0';
1082- if(GetEnvironmentVariable(L"JAVA_HOME", buffer, MAX_LONG_PATH) == 0)
1090+ wcscpy_s(buffer, BUFFER_SIZE, module_path);
1091+ wcscpy_s(search, MAX_LONG_PATH, buffer);
1092+ wcscat_s(search, MAX_LONG_PATH, L"\\..\\jre*");
1093+ hSearch = FindFirstFile(search, &fd);
1094+ if(hSearch != INVALID_HANDLE_VALUE)
10831095 {
1084- wchar_t* subkeys_native[] =
1096+ found = FALSE;
1097+ do
10851098 {
1086- L"SOFTWARE\\JavaSoft\\JDK", //Java9-
1087- L"SOFTWARE\\JavaSoft\\JRE", //Java9-
1088- L"SOFTWARE\\JavaSoft\\Java Development Kit",
1089- L"SOFTWARE\\JavaSoft\\Java Runtime Environment",
1090- NULL
1091- };
1092-
1093- wchar_t* subkeys_wow[] =
1094- {
1095- L"SOFTWARE\\Wow6432Node\\JavaSoft\\JDK", //Java9-
1096- L"SOFTWARE\\Wow6432Node\\JavaSoft\\JRE", //Java9-
1097- L"SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit",
1098- L"SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment",
1099- NULL
1100- };
1101-
1102- wchar_t** subkeys = subkeys_native;
1103- int i = 0;
1104-
1105- //32ビットプロセスを64ビットOSで実行している場合はWowレジストリから検索します。
1106- if(get_process_architecture() == 32 && get_platform_architecture() == 64)
1107- {
1108- subkeys = subkeys_wow;
1109- }
1110-
1111- while(subkeys[i] != NULL)
1112- {
1113- if(find_java_home_from_registry(subkeys[i], buffer) != NULL)
1099+ if (fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
11141100 {
1115- // JDK/JREをアンインストールしてもレジストリが残ってしまうディストリビューションがあるようです。
1116- // ディレクトリが存在する場合は次の工程に進みます。
1117- if(is_directory(buffer))
1118- {
1119- break;
1120- }
1101+ wcscat_s(buffer, BUFFER_SIZE, L"\\..\\");
1102+ wcscat_s(buffer, BUFFER_SIZE, fd.cFileName);
1103+ found = TRUE;
11211104 }
1122- i++;
1123- }
1124- }
1125-
1126- if(buffer[0] != L'\0')
1127- {
1128- // bufferにはJAVA_HOME環境変数の値が入っています。
1129-
1130- // 下位に jre フォルダーがあるか確認します。
1131- if(buffer[wcslen(buffer) - 1] == L'\\')
1105+ } while (!found && FindNextFile(hSearch, &fd));
1106+ FindClose(hSearch);
1107+ if(found)
11321108 {
1133- wcscat_s(buffer, BUFFER_SIZE, L"jre");
1134- }
1135- else
1136- {
1137- wcscat_s(buffer, BUFFER_SIZE, L"\\jre");
1138- }
1139- // 下位に jre フォルダーがなければ元のフォルダーに戻します。
1140- if(!is_directory(buffer))
1141- {
1142- *(wcsrchr(buffer, L'\\')) = L'\0';
1143- }
1144- if(is_directory(buffer))
1145- {
11461109 if(find_java_vm(jvmpath, buffer, use_server_vm))
11471110 {
11481111 int bits = get_java_vm_bits(jvmpath);
@@ -1165,8 +1128,132 @@
11651128 }
11661129 }
11671130
1131+ // Find JDK/JRE from JAVA_HOME
1132+ if((vm_search_locations & VM_SEARCH_JAVAHOME) && jvmpath[0] == L'\0')
1133+ {
1134+ buffer[0] = L'\0';
1135+ if(GetEnvironmentVariable(L"JAVA_HOME", buffer, MAX_LONG_PATH) > 0)
1136+ {
1137+ // 下位に jre フォルダーがあるか確認します。
1138+ if(buffer[wcslen(buffer) - 1] == L'\\')
1139+ {
1140+ wcscat_s(buffer, BUFFER_SIZE, L"jre");
1141+ }
1142+ else
1143+ {
1144+ wcscat_s(buffer, BUFFER_SIZE, L"\\jre");
1145+ }
1146+ // 下位に jre フォルダーがなければ元のフォルダーに戻します。
1147+ if(!is_directory(buffer))
1148+ {
1149+ *(wcsrchr(buffer, L'\\')) = L'\0';
1150+ }
1151+ if(is_directory(buffer))
1152+ {
1153+ if(find_java_vm(jvmpath, buffer, use_server_vm))
1154+ {
1155+ int bits = get_java_vm_bits(jvmpath);
1156+ if(bits == get_process_architecture())
1157+ {
1158+ if(buffer[wcslen(buffer) - 1] != L'\\')
1159+ {
1160+ wcscat_s(buffer, BUFFER_SIZE, L"\\");
1161+ }
1162+ SetEnvironmentVariable(L"JAVA_HOME", buffer);
1163+ wcscpy_s(binpath, MAX_LONG_PATH, buffer);
1164+ wcscat_s(binpath, MAX_LONG_PATH, L"bin");
1165+ }
1166+ else
1167+ {
1168+ jvmpath[0] = L'\0';
1169+ }
1170+ }
1171+ }
1172+ }
1173+ }
1174+
1175+ // Find JDK/JRE from registry
1176+ if((vm_search_locations & VM_SEARCH_REGISTRY) && jvmpath[0] == L'\0')
1177+ {
1178+ wchar_t* subkeys_native[] =
1179+ {
1180+ L"SOFTWARE\\JavaSoft\\JDK", //Java9-
1181+ L"SOFTWARE\\JavaSoft\\JRE", //Java9-
1182+ L"SOFTWARE\\JavaSoft\\Java Development Kit",
1183+ L"SOFTWARE\\JavaSoft\\Java Runtime Environment",
1184+ NULL
1185+ };
1186+
1187+ wchar_t* subkeys_wow[] =
1188+ {
1189+ L"SOFTWARE\\Wow6432Node\\JavaSoft\\JDK", //Java9-
1190+ L"SOFTWARE\\Wow6432Node\\JavaSoft\\JRE", //Java9-
1191+ L"SOFTWARE\\Wow6432Node\\JavaSoft\\Java Development Kit",
1192+ L"SOFTWARE\\Wow6432Node\\JavaSoft\\Java Runtime Environment",
1193+ NULL
1194+ };
1195+
1196+ wchar_t** subkeys = subkeys_native;
1197+ int i = 0;
1198+
1199+ //32ビットプロセスを64ビットOSで実行している場合はWowレジストリから検索します。
1200+ if(get_process_architecture() == 32 && get_platform_architecture() == 64)
1201+ {
1202+ subkeys = subkeys_wow;
1203+ }
1204+
1205+ while(subkeys[i] != NULL)
1206+ {
1207+ if(find_java_home_from_registry(subkeys[i], buffer) != NULL)
1208+ {
1209+ // JDK/JREをアンインストールしてもレジストリが残ってしまうディストリビューションがあるようです。
1210+ // ディレクトリが存在する場合は次の工程に進みます。
1211+ if(is_directory(buffer))
1212+ {
1213+ // 下位に jre フォルダーがあるか確認します。
1214+ if(buffer[wcslen(buffer) - 1] == L'\\')
1215+ {
1216+ wcscat_s(buffer, BUFFER_SIZE, L"jre");
1217+ }
1218+ else
1219+ {
1220+ wcscat_s(buffer, BUFFER_SIZE, L"\\jre");
1221+ }
1222+ // 下位に jre フォルダーがなければ元のフォルダーに戻します。
1223+ if(!is_directory(buffer))
1224+ {
1225+ *(wcsrchr(buffer, L'\\')) = L'\0';
1226+ }
1227+ if(is_directory(buffer))
1228+ {
1229+ if(find_java_vm(jvmpath, buffer, use_server_vm))
1230+ {
1231+ int bits = get_java_vm_bits(jvmpath);
1232+ if(bits == get_process_architecture())
1233+ {
1234+ if(buffer[wcslen(buffer) - 1] != L'\\')
1235+ {
1236+ wcscat_s(buffer, BUFFER_SIZE, L"\\");
1237+ }
1238+ SetEnvironmentVariable(L"JAVA_HOME", buffer);
1239+ wcscpy_s(binpath, MAX_LONG_PATH, buffer);
1240+ wcscat_s(binpath, MAX_LONG_PATH, L"bin");
1241+ break; // JavaVM found!!
1242+ }
1243+ else
1244+ {
1245+ jvmpath[0] = L'\0';
1246+ }
1247+ }
1248+ }
1249+ }
1250+ }
1251+ i++;
1252+ }
1253+ }
1254+
11681255 // Find java.exe from PATH environment
1169- if(jvmpath[0] == L'\0')
1256+ if((vm_search_locations & VM_SEARCH_PATHENV) && jvmpath[0] == L'\0')
11701257 {
11711258 if(GetEnvironmentVariable(L"PATH", buffer, BUFFER_SIZE))
11721259 {
@@ -1256,7 +1343,7 @@
12561343 }
12571344
12581345 // Find .jar association from registry
1259- if(jvmpath[0] == L'\0')
1346+ if((vm_search_locations & VM_SEARCH_JARASSOC) && jvmpath[0] == L'\0')
12601347 {
12611348 HKEY key1 = NULL;
12621349 HKEY key2 = NULL;
Show on old repository browser