aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2013-02-20 19:58:55 +0000
committerGerald Combs <gerald@wireshark.org>2013-02-20 19:58:55 +0000
commit3ba2c108f13e513cab2b46566e35d2c3f0d24091 (patch)
tree0e23256fb51eaf523e80189f045ba59eb5725ac6 /wsutil
parent63093db8d213c36d9ba4928943c6a49ae10bc9f4 (diff)
As http://www.jrsoftware.org/iskb.php?mutexsessions points out, a session
mutex may not be visible to other sessions and we may not be able to create a global mutex. Try to create both, and make each one accessible to all users. Update the NSIS installer to check for both global and session mutexes. svn path=/trunk/; revision=47773
Diffstat (limited to 'wsutil')
-rw-r--r--wsutil/file_util.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/wsutil/file_util.c b/wsutil/file_util.c
index 1efc7cc39c..99721984b2 100644
--- a/wsutil/file_util.c
+++ b/wsutil/file_util.c
@@ -618,6 +618,28 @@ getenv_utf8(const char *varname)
/** Create or open a "Wireshark is running" mutex.
*/
#define WIRESHARK_IS_RUNNING_UUID "9CA78EEA-EA4D-4490-9240-FC01FCEF464B"
+
+static SECURITY_ATTRIBUTES *sec_attributes_;
+
void create_app_running_mutex() {
- CreateMutex(NULL, FALSE, _T("Wireshark-is-running-{") _T(WIRESHARK_IS_RUNNING_UUID) _T("}"));
+ SECURITY_ATTRIBUTES *sa = NULL;
+
+ if (!sec_attributes_) sec_attributes_ = g_new0(SECURITY_ATTRIBUTES, 1);
+
+ sec_attributes_->nLength = sizeof(SECURITY_ATTRIBUTES);
+ sec_attributes_->lpSecurityDescriptor = g_new0(SECURITY_DESCRIPTOR, 1);
+ sec_attributes_->bInheritHandle = TRUE;
+ if (InitializeSecurityDescriptor(sec_attributes_->lpSecurityDescriptor, SECURITY_DESCRIPTOR_REVISION)) {
+ if (SetSecurityDescriptorDacl(sec_attributes_->lpSecurityDescriptor, TRUE, NULL, FALSE)) {
+ sa = sec_attributes_;
+ }
+ }
+
+ if (!sa) {
+ g_free(sec_attributes_->lpSecurityDescriptor);
+ g_free(sec_attributes_);
+ sec_attributes_ = NULL;
+ }
+ CreateMutex(sa, FALSE, _T("Wireshark-is-running-{") _T(WIRESHARK_IS_RUNNING_UUID) _T("}"));
+ CreateMutex(sa, FALSE, _T("Global\\Wireshark-is-running-{") _T(WIRESHARK_IS_RUNNING_UUID) _T("}"));
}