问题描述
我正在尝试在 cpp 中为 LOCAL_SYstem 创建安全描述符。参考代码 Creating a Security Descriptor
示例告诉如何为每个人和管理员创建 但我正在尝试创建 LOCAL_SYstem 但失败了。
SID_IDENTIFIER_AUTHORITY SIDLocalSystem = Security_LOCAL_SID_AUTHORITY;
Security_ATTRIBUTES sa;
HKEY hkSub = NULL;
HKEY hRegKey = NULL;
bool bRet = false;
// Create a well-kNown SID for the Everyone group.
if (!AllocateAndInitializeSid(&SIDAuthWorld,1,/*Security_WORLD_RID*/Security_LOCAL_SYstem_RID,&SIDLocalSystem))
{
WcaLog(LOGMSG_STANDARD,"AllocateAndInitializeSid Error %u",GetLastError());
goto exit;
}
// Initialize an EXPLICIT_ACCESS structure for an ACE.
// The ACE will allow Everyone read access to the key.
ZeroMemory(&ea,2 * sizeof(EXPLICIT_ACCESS));
ea[0].grfAccesspermissions = KEY_ALL_ACCESS;
ea[0].grfAccessMode = SET_ACCESS;
ea[0].grfInheritance = NO_INHERITANCE;
ea[0].Trustee.TrusteeForm = TRUSTEE_IS_SID;
ea[0].Trustee.TrusteeType = TRUSTEE_IS_USER;
ea[0].Trustee.ptstrName = (LPTSTR)SIDLocalSystem;
不知何故导致设置未知 SID
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)