首页
社区
课程
招聘
[旧帖] [讨论]刚发现的一个问题,关于AdjustTokenPrivileges 0.00雪花
发表于: 2009-11-20 21:23 1747

[旧帖] [讨论]刚发现的一个问题,关于AdjustTokenPrivileges 0.00雪花

2009-11-20 21:23
1747
刚在学习AdjustTokenPrivileges
在msdn看到关于AdjustTokenPrivileges 返回值的这一段,觉的有点矛盾
第一句,如果函数成功,返回非0,下面些又有两个成功返回值描述ERROR_SUCCESS  和ERROR_NOT_ALL_ASSIGNED,而ERROR_SUCCESS 我看了一下刚还是0,有点困惑了,这到底是什么意思,请明白的各位能指点一下

Return Values
If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call GetLastError, which returns one of the following values when the function succeeds:

Value Description
ERROR_SUCCESS                      The function adjusted all specified privileges.
ERROR_NOT_ALL_ASSIGNED      The token does not have one or more of the privileges specified in the NewState parameter. The function may succeed with this error value even if no privileges were adjusted. The PreviousState parameter indicates the privileges that were adjusted.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 0
支持
分享
最新回复 (2)
雪    币: 71
活跃值: (10)
能力值: ( LV7,RANK:100 )
在线值:
发帖
回帖
粉丝
2
MSDN原文解释:
If the function succeeds, the return value is nonzero. To determine whether the function adjusted all of the specified privileges, call GetLastError, which returns one of the following values when the function succeeds:Return code Description
ERROR_SUCCESS The function adjusted all specified privileges.
ERROR_NOT_ALL_ASSIGNED The token does not have one or more of the privileges specified in the NewState parameter. The function may succeed with this error value even if no privileges were adjusted. The PreviousState parameter indicates the privileges that were adjusted.

If the function fails, the return value is zero. To get extended error information, call GetLastError.
正确理解:这个函数返回为BOOL,明显TRUE则执行成功,FALSE则执行失败。一般的GetLastError是用在函数执行失败后的,而这个函数貌似很特殊,它通过GetLastError将函数成功时的具体结果(1,更改了所有指定的权限;2,还有一个或者多个权限没有得到更改)反映给调用者了@
2009-11-20 22:50
0
雪    币: 169
活跃值: (25)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
谢谢,明白了,这个还真的是有点特别
2009-11-21 00:44
0
游客
登录 | 注册 方可回帖
返回
//