OSDN Git Service

カスタムLaunch4jheadの更新
[charactermanaj/CharacterManaJ.git] / src / Launch4JStub / head_src / head.h
1 /*
2         Launch4j (http://launch4j.sourceforge.net/)
3         Cross-platform Java application wrapper for creating Windows native executables.
4
5         Copyright (c) 2004, 2015 Grzegorz Kowal,
6                                                          Ian Roberts (jdk preference patch)
7
8         Permission is hereby granted, free of charge, to any person obtaining a copy
9         of this software and associated documentation files (the "Software"), to deal
10         in the Software without restriction, including without limitation the rights
11         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12         copies of the Software, and to permit persons to whom the Software is
13         furnished to do so, subject to the following conditions:
14
15         The above copyright notice and this permission notice shall be included in
16         all copies or substantial portions of the Software.
17
18         Except as contained in this notice, the name(s) of the above copyright holders
19         shall not be used in advertising or otherwise to promote the sale, use or other
20         dealings in this Software without prior written authorization.
21
22         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
28         THE SOFTWARE.
29 */
30
31 #ifndef _WIN32_WINNT
32 #define _WIN32_WINNT 0x0501
33 #endif // _WIN32_WINNT
34
35 #ifndef _LAUNCH4J_HEAD__INCLUDED_
36 #define _LAUNCH4J_HEAD__INCLUDED_
37
38 #define WIN32_LEAN_AND_MEAN             // VC - Exclude rarely-used stuff from Windows headers
39
40 // Windows Header Files:
41 #include <windows.h>
42 #include <shlobj.h>
43
44 // C RunTime Header Files
45 #include <stdlib.h>
46 #include <malloc.h>
47 #include <memory.h>
48 #include <tchar.h>
49 #include <shellapi.h>
50 #include <direct.h>
51 #include <fcntl.h>
52 #include <stdio.h>
53 #include <sys/stat.h>
54 #include <io.h>
55 #include <process.h>
56 #include <locale.h>
57
58 #define LAUNCH4j "Launch4j"
59 #define VERSION "3.12"
60
61 #define JRE_VER_MAX_DIGITS_PER_PART 3
62
63 #define NO_JAVA_FOUND 0
64 #define FOUND_JRE 1
65 #define FOUND_SDK 2
66 #define FOUND_BUNDLED 4
67 #define FOUND_CHOOSED 8
68
69 #define JRE_ONLY 0
70 #define PREFER_JRE 1
71 #define PREFER_JDK 2
72 #define JDK_ONLY 3
73
74 #define USE_64_BIT_RUNTIME 1
75 #define USE_64_AND_32_BIT_RUNTIME 2
76 #define USE_32_AND_64_BIT_RUNTIME 3
77 #define USE_32_BIT_RUNTIME 4
78 #define INIT_RUNTIME_BITS 9
79
80 #define KEY_WOW64_64KEY 0x0100
81
82 #define HKEY_STR "HKEY"
83 #define HKEY_CLASSES_ROOT_STR "HKEY_CLASSES_ROOT"
84 #define HKEY_CURRENT_USER_STR "HKEY_CURRENT_USER"
85 #define HKEY_LOCAL_MACHINE_STR "HKEY_LOCAL_MACHINE"
86 #define HKEY_USERS_STR "HKEY_USERS"
87 #define HKEY_CURRENT_CONFIG_STR "HKEY_CURRENT_CONFIG"
88
89 #define STR 128
90 #define BIG_STR 1024
91 #define MAX_VAR_SIZE 32767
92 #define MAX_ARGS 32768
93
94 #define TRUE_STR "true"
95 #define FALSE_STR "false"
96
97 #define ERROR_FORMAT "Error:\t\t%s\n"
98 #define debug(args...) if (hLog != NULL) { fprintf(hLog, ## args); fflush(hLog); }
99 #define debugAll(args...) if (debugAll && hLog != NULL) fprintf(hLog, ## args);
100
101 typedef void (WINAPI *LPFN_ISWOW64PROCESS) (HANDLE, PBOOL);
102
103 BOOL initGlobals();
104 FILE* openLogFile(const char* exePath, const int pathLen);
105 void closeLogFile();
106 BOOL initializeLogging(const char *lpCmdLine, const char* exePath, const int pathLen);
107 void msgBox(const char* text);
108 void signalError();
109 BOOL loadString(const int resID, char* buffer);
110 BOOL loadBool(const int resID);
111 int loadInt(const int resID);
112 BOOL regQueryValue(const char* regPath, unsigned char* buffer,
113                 unsigned long bufferLength);
114 void formatJavaVersion(char* version, const char* originalVersion);
115 void regSearch(const char* keyName, const int searchType);
116 BOOL isJavaHomeValid(const char* keyName, const int searchType);
117 BOOL isLauncherPathValid(const char* path);
118 void regSearchWow(const char* keyName, const int searchType);
119 void regSearchJreSdk(const char* jreKeyName, const char* sdkKeyName,
120                 const int jdkPreference);
121 BOOL findJavaHome(char* path, const int jdkPreference);
122 int getExePath(char* exePath);
123 void appendPath(char* basepath, const char* path);
124 void appendLauncher(char* jrePath);
125 void appendAppClasspath(char* dst, const char* src);
126 BOOL expandVars(char *dst, const char *src, const char *exePath, const int pathLen);
127 void appendHeapSizes(char *dst);
128 void appendHeapSize(char *dst, const int megabytesID, const int percentID,
129                 const DWORDLONG availableMemory, const char *option);
130 void setJvmOptions(char *jvmOptions, const char *exePath, const int pathLen);
131 BOOL createMutex();
132 void setWorkingDirectory(const char *exePath, const int pathLen);
133 BOOL bundledJreSearch(const char *exePath, const int pathLen);
134 BOOL installedJreSearch();
135 void createJreSearchError();
136 BOOL jreSearch(const char *exePath, const int pathLen);
137 BOOL appendToPathVar(const char* path);
138 BOOL appendJreBinToPathVar();
139 void setEnvironmentVariables(const char *exePath, const int pathLen);
140 void setMainClassAndClassPath(const char *exePath, const int pathLen);
141 void setCommandLineArgs(const char *lpCmdLine, const char *exePath, const int pathLen);
142 int prepare(const char *lpCmdLine);
143 void closeProcessHandles();
144 BOOL execute(const BOOL wait, DWORD *dwExitCode);
145 const char* getJavaHome();
146 const char* getMainClass();
147 const char* getLauncherArgs();
148
149 #endif // _LAUNCH4J_HEAD__INCLUDED_