WIN API 用户权限 C++
我正在尝试查看用户是否具有 SeLoadDriver 权限。我已经获得了 PLUID :
PLUID pld;
LookupPrivilegeValue(NULL, SE_LOAD_DRIVER_NAME, pld);
但现在我不确定如何从 PLUID 中获取 bool 值来表明用户是否拥有该权限。我已经阅读了相关方法,但它认为这可能是直接从 PLUID 值获取此值的简单方法。
谢谢
I'm trying to see if the user has the SeLoadDriver privilege. I've got the PLUID :
PLUID pld;
LookupPrivilegeValue(NULL, SE_LOAD_DRIVER_NAME, pld);
But now i'm not sure how to get a bool from the PLUID stating that the user has, or not, the privilege. I've read the related methods but it think that it might be an easy way of getting this directly from the PLUID value.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
比这更复杂一些。
首先,您需要获取进程令牌的权限集(通过调用 GetTokenInformation()),然后扫描从中获得的缓冲区(这是一个
LUID_AND_ATTRIBUTES
数组)结构)获取从LookupPrivilegeValue()
获取的 LUID。然后,您可以使用您找到的LUID_AND_ATTRIBUTES
并检查Attributes
是否包含所需的标志(在您的情况下为SE_PRIVILEGE_ENABLED
)。请注意,当您检查启用的权限时,您还应该检查您正在检查的
Attributes
中是否未设置SE_PRIVILEGE_REMOVED
;同时具有SE_PRIVILEGE_REMOVED
和SE_PRIVILEGE_ENABLED
的权限已被删除且未启用...It's a little more involved than that.
First you need to obtain the process token's privilege set (by calling
GetTokenInformation()
) then you scan the buffer that you've got from that (which is an array ofLUID_AND_ATTRIBUTES
structures) for the LUID that you get fromLookupPrivilegeValue()
. You can then use theLUID_AND_ATTRIBUTES
that you've located and check to see if theAttributes
contain the required flag (SE_PRIVILEGE_ENABLED
in your case).Be aware that when you are checking for an enabled privilege you should also check that
SE_PRIVILEGE_REMOVED
is NOT set in theAttributes
that you are checking; a privilege that has bothSE_PRIVILEGE_REMOVED
andSE_PRIVILEGE_ENABLED
has been removed and is NOT enabled...