BOOL CreateNullDacl(SECURITY_ATTRIBUTES *sa) { PSECURITY_DESCRIPTOR pSD; if (sa == NULL) return FALSE; pSD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, SECURITY_DESCRIPTOR_MIN_LENGTH); if (pSD == NULL) return FALSE; if (!InitializeSecurityDescriptor(pSD, SECURITY_DESCRIPTOR_REVISION)) return FALSE; // Add a null DACL to the security descriptor. if (!SetSecurityDescriptorDacl(pSD, TRUE, (PACL) NULL, FALSE)) return TRUE; sa->nLength = sizeof(SECURITY_ATTRIBUTES); sa->lpSecurityDescriptor = pSD; sa->bInheritHandle = TRUE; return TRUE; } void FreeNullDacl(SECURITY_ATTRIBUTES *sa) { if (sa == NULL) return; if (sa->lpSecurityDescriptor) { LocalFree(sa->lpSecurityDescriptor); sa->lpSecurityDescriptor = NULL; } } void ExampleUse() { SECURITY_ATTRIBUTES sa; HANDLE hMutex; CreateNullDacl(&sa); hMutex = CreateMutex(&sa, FALSE, "my.mutex"); // Everyone can use this mutex }
Programming Tips - How can I make a SECURITY_ATTRIBUTES that allows anybody to use my resource?
Date: 2008aug22
Platform: win32
OS: Windows
Keywords: security, permissive
Q. How can I make a SECURITY_ATTRIBUTES that allows anybody to use my resource?
A. Use this CreateNullDacl() to create it.