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
This commit is contained in:
parent
63093db8d2
commit
3ba2c108f1
|
@ -212,14 +212,28 @@ Function .onInit
|
|||
|
||||
; 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
|
||||
${Do}
|
||||
|
||||
System::Call 'kernel32::OpenMutex(i 0x100000, b 0, t "Global\${PROGRAM_NAME}-is-running-{9CA78EEA-EA4D-4490-9240-FC01FCEF464B}") i .R0'
|
||||
IntCmp $R0 0 checkRunningSession
|
||||
System::Call 'kernel32::CloseHandle(i $R0)'
|
||||
Goto isRunning
|
||||
|
||||
checkRunningSession:
|
||||
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)'
|
||||
|
||||
isRunning:
|
||||
; 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 continueChecking
|
||||
Quit
|
||||
|
||||
notRunning:
|
||||
${ExitDo}
|
||||
|
||||
continueChecking:
|
||||
${Loop}
|
||||
|
||||
; Copied from http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new
|
||||
ReadRegStr $OLD_UNINSTALLER HKLM \
|
||||
|
|
|
@ -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("}"));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue