系统权限
在win2000,VC6里面如何得到系统的各种权限,比如SE_SHUTDOWN_NAME等等,谢谢 问题点数:30、回复次数:4Top
1 楼kulala(边走边看)回复于 2001-12-02 17:09:21 得分 0
每个用户都拥有SE_SHUTDOWN_NAME权限的,只是处于disable状态;
http://www.chinawolf.com/~lu0/有一个斑竹写的例子程序《超越ADMIN》
Top
2 楼leepiaoping(回首乱山横)回复于 2001-12-02 17:16:15 得分 0
那该如何Enable 这些处于disable的系统权限呢
上面这个连接打不开:(Top
3 楼kulala(边走边看)回复于 2001-12-02 17:29:50 得分 30
在MSDN中用Privileges做索引你可以找到很多需要的东西。
这是MSDN上的一个例子:
The following example shows how to enable or disable a privilege in an access token. The example calls the LookupPrivilegeValue function to get the LUID that the local system uses to identify the privilege. Then the example calls the AdjustTokenPrivileges function, which either enables or disables the privilege that depends on the value of the bEnablePrivilege parameter.
BOOL SetPrivilege(
HANDLE hToken, // access token handle
LPCTSTR lpszPrivilege, // name of privilege to enable/disable
BOOL bEnablePrivilege // to enable or disable privilege
)
{
TOKEN_PRIVILEGES tp;
LUID luid;
if ( !LookupPrivilegeValue(
NULL, // lookup privilege on local system
lpszPrivilege, // privilege to lookup
&luid ) ) { // receives LUID of privilege
printf("LookupPrivilegeValue error: %u\n", GetLastError() );
return FALSE;
}
tp.PrivilegeCount = 1;
tp.Privileges[0].Luid = luid;
if (bEnablePrivilege)
tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
else
tp.Privileges[0].Attributes = 0;
// Enable the privilege or disable all privileges.
AdjustTokenPrivileges(
hToken,
FALSE,
&tp,
sizeof(TOKEN_PRIVILEGES),
(PTOKEN_PRIVILEGES) NULL,
(PDWORD) NULL);
// Call GetLastError to determine whether the function succeeded.
if (GetLastError() != ERROR_SUCCESS) {
printf("AdjustTokenPrivileges failed: %u\n", GetLastError() );
return FALSE;
}
return TRUE;
}
Top
4 楼leepiaoping(回首乱山横)回复于 2001-12-02 18:02:10 得分 0
Thank you!Top




