summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--capinfos.c7
-rw-r--r--dumpcap.c3
-rw-r--r--editcap.c2
-rw-r--r--mergecap.c1
-rw-r--r--packaging/nsis/wireshark.nsi11
-rw-r--r--randpkt.c1
-rw-r--r--rawshark.c1
-rw-r--r--text2pcap.c1
-rw-r--r--tshark.c1
-rw-r--r--ui/gtk/main.c3
-rw-r--r--ui/qt/main.cpp1
-rw-r--r--wsutil/file_util.c7
-rw-r--r--wsutil/file_util.h7
-rw-r--r--wsutil/libwsutil.def1
14 files changed, 41 insertions, 6 deletions
diff --git a/capinfos.c b/capinfos.c
index 96d7de998a..246afb3443 100644
--- a/capinfos.c
+++ b/capinfos.c
@@ -155,7 +155,7 @@ static gboolean cap_file_hashes = TRUE; /* Calculate file hashes */
#ifdef USE_GOPTION
static gboolean cap_help = FALSE;
static gboolean table_report = FALSE;
-
+
static GOptionEntry general_entries[] =
{
/* General */
@@ -490,7 +490,7 @@ print_stats(const gchar *filename, capture_info *cf_info)
}
if (cap_packet_size) printf ("Average packet size: %.2f bytes\n", cf_info->packet_size);
if (cf_info->times_known) {
- if (cap_packet_rate)
+ if (cap_packet_rate)
print_value("Average packet rate: ", 2, " packets/sec", cf_info->packet_rate);
}
#ifdef HAVE_LIBGCRYPT
@@ -1022,6 +1022,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/*
@@ -1044,7 +1045,7 @@ main(int argc, char *argv[])
/* Process the options */
#ifdef USE_GOPTION
ctx = g_option_context_new(" <infile> ... - print information about capture file(s)");
- general_grp = g_option_group_new("gen", "General infos:",
+ general_grp = g_option_group_new("gen", "General infos:",
"Show general options", NULL, NULL);
size_grp = g_option_group_new("size", "Size infos:",
"Show size options", NULL, NULL);
diff --git a/dumpcap.c b/dumpcap.c
index d2dfecabee..c917b96d95 100644
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -4177,9 +4177,8 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
-#endif /* _WIN32 */
+ create_app_running_mutex();
-#ifdef _WIN32
/*
* Initialize our DLL search path. MUST be called before LoadLibrary
* or g_module_open.
diff --git a/editcap.c b/editcap.c
index 03ef746509..f1fdf7dcb5 100644
--- a/editcap.c
+++ b/editcap.c
@@ -65,6 +65,7 @@
#endif
#ifdef _WIN32
+#include <wsutil/file_util.h>
#include <wsutil/unicode-utils.h>
#include <process.h> /* getpid */
#ifdef HAVE_WINSOCK2_H
@@ -870,6 +871,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/*
diff --git a/mergecap.c b/mergecap.c
index 685b0da686..d42b858cde 100644
--- a/mergecap.c
+++ b/mergecap.c
@@ -223,6 +223,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/* Process the options first */
diff --git a/packaging/nsis/wireshark.nsi b/packaging/nsis/wireshark.nsi
index d432933e1b..d7d2f69609 100644
--- a/packaging/nsis/wireshark.nsi
+++ b/packaging/nsis/wireshark.nsi
@@ -210,6 +210,17 @@ Function .onInit
${EndIf}
!endif
+; See if Wireshark is running
+; http://nsis.sourceforge.net/Check_whether_your_application_is_running
+checkRunning:
+System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "${PROGRAM_NAME}-is-running-{9CA78EEA-EA4D-4490-9240-FC01FCEF464B}") i .R0'
+ IntCmp $R0 0 notRunning
+ System::Call 'kernel32::CloseHandle(i $R0)'
+ ; You'd better go catch it.
+ MessageBox MB_RETRYCANCEL|MB_ICONEXCLAMATION "${PROGRAM_NAME} or one is associated programs is running. Please close it first" /SD IDCANCEL IDRETRY checkRunning
+ Quit
+notRunning:
+
; Copied from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new
ReadRegStr $OLD_UNINSTALLER HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${PROGRAM_NAME}" \
diff --git a/randpkt.c b/randpkt.c
index caf50fd0ed..96d2b9ee97 100644
--- a/randpkt.c
+++ b/randpkt.c
@@ -512,6 +512,7 @@ main(int argc, char **argv)
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
while ((opt = getopt(argc, argv, "b:c:ht:")) != -1) {
diff --git a/rawshark.c b/rawshark.c
index 28275f23b8..79ba938736 100644
--- a/rawshark.c
+++ b/rawshark.c
@@ -472,6 +472,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/*
diff --git a/text2pcap.c b/text2pcap.c
index 29af045fa4..14bc419118 100644
--- a/text2pcap.c
+++ b/text2pcap.c
@@ -1369,6 +1369,7 @@ parse_options (int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/* Scan CLI parameters */
diff --git a/tshark.c b/tshark.c
index e1d3688474..c6a42782ee 100644
--- a/tshark.c
+++ b/tshark.c
@@ -950,6 +950,7 @@ main(int argc, char *argv[])
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#if !GLIB_CHECK_VERSION(2,31,0)
g_thread_init(NULL);
#endif
diff --git a/ui/gtk/main.c b/ui/gtk/main.c
index acc69e4ff1..313e52a2c0 100644
--- a/ui/gtk/main.c
+++ b/ui/gtk/main.c
@@ -2224,6 +2224,7 @@ main(int argc, char *argv[])
setlocale(LC_ALL, "");
#ifdef _WIN32
arg_list_utf_16to8(argc, argv);
+ create_app_running_mutex();
#endif /* _WIN32 */
/*
@@ -3217,7 +3218,7 @@ main(int argc, char *argv[])
#endif
software_update_init();
-
+
/* we'll enter the GTK loop now and hand the control over to GTK ... */
gtk_main();
/* ... back from GTK, we're going down now! */
diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp
index cb1dc3acb3..46533369c6 100644
--- a/ui/qt/main.cpp
+++ b/ui/qt/main.cpp
@@ -528,6 +528,7 @@ int main(int argc, char *argv[])
int status;
//initialize language !
+ create_app_running_mutex();
QString locale = QLocale::system().name();
diff --git a/wsutil/file_util.c b/wsutil/file_util.c
index c9186c423d..1efc7cc39c 100644
--- a/wsutil/file_util.c
+++ b/wsutil/file_util.c
@@ -614,3 +614,10 @@ getenv_utf8(const char *varname)
return envvar;
}
+
+/** Create or open a "Wireshark is running" mutex.
+ */
+#define WIRESHARK_IS_RUNNING_UUID "9CA78EEA-EA4D-4490-9240-FC01FCEF464B"
+void create_app_running_mutex() {
+ CreateMutex(NULL, FALSE, _T("Wireshark-is-running-{") _T(WIRESHARK_IS_RUNNING_UUID) _T("}"));
+}
diff --git a/wsutil/file_util.h b/wsutil/file_util.h
index 4710aa6a15..af5f94d996 100644
--- a/wsutil/file_util.h
+++ b/wsutil/file_util.h
@@ -113,6 +113,7 @@ gboolean ws_init_dll_search_path();
*/
void *ws_load_library(gchar *library_name);
+
/** Load a DLL using g_module_open.
* Only the system and program directories are searched.
*
@@ -127,6 +128,12 @@ GModule *ws_module_open(gchar *module_name, GModuleFlags flags);
*/
extern char *getenv_utf8(const char *varname);
+/** Create or open a "Wireshark is running" mutex.
+ * Create or open a mutex which signals that Wireshark or its associated
+ * executables is running. Used by the installer to test for a running application.
+ */
+extern void create_app_running_mutex();
+
#else /* _WIN32 */
/*
diff --git a/wsutil/libwsutil.def b/wsutil/libwsutil.def
index 49b9a39286..bc30c3ab36 100644
--- a/wsutil/libwsutil.def
+++ b/wsutil/libwsutil.def
@@ -52,6 +52,7 @@ crc32_mpeg2_seed
crc_drm
; file_util.c
+create_app_running_mutex
getenv_utf8
ws_stdio_fopen
ws_stdio_freopen