diff options
author | Ron Yorston <rmy@pobox.com> | 2020-06-02 07:53:10 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2020-06-02 08:27:46 +0100 |
commit | 27c718aa1a4674587925adb543362cb8e60814c4 (patch) | |
tree | db22579586cede7cb0f3351ce66c36f98a9a5a7a /loginutils | |
parent | 5ea460a32a9882906c7ee3656b8fb0dcdbce2abc (diff) | |
download | busybox-w32-27c718aa1a4674587925adb543362cb8e60814c4.tar.gz busybox-w32-27c718aa1a4674587925adb543362cb8e60814c4.tar.bz2 busybox-w32-27c718aa1a4674587925adb543362cb8e60814c4.zip |
win32: use lazy loading for certain DLLs
Only a handful of functions are used from shell32.dll, userenv.dll
and psapi.dll. Mostly these functions are in out of the way places.
By loading the functions only when required we can avoid the startup
cost of linking the three DLLs in the common case that they aren't
needed.
Diffstat (limited to 'loginutils')
-rw-r--r-- | loginutils/suw32.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/loginutils/suw32.c b/loginutils/suw32.c index de29f423a..3500c08db 100644 --- a/loginutils/suw32.c +++ b/loginutils/suw32.c | |||
@@ -22,6 +22,7 @@ | |||
22 | //usage: "\n -c CMD Command to pass to 'sh -c'" | 22 | //usage: "\n -c CMD Command to pass to 'sh -c'" |
23 | 23 | ||
24 | #include "libbb.h" | 24 | #include "libbb.h" |
25 | #include "lazyload.h" | ||
25 | 26 | ||
26 | int suw32_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 27 | int suw32_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
27 | int suw32_main(int argc UNUSED_PARAM, char **argv) | 28 | int suw32_main(int argc UNUSED_PARAM, char **argv) |
@@ -29,6 +30,7 @@ int suw32_main(int argc UNUSED_PARAM, char **argv) | |||
29 | char *opt_command = NULL; | 30 | char *opt_command = NULL; |
30 | SHELLEXECUTEINFO info; | 31 | SHELLEXECUTEINFO info; |
31 | char *bb_path, *cwd; | 32 | char *bb_path, *cwd; |
33 | DECLARE_PROC_ADDR(BOOL, ShellExecuteExA, SHELLEXECUTEINFOA *); | ||
32 | 34 | ||
33 | getopt32(argv, "c:", &opt_command); | 35 | getopt32(argv, "c:", &opt_command); |
34 | if (argv[optind]) | 36 | if (argv[optind]) |
@@ -63,5 +65,8 @@ int suw32_main(int argc UNUSED_PARAM, char **argv) | |||
63 | /* info.lpDirectory = NULL; */ | 65 | /* info.lpDirectory = NULL; */ |
64 | info.nShow = SW_SHOWNORMAL; | 66 | info.nShow = SW_SHOWNORMAL; |
65 | 67 | ||
66 | return !ShellExecuteEx(&info); | 68 | if (!INIT_PROC_ADDR(shell32.dll, ShellExecuteExA)) |
69 | return -1; | ||
70 | |||
71 | return !ShellExecuteExA(&info); | ||
67 | } | 72 | } |