A forum for reverse engineering, OS internals and malware analysis 

Discussion on reverse-engineering and debugging.
 #11781  by Brock
 Fri Feb 24, 2012 5:41 am
ad13's idea of using a named mutex is most commonly used from what I have seen but there are definitely issues with this.

[1] NULL security attributes is typically ill-advised since it uses the default but I do understand it was a quick example however for the sake of brevity
[2] Since mutex is not created in the Global namespace, it will not be visible to other instances of the program in different sessions. Since Vista+ process session isolation has created many problems with this as well as XP+ Fast User Switching based on terminal services logic, same result since it's not globally created
[3] Creating a globally named object requires elevated rights and acquiring of SeCreateGlobalPrivilege beforehand
[4] EP is correct in pointing out the advisory about statically naming objects for comparison and exiting the program if it already exists. I think most of us would recommend name randomization based on some shared internal algorithm/logic at run-time or avoid named objects altogether