About the Vista Mutex Object

My OS is Vista with UAC enabled, I create a global Mutex object on the server side, then my UI hotspot wants to use CreateMutex with the same name to get the Mutex object that was created on the server, but the function says I am not allowed to access it. How can i do this?

0


a source to share


1 answer


I think in your case, you need to explicitly allow all access to your mutex by initializing the appropriate security attributes.

Try creating a mutex this way (think of it as semi-pseudocode):

SECURITY_ATTRIBUTES sa;
SECURITY_DESCRIPTOR sd;
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
sa.nLength = sizeof(sa);
sa.lpSecurityDescriptor = &sd;
CreateMutex(&sa, ...);

      



And by the way, it's good to use CreateMutex to open an existing mutex . But OpenMutex allows you to specify the required access level.

Also note that if you want a truly global mutex - you will need to prefix its name with "Global" (see the MSDN article "Nuclear Namespaces")

+5


a source







All Articles