diff options
author | Ron Yorston <rmy@pobox.com> | 2019-02-17 13:59:17 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2019-02-17 13:59:17 +0000 |
commit | 743580b4c029e200b1390075a1328ab314973bc2 (patch) | |
tree | ee967e8fe9f8c2016d50fddbe2b8837b6fa7aa79 | |
parent | 5d710374afe4545d8e14c0559857b50ceceb1df3 (diff) | |
download | busybox-w32-743580b4c029e200b1390075a1328ab314973bc2.tar.gz busybox-w32-743580b4c029e200b1390075a1328ab314973bc2.tar.bz2 busybox-w32-743580b4c029e200b1390075a1328ab314973bc2.zip |
ash: updated support for hiding console
Move the code to hide the console to a separate function in
win32/mingw.c. Use lazy loading to avoid problems on platforms
where the require APIs aren't supported (PR #70).
Enable console hiding in the default 64-bit configuration.
-rw-r--r-- | configs/mingw64_defconfig | 2 | ||||
-rw-r--r-- | include/mingw.h | 1 | ||||
-rw-r--r-- | shell/ash.c | 12 | ||||
-rw-r--r-- | win32/mingw.c | 16 |
4 files changed, 21 insertions, 10 deletions
diff --git a/configs/mingw64_defconfig b/configs/mingw64_defconfig index a0569b23a..2f85f2883 100644 --- a/configs/mingw64_defconfig +++ b/configs/mingw64_defconfig | |||
@@ -1112,7 +1112,7 @@ CONFIG_ASH_TEST=y | |||
1112 | CONFIG_ASH_HELP=y | 1112 | CONFIG_ASH_HELP=y |
1113 | CONFIG_ASH_GETOPTS=y | 1113 | CONFIG_ASH_GETOPTS=y |
1114 | CONFIG_ASH_CMDCMD=y | 1114 | CONFIG_ASH_CMDCMD=y |
1115 | # CONFIG_ASH_NOCONSOLE is not set | 1115 | CONFIG_ASH_NOCONSOLE=y |
1116 | # CONFIG_CTTYHACK is not set | 1116 | # CONFIG_CTTYHACK is not set |
1117 | # CONFIG_HUSH is not set | 1117 | # CONFIG_HUSH is not set |
1118 | # CONFIG_HUSH_BASH_COMPAT is not set | 1118 | # CONFIG_HUSH_BASH_COMPAT is not set |
diff --git a/include/mingw.h b/include/mingw.h index 0f403b993..f8e833138 100644 --- a/include/mingw.h +++ b/include/mingw.h | |||
@@ -513,3 +513,4 @@ ULONGLONG CompatGetTickCount64(void); | |||
513 | 513 | ||
514 | ssize_t get_random_bytes(void *buf, ssize_t count); | 514 | ssize_t get_random_bytes(void *buf, ssize_t count); |
515 | int enumerate_links(const char *file, char *name); | 515 | int enumerate_links(const char *file, char *name); |
516 | void hide_console(void); | ||
diff --git a/shell/ash.c b/shell/ash.c index 0040fd3c8..89bd886d3 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -172,8 +172,7 @@ | |||
172 | //config: Enable support for the 'noconsole' option, which attempts to | 172 | //config: Enable support for the 'noconsole' option, which attempts to |
173 | //config: hide the console normally associated with a command line | 173 | //config: hide the console normally associated with a command line |
174 | //config: application. This may be useful when running a shell script | 174 | //config: application. This may be useful when running a shell script |
175 | //config: from a GUI application. Disable this if your platform doesn't | 175 | //config: from a GUI application. |
176 | //config: support the required APIs. | ||
177 | //config: | 176 | //config: |
178 | //config:endif # ash options | 177 | //config:endif # ash options |
179 | 178 | ||
@@ -14917,13 +14916,8 @@ int ash_main(int argc UNUSED_PARAM, char **argv) | |||
14917 | #endif | 14916 | #endif |
14918 | 14917 | ||
14919 | #if ENABLE_ASH_NOCONSOLE | 14918 | #if ENABLE_ASH_NOCONSOLE |
14920 | if ( noconsole ) { | 14919 | if (noconsole) |
14921 | DWORD dummy; | 14920 | hide_console(); |
14922 | |||
14923 | if ( GetConsoleProcessList(&dummy, 1) == 1 ) { | ||
14924 | ShowWindow(GetConsoleWindow(), SW_HIDE); | ||
14925 | } | ||
14926 | } | ||
14927 | #endif | 14921 | #endif |
14928 | 14922 | ||
14929 | if (login_sh) { | 14923 | if (login_sh) { |
diff --git a/win32/mingw.c b/win32/mingw.c index 03636a04b..5cfba22f7 100644 --- a/win32/mingw.c +++ b/win32/mingw.c | |||
@@ -1397,3 +1397,19 @@ int enumerate_links(const char *file, char *name) | |||
1397 | return 1; | 1397 | return 1; |
1398 | } | 1398 | } |
1399 | #endif | 1399 | #endif |
1400 | |||
1401 | #if ENABLE_ASH_NOCONSOLE | ||
1402 | void hide_console(void) | ||
1403 | { | ||
1404 | DWORD dummy; | ||
1405 | DECLARE_PROC_ADDR(DWORD, GetConsoleProcessList, LPDWORD, DWORD); | ||
1406 | DECLARE_PROC_ADDR(BOOL, ShowWindow, HWND, int); | ||
1407 | |||
1408 | if (INIT_PROC_ADDR(kernel32.dll, GetConsoleProcessList) && | ||
1409 | INIT_PROC_ADDR(user32.dll, ShowWindow)) { | ||
1410 | if (GetConsoleProcessList(&dummy, 1) == 1) { | ||
1411 | ShowWindow(GetConsoleWindow(), SW_HIDE); | ||
1412 | } | ||
1413 | } | ||
1414 | } | ||
1415 | #endif | ||