diff options
-rw-r--r-- | CMakeLists.txt | 29 | ||||
-rw-r--r-- | Makefile.nmake | 14 | ||||
-rw-r--r-- | extcap.c | 24 | ||||
-rwxr-xr-x | packaging/nsis/uninstall.nsi | 1 | ||||
-rw-r--r-- | packaging/nsis/wireshark.nsi | 4 | ||||
-rw-r--r-- | packaging/portableapps/Makefile.nmake | 1 | ||||
-rw-r--r-- | ui/qt/Wireshark.pro | 13 |
7 files changed, 48 insertions, 38 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ac850c136..cd3a360079 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1765,6 +1765,25 @@ macro(set_extra_executable_properties _executable _folder) endif() endmacro() +macro(set_extcap_executable_properties _executable) + set_target_properties(androiddump PROPERTIES FOLDER "Executables/Extcaps") + + set(PROGLIST ${PROGLIST} ${_executable}) + + if(WIN32) + set_target_properties(${_executable} PROPERTIES + LINK_FLAGS "${WS_LINK_FLAGS} /SUBSYSTEM:WINDOWS" + RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap + RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/run/Debug/extcap + RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/run/Release/extcap + RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${CMAKE_BINARY_DIR}/run/MinSizeRel/extcap + RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${CMAKE_BINARY_DIR}/run/RelWithDebInfo/extcap + ) + else() + set_target_properties(${_executable} PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") + endif() +endmacro() + if(BUILD_wireshark_gtk AND GTK_FOUND) set(wireshark_gtk_LIBS gtkui @@ -2172,19 +2191,11 @@ if(BUILD_androiddump) extcap/androiddump.c ) - set(COPY_CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/extcap) add_executable(androiddump ${androiddump_FILES}) add_dependencies(androiddump gitversion) - if(WIN32) - set_target_properties(androiddump PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS} /SUBSYSTEM:WINDOWS") - else() - set_target_properties(androiddump PROPERTIES LINK_FLAGS "${WS_LINK_FLAGS}") - endif() - set_target_properties(androiddump PROPERTIES FOLDER "Executables/Extcaps") + set_extcap_executable_properties(androiddump) target_link_libraries(androiddump ${androiddump_LIBS}) install(TARGETS androiddump RUNTIME DESTINATION ${EXTCAP_DIR}) - set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${COPY_CMAKE_RUNTIME_OUTPUT_DIRECTORY}) endif() ADD_CUSTOM_COMMAND( diff --git a/Makefile.nmake b/Makefile.nmake index 92581610f7..61783949d7 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1227,17 +1227,9 @@ install-generated-files: doc if not exist $(INSTALL_DIR)\extcap mkdir $(INSTALL_DIR)\extcap if exist androiddump.exe xcopy androiddump.exe $(INSTALL_DIR)\extcap /d if exist androiddump.pdb xcopy androiddump.pdb $(INSTALL_DIR)\extcap /d - xcopy ".\wiretap\wiretap-$(WTAP_VERSION).dll" $(INSTALL_DIR)\extcap /d - xcopy ".\wsutil\libwsutil.dll" $(INSTALL_DIR)\extcap /d - xcopy $(GTK_DIR)\bin\libglib-2.0-0.dll $(INSTALL_DIR)\extcap /d - xcopy $(GTK_DIR)\bin\libgmodule-2.0-0.dll $(INSTALL_DIR)\extcap /d - xcopy $(ZLIB_DIR)\zlib1.dll $(INSTALL_DIR)\extcap /d - xcopy $(GTK_DIR)\bin\$(INTL_DLL) $(INSTALL_DIR)\extcap /d -!IFDEF GNUTLS_DIR - xcopy $(GNUTLS_DIR)\bin\$(GCC_DLL) $(INSTALL_DIR)\extcap /d - xcopy $(GNUTLS_DIR)\bin\libgcrypt-20.dll $(INSTALL_DIR)\extcap /d - xcopy $(GNUTLS_DIR)\bin\$(GPGERROR_DLL) $(INSTALL_DIR)\extcap /d -!ENDIF + if not exist $(INSTALL_DIR_QT)\extcap mkdir $(INSTALL_DIR_QT)\extcap + if exist androiddump.exe xcopy androiddump.exe $(INSTALL_DIR_QT)\extcap /d + if exist androiddump.pdb xcopy androiddump.pdb $(INSTALL_DIR_QT)\extcap /d if exist capinfos.exe xcopy capinfos.exe $(INSTALL_DIR) /d if exist capinfos.pdb xcopy capinfos.pdb $(INSTALL_DIR) /d if exist captype.exe xcopy captype.exe $(INSTALL_DIR) /d @@ -139,11 +139,28 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb, const gchar *file; gboolean keep_going; gchar **argv; +#ifdef WIN32 + gchar **dll_search_envp; + gchar *progfile_dir; +#endif keep_going = TRUE; argv = (gchar **) g_malloc0(sizeof(gchar *) * (argc + 2)); +#ifdef WIN32 + /* + * Make sure executables can find dependent DLLs and that they're *our* + * DLLs: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682586.aspx + * Alternatively we could create a simple wrapper exe similar to Create + * Hidden Process (http://www.commandline.co.uk/chp/). + */ + dll_search_envp = g_get_environ(); + progfile_dir = g_strdup_printf("%s;%s", get_progfile_dir(), g_environ_getenv(dll_search_envp, "Path")); + dll_search_envp = g_environ_setenv(dll_search_envp, "Path", progfile_dir, TRUE); + g_free(progfile_dir); +#endif + if ((dir = g_dir_open(dirname, 0, NULL)) != NULL) { #ifdef WIN32 dirname = g_strescape(dirname,NULL); @@ -156,12 +173,14 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb, gint i; gint exit_status = 0; GError *error = NULL; + gchar **envp = NULL; /* full path to extcap binary */ extcap_string = g_string_new(""); #ifdef WIN32 g_string_printf(extcap_string, "%s\\\\%s",dirname,file); extcap = g_string_free(extcap_string, FALSE); + envp = dll_search_envp; #else g_string_printf(extcap_string, "%s/%s", dirname, file); extcap = g_string_free(extcap_string, FALSE); @@ -174,7 +193,7 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb, argv[i+1] = args[i]; argv[argc+1] = NULL; - status = g_spawn_sync(dirname, argv, NULL, + status = g_spawn_sync(dirname, argv, envp, (GSpawnFlags) 0, NULL, NULL, &command_output, NULL, &exit_status, &error); @@ -188,6 +207,9 @@ static void extcap_foreach(gint argc, gchar **args, extcap_cb_t cb, g_dir_close(dir); } +#ifdef WIN32 + g_strfreev(dll_search_envp); +#endif g_free(argv); } diff --git a/packaging/nsis/uninstall.nsi b/packaging/nsis/uninstall.nsi index 1af6aaa495..739c7571d8 100755 --- a/packaging/nsis/uninstall.nsi +++ b/packaging/nsis/uninstall.nsi @@ -147,7 +147,6 @@ Delete "$INSTDIR\etc\gtk-2.0\*.*" Delete "$INSTDIR\etc\gtk-3.0\*.*" Delete "$INSTDIR\etc\pango\*.*" Delete "$INSTDIR\extcap\androiddump.*" -Delete "$INSTDIR\extcap\*.dll" Delete "$INSTDIR\help\*.*" Delete "$INSTDIR\iconengines\*.*" Delete "$INSTDIR\imageformats\*.*" diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi index 4af80f7b58..09e20b5ff8 100644 --- a/packaging/nsis/wireshark.nsi +++ b/packaging/nsis/wireshark.nsi @@ -987,10 +987,10 @@ SectionEnd Section /o "Androiddump" SecAndroiddumpinfos ;------------------------------------------- -SetOutPath $INSTDIR\extcap +SetOutPath $INSTDIR File "${STAGING_DIR}\androiddump.html" +SetOutPath $INSTDIR\extcap File "${STAGING_DIR}\extcap\androiddump.exe" -File "${STAGING_DIR}\extcap\*.dll" SectionEnd SectionGroupEnd ; "Tools" diff --git a/packaging/portableapps/Makefile.nmake b/packaging/portableapps/Makefile.nmake index 6a25f928d0..5ffaeb954e 100644 --- a/packaging/portableapps/Makefile.nmake +++ b/packaging/portableapps/Makefile.nmake @@ -62,7 +62,6 @@ dirs: #!IFDEF UPX # -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\[a-z]*.exe # -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\*.dll -# -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\extcap\*.dll # -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\plugins\$(VERSION)\*.dll # -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\lib\gtk-2.0\$(GTK_LIB_DIR)\loaders\*.dll # -$(UPX) $(UPX_FLAGS) $(FILES)\$(APP)\$(WIRESHARK)\lib\gtk-2.0\$(GTK_LIB_DIR)\immodules\*.dll diff --git a/ui/qt/Wireshark.pro b/ui/qt/Wireshark.pro index 5972a9a11e..5ac94cdf1c 100644 --- a/ui/qt/Wireshark.pro +++ b/ui/qt/Wireshark.pro @@ -493,19 +493,6 @@ win32 { QMAKE_POST_LINK +=$$quote($(CHK_DIR_EXISTS) $${PLUGINS_DIR} $(MKDIR) $${PLUGINS_DIR}$$escape_expand(\\n\\t)) QMAKE_POST_LINK +=$$quote($(COPY_FILE) ..\\..\\$${INSTALL_DIR}\\plugins\\*.dll $(DESTDIR)plugins$$escape_expand(\\n\\t)) - EXTCAP_DIR = $(DESTDIR)extcap - QMAKE_POST_LINK +=$$quote($(CHK_DIR_EXISTS) $${EXTCAP_DIR} $(MKDIR) $${EXTCAP_DIR}$$escape_expand(\\n\\t)) - EXTRA_EXTCAP_BINFILES = \ - ../../androiddump.exe ../../wiretap/wiretap-$${WTAP_VERSION}.dll ../../wsutil/libwsutil.dll \ - $${GLIB_DIR}/bin/libglib-2.0-0.dll $${GLIB_DIR}/bin/libgmodule-2.0-0.dll \ - $${GLIB_DIR}/bin/$${INTL_DLL} $${ZLIB_DIR}/zlib1.dll \ - $${GNUTLS_DIR}/bin/$${GCC_DLL} $${GNUTLS_DIR}/bin/libgcrypt-20.dll \ - $${GNUTLS_DIR}/bin/$${GPGERROR_DLL} - EXTRA_EXTCAP_BINFILES ~= s,/,\\,g - for(FILE,EXTRA_EXTCAP_BINFILES){ - QMAKE_POST_LINK +=$$quote($(COPY_FILE) $${FILE} $(DESTDIR)extcap$$escape_expand(\\n\\t)) - } - # This doesn't depend on wireshark-gtk2. It also doesn't work. #PLUGINS_IN_PWD=$${IN_PWD} #PLUGINS_OUT_PWD=$${OUT_PWD} |