我是winapi的新手,我遇到了这段代码:
PSECURITY_DESCRIPTOR SD = NULL;
Int length = SECURITY_DESCRIPTOR_MIN_LENGTH;
SD = (PSECURITY_DESCRIPTOR) LocalAlloc(LPTR, length);
if (SD == NULL)
{
printf("Error! SD is null.\n");
}
if (InitializeSecurityDescriptor(SD,
SECURITY_DESCRIPTOR_REVISION) == FALSE)
{
printf("Error in InitializeSecurityDescriptor.\n");
}
if (SetSecurityDescriptorDacl(SD, TRUE, acl, FALSE) == FALSE)
{
printf("Error in SetSecurityDescriptorDacl.\n");
}
MSDN 网站告诉我,The minimum length of a security descriptor is SECURITY_DESCRIPTOR_MIN_LENGTH. A security descriptor of this length has no associated security identifiers (SIDs) or access control lists (ACLs).
但是当我测试这段代码时,它运行良好。我做了很少的研究,发现了关于安全描述符的 MSDN 示例,并且在那里也使用了这样的代码。我想我误解了一些东西,不应该使用SECURITY_DESCRIPTOR_MIN_LENGTH
然后添加 ACL 会导致错误吗?对不起,如果问题听起来很傻。