• R/O
  • SSH
  • HTTPS

exewrap: Commit


Commit MetaInfo

Revision55 (tree)
Time2018-06-27 20:24:13
Authorhirukawa_ryo

Log Message

* exewrap 1.2.6
-P オプションで実行時の特権要求を指定できるようになりました。asInvoker, highestAvailable, requireAdministrator

Change Summary

Incremental Difference

--- exewrap/trunk/exewrap/src/Makefile (revision 54)
+++ exewrap/trunk/exewrap/src/Makefile (revision 55)
@@ -6,6 +6,7 @@
66 LINK = link.exe
77 RC = rc.exe
88 MT = mt.exe
9+JAVA = java.exe
910 JAVAC = javac.exe
1011 JAR = jar.exe
1112
@@ -65,23 +66,47 @@
6566 $(OBJ)\util.jar $(OBJ)\tool.jar $(OBJ)\loader.jar
6667 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /MANIFESTFILE:$(OBJ)\exewrap.exe.manifest /OUT:$(OBJ)\exewrap.exe $(OBJ)\exewrap.res $(OBJ)\exewrap.obj \
6768 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
68- $(MT) -manifest $(OBJ)\exewrap.exe.manifest -outputresource:$(BIN)\exewrap.exe;1
69+ $(MT) -manifest $(OBJ)\exewrap.exe.manifest -outputresource:$(OBJ)\exewrap.exe;1
6970 $(OBJ)\bindres.exe $(OBJ)\exewrap.exe VERSION_INFO resources\versioninfo.bin
70- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_32 $(OBJ)\..\x86\image_console.exe
71- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_64 $(OBJ)\..\x64\image_console.exe
72- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_32 $(OBJ)\..\x86\image_gui.exe
73- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_64 $(OBJ)\..\x64\image_gui.exe
74- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_32 $(OBJ)\..\x86\image_service.exe
75- $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_64 $(OBJ)\..\x64\image_service.exe
76- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
77- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
78- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
79- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
80- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
81- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
82- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe LOADER_JAR $(OBJ)\loader.jar
83- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe UTIL_JAR $(OBJ)\util.jar
84- $(OBJ)\bindres.exe $(OBJ)\exewrap.exe JAR $(OBJ)\tool.jar
71+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_32 $(OBJ)\..\x86\image_console.exe
72+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_32_MF_DEFAULT $(OBJ)\..\x86\image_console.exe.manifest
73+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_32_MF_ADMIN $(OBJ)\..\x86\image_console.exe.manifest.requireAdministrator
74+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_32_MF_HIGHEST $(OBJ)\..\x86\image_console.exe.manifest.highestAvailable
75+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_32_MF_INVOKER $(OBJ)\..\x86\image_console.exe.manifest.asInvoker
76+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_CONSOLE_64 $(OBJ)\..\x64\image_console.exe
77+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_64_MF_DEFAULT $(OBJ)\..\x64\image_console.exe.manifest
78+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_64_MF_ADMIN $(OBJ)\..\x64\image_console.exe.manifest.requireAdministrator
79+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_64_MF_HIGHEST $(OBJ)\..\x64\image_console.exe.manifest.highestAvailable
80+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_CONSOLE_64_MF_INVOKER $(OBJ)\..\x64\image_console.exe.manifest.asInvoker
81+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_32 $(OBJ)\..\x86\image_gui.exe
82+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_32_MF_DEFAULT $(OBJ)\..\x86\image_gui.exe.manifest
83+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_32_MF_ADMIN $(OBJ)\..\x86\image_gui.exe.manifest.requireAdministrator
84+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_32_MF_HIGHEST $(OBJ)\..\x86\image_gui.exe.manifest.highestAvailable
85+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_32_MF_INVOKER $(OBJ)\..\x86\image_gui.exe.manifest.asInvoker
86+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_GUI_64 $(OBJ)\..\x64\image_gui.exe
87+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_64_MF_DEFAULT $(OBJ)\..\x64\image_gui.exe.manifest
88+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_64_MF_ADMIN $(OBJ)\..\x64\image_gui.exe.manifest.requireAdministrator
89+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_64_MF_HIGHEST $(OBJ)\..\x64\image_gui.exe.manifest.highestAvailable
90+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_GUI_64_MF_INVOKER $(OBJ)\..\x64\image_gui.exe.manifest.asInvoker
91+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_32 $(OBJ)\..\x86\image_service.exe
92+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_32_MF_DEFAULT $(OBJ)\..\x86\image_service.exe.manifest
93+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_32_MF_ADMIN $(OBJ)\..\x86\image_service.exe.manifest.requireAdministrator
94+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_32_MF_HIGHEST $(OBJ)\..\x86\image_service.exe.manifest.highestAvailable
95+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_32_MF_INVOKER $(OBJ)\..\x86\image_service.exe.manifest.asInvoker
96+ $(OBJ)\bindres.exe -r $(OBJ)\exewrap.exe IMAGE_SERVICE_64 $(OBJ)\..\x64\image_service.exe
97+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_64_MF_DEFAULT $(OBJ)\..\x64\image_service.exe.manifest
98+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_64_MF_ADMIN $(OBJ)\..\x64\image_service.exe.manifest.requireAdministrator
99+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_64_MF_HIGHEST $(OBJ)\..\x64\image_service.exe.manifest.highestAvailable
100+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe IMAGE_SERVICE_64_MF_INVOKER $(OBJ)\..\x64\image_service.exe.manifest.asInvoker
101+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
102+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
103+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
104+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_CONNECTION $(OBJ)\exewrap\core\URLConnection.class
105+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER $(OBJ)\exewrap\core\URLStreamHandler.class
106+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe URL_STREAM_HANDLER_FACTORY $(OBJ)\exewrap\core\URLStreamHandlerFactory.class
107+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe LOADER_JAR $(OBJ)\loader.jar
108+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe UTIL_JAR $(OBJ)\util.jar
109+ $(OBJ)\bindres.exe $(OBJ)\exewrap.exe JAR $(OBJ)\tool.jar
85110 copy /V /Y /B $(OBJ)\exewrap.exe + $(OBJ)\loader.jar $(BIN)\exewrap.exe
86111
87112 $(OBJ)\exewrap.obj : $(OBJ) exewrap.c
@@ -92,13 +117,13 @@
92117
93118 $(OBJ)\image_console.exe : $(OBJ) $(OBJ)\image_console.res $(OBJ)\image_console.obj \
94119 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj \
95- $(OBJ)\bindres.exe \
120+ $(OBJ)\bindres.exe $(OBJ)\CopyManifest.class \
96121 $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
97122 $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
98123 $(OBJ)\util.jar
99124 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_console.exe $(OBJ)\image_console.res $(OBJ)\image_console.obj \
100125 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
101- $(MT) -manifest $(OBJ)\image_console.exe.manifest -outputresource:$(OBJ)\image_console.exe;1
126+ $(JAVA) -cp $(OBJ) CopyManifest $(OBJ)\image_console.exe.manifest
102127 $(OBJ)\bindres.exe $(OBJ)\image_console.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
103128 $(OBJ)\bindres.exe $(OBJ)\image_console.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
104129 $(OBJ)\bindres.exe $(OBJ)\image_console.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
@@ -115,13 +140,13 @@
115140
116141 $(OBJ)\image_gui.exe : $(OBJ) $(OBJ)\image_gui.res $(OBJ)\image_gui.obj \
117142 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj \
118- $(OBJ)\bindres.exe \
143+ $(OBJ)\bindres.exe $(OBJ)\CopyManifest.class \
119144 $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
120145 $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
121146 $(OBJ)\util.jar
122147 $(LINK) $(LDFLAGS) /SUBSYSTEM:WINDOWS$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_gui.exe $(OBJ)\image_gui.res $(OBJ)\image_gui.obj \
123148 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\notify.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
124- $(MT) -manifest $(OBJ)\image_gui.exe.manifest -outputresource:$(OBJ)\image_gui.exe;1
149+ $(JAVA) -cp $(OBJ) CopyManifest $(OBJ)\image_gui.exe.manifest
125150 $(OBJ)\bindres.exe $(OBJ)\image_gui.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
126151 $(OBJ)\bindres.exe $(OBJ)\image_gui.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
127152 $(OBJ)\bindres.exe $(OBJ)\image_gui.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
@@ -138,13 +163,13 @@
138163
139164 $(OBJ)\image_service.exe : $(OBJ) $(OBJ)\image_service.res $(OBJ)\image_service.obj \
140165 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj \
141- $(OBJ)\bindres.exe \
166+ $(OBJ)\bindres.exe $(OBJ)\CopyManifest.class \
142167 $(OBJ)\exewrap\core\ByteBufferInputStream.class $(OBJ)\exewrap\core\NativeMethods.class $(OBJ)\exewrap\core\PackInputStream.class \
143168 $(OBJ)\exewrap\core\URLConnection.class $(OBJ)\exewrap\core\URLStreamHandler.class $(OBJ)\exewrap\core\URLStreamHandlerFactory.class \
144169 $(OBJ)\util.jar
145170 $(LINK) $(LDFLAGS) /SUBSYSTEM:CONSOLE$(TARGET_VER) /MANIFEST /OUT:$(OBJ)\image_service.exe $(OBJ)\image_service.res $(OBJ)\image_service.obj \
146171 $(OBJ)\jvm.obj $(OBJ)\loader.obj $(OBJ)\message.obj $(OBJ)\eventlog.obj $(LIBS) $(MSVCRT_PATCH)
147- $(MT) -manifest $(OBJ)\image_service.exe.manifest -outputresource:$(OBJ)\image_service.exe;1
172+ $(JAVA) -cp $(OBJ) CopyManifest $(OBJ)\image_service.exe.manifest
148173 $(OBJ)\bindres.exe $(OBJ)\image_service.exe BYTE_BUFFER_INPUT_STREAM $(OBJ)\exewrap\core\ByteBufferInputStream.class
149174 $(OBJ)\bindres.exe $(OBJ)\image_service.exe NATIVE_METHODS $(OBJ)\exewrap\core\NativeMethods.class
150175 $(OBJ)\bindres.exe $(OBJ)\image_service.exe PACK_INPUT_STREAM $(OBJ)\exewrap\core\PackInputStream.class
@@ -185,6 +210,12 @@
185210 ### Java
186211 ###
187212
213+### exe.manifest build tool
214+
215+$(OBJ)\CopyManifest.class : $(OBJ) java\CopyManifest.java
216+ $(JAVAC) -sourcepath java -d $(OBJ) java\CopyManifest.java
217+
218+
188219 ### exewrap system class loader
189220
190221 $(OBJ)\loader.jar : $(OBJ) $(OBJ)\exewrap-loader\Loader.class
@@ -244,3 +275,4 @@
244275
245276 $(OBJ)\exewrap\tool\JarProcessor.class : $(OBJ) java\exewrap\tool\JarProcessor.java
246277 $(JAVAC) -Xlint:none -g:none -source 1.5 -target 1.5 -sourcepath java -d $(OBJ) java\exewrap\tool\JarProcessor.java
278+
--- exewrap/trunk/exewrap/src/exewrap.c (revision 54)
+++ exewrap/trunk/exewrap/src/exewrap.c (revision 55)
@@ -40,6 +40,7 @@
4040 char* exe_file = NULL;
4141 int architecture_bits = 0;
4242 char image_name[32];
43+ char manifest_name[32];
4344 BYTE* image_buf;
4445 DWORD image_len;
4546 DWORD previous_revision = 0;
@@ -83,7 +84,7 @@
8384 exe_file = argv[0];
8485 }
8586
86- printf("exewrap 1.2.4 for %s (%d-bit) \r\n"
87+ printf("exewrap 1.2.6 for %s (%d-bit) \r\n"
8788 "Native executable java application wrapper.\r\n"
8889 "Copyright (C) 2005-2018 HIRUKAWA Ryo. All rights reserved.\r\n"
8990 "\r\n"
@@ -100,6 +101,7 @@
100101 " -a <vm-args> \t Set Java VM arguments.\r\n"
101102 " -b <vm-args> \t This arguments will be applied when the service was started without the SCM.\r\n"
102103 " -i <icon-file> \t Set application icon.\r\n"
104+ " -P <privilege> \t Set privilege. (asInvoker | highestAvailable | requireAdministrator)\r\n"
103105 " -v <version> \t Set version number.\r\n"
104106 " -d <description> \t Set file description.\r\n"
105107 " -c <copyright> \t Set copyright.\r\n"
@@ -184,6 +186,32 @@
184186 sprintf(image_name, "IMAGE_CONSOLE_%d", architecture_bits);
185187 }
186188
189+ if(opt['P'])
190+ {
191+ if(stricmp(opt['P'], "asInvoker") == 0)
192+ {
193+ sprintf(manifest_name, "%s%s", image_name, "_MF_INVOKER");
194+ printf("Privilege: asInvoker\n");
195+ }
196+ else if(stricmp(opt['P'], "highestAvailable") == 0)
197+ {
198+ sprintf(manifest_name, "%s%s", image_name, "_MF_HIGHEST");
199+ printf("Privilege: highestAvailable\n");
200+ }
201+ else if(stricmp(opt['P'], "requireAdministrator") == 0)
202+ {
203+ sprintf(manifest_name, "%s%s", image_name, "_MF_ADMIN");
204+ printf("Privilege: requireAdministrator\n");
205+ }
206+ else
207+ {
208+ printf("Invalid privilege value: %s\n", opt['P']);
209+ return 3;
210+ }
211+ } else {
212+ sprintf(manifest_name, "%s%s", image_name, "_MF_DEFAULT");
213+ }
214+
187215 GetResource(image_name, &res);
188216 image_buf = res.buf;
189217 image_len = res.len;
@@ -197,6 +225,9 @@
197225 goto EXIT;
198226 }
199227
228+ GetResource(manifest_name, &res);
229+ set_resource(exe_file, CREATEPROCESS_MANIFEST_RESOURCE_ID, RT_MANIFEST, res.buf, res.len);
230+
200231 if(opt['t'])
201232 {
202233 target_version = get_target_java_runtime_version(opt['t']);
--- exewrap/trunk/exewrap/src/java/CopyManifest.java (nonexistent)
+++ exewrap/trunk/exewrap/src/java/CopyManifest.java (revision 55)
@@ -0,0 +1,38 @@
1+import java.io.IOException;
2+import java.nio.charset.StandardCharsets;
3+import java.nio.file.Files;
4+import java.nio.file.Path;
5+import java.nio.file.Paths;
6+import java.util.regex.Matcher;
7+import java.util.regex.Pattern;
8+
9+public class CopyManifest {
10+
11+ private static Pattern pattern = Pattern.compile("<requestedExecutionLevel\\s+.*level=([^\\s/>]+)", Pattern.MULTILINE | Pattern.DOTALL);
12+
13+ public static void main(String[] args) throws IOException {
14+ if(args.length == 0) {
15+ return;
16+ }
17+
18+ Path input = Paths.get(args[0]);
19+ if(!Files.exists(input)) {
20+ return;
21+ }
22+
23+ String manifest = new String(Files.readAllBytes(input), StandardCharsets.UTF_8);
24+ Files.write(input.resolveSibling(input.getFileName().toString() + ".asInvoker"), replace(manifest, "asInvoker"));
25+ Files.write(input.resolveSibling(input.getFileName().toString() + ".highestAvailable"), replace(manifest, "highestAvailable"));
26+ Files.write(input.resolveSibling(input.getFileName().toString() + ".requireAdministrator"), replace(manifest, "requireAdministrator"));
27+ }
28+
29+ private static byte[] replace(String manifest, String executionLevel) {
30+ StringBuffer sb = new StringBuffer();
31+ Matcher m = pattern.matcher(manifest);
32+ while(m.find()) {
33+ m.appendReplacement(sb, m.group(0).replace(m.group(1), "'" + executionLevel + "'"));
34+ }
35+ m.appendTail(sb);
36+ return sb.toString().getBytes(StandardCharsets.UTF_8);
37+ }
38+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Show on old repository browser