I don't think you should use GetLastError (?e) to determine the result of CreateMutex. Instead of i.r0 ?e on the end, just use i.s. The rest of the code can stay the same as CreateMutex will return 0 (NULL) on failure.
Stu
Need Help with Set and Release Mutex!
38 posts
I think it should be "CreateMutexA(i 0, i 0, t "myMutex") i .r0 ?e".This doesn't work for me either
See: http://nsis.sourceforge.net/Allow_on...aller_instance
I don't think you should use GetLastError (?e) to determine the result of CreateMutex. Instead of i.r0 ?e on the end, just use .s. The rest of the code can stay the same as CreateMutex will return 0 (NULL) on failure.I used the following code to check out .s:
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") .s'But this time the CreateMutex results in nothing - not even a number. I tested it with MessageBox MB_OK $R0
Edit: Ah! What I found out is that I'm using the UAC library and because of this the program seems to start twice at the first time - I printed out the message of the return value of createMutex and it appears twice! It may not relate to this topic.
I'm going to ask my question in the related plugin topic, so if someone of you got an answer please answer in that topic
Sorry I meant i.s not .s.
Stu
Stu
Mutex Inheritance
Hi,
I'm trying to make the Mutex inheritable so that the child process (in this example notepad.exe) will keep it open even though the parent process has exited, here what I have so far:
System::Alloc 72
Pop $4
System::Call "*$4(i 72,n,i 1)" # Set bInheritHandle to true
System::Call 'Kernel32::CreateMutexA(i r4, i 0, t "Global\ProductName") i.r1?e'
System::Free $4
Pop $2
Detailprint $2
StrCmp $2 "0" 0 +2
ExecWait '"notepad.exe"'
But I keep getting error 998 (ERROR_NOACCESS) returned.
Can anybody help?
Hi,
I'm trying to make the Mutex inheritable so that the child process (in this example notepad.exe) will keep it open even though the parent process has exited, here what I have so far:
System::Alloc 72
Pop $4
System::Call "*$4(i 72,n,i 1)" # Set bInheritHandle to true
System::Call 'Kernel32::CreateMutexA(i r4, i 0, t "Global\ProductName") i.r1?e'
System::Free $4
Pop $2
Detailprint $2
StrCmp $2 "0" 0 +2
ExecWait '"notepad.exe"'
But I keep getting error 998 (ERROR_NOACCESS) returned.
Can anybody help?
sizeof(SECURITY_ATTRIBUTES) = 12 on a 32 bit system? Not sure where you got 72 from. Does it even create the mutex?
I see you are using the Global\ prefix, you might need to set lpSecurityDescriptor in SECURITY_ATTRIBUTES if you want other users to access the mutex.
Anyway, ExecWait calls CreateProcess with inherit = false so you need to call CreateProcess yourself with the system plugin...
I see you are using the Global\ prefix, you might need to set lpSecurityDescriptor in SECURITY_ATTRIBUTES if you want other users to access the mutex.
Anyway, ExecWait calls CreateProcess with inherit = false so you need to call CreateProcess yourself with the system plugin...
Thanks! It was the buffer size that was causing the issue, that and I was setting the size with i instead of l.
It works perfectly now across all sessions.
It works perfectly now across all sessions.
i was right, l is 64 bit but you got lucky and it flows over into the field where you just used n and it should probably be i0.
Try this:
System::Call "*(i 12,i 0,i 1)i.r4"
Try this:
System::Call "*(i 12,i 0,i 1)i.r4"
Thanks again! That works nicely with the second field set to 0.