金币699
积分1348
注册时间2017-8-13
最后登录2023-10-25
|
参考 |
- //
- // SetPrivilege enables/disables process token privilege.
- //
- BOOL SetPrivilege(HANDLE hToken, LPCTSTR lpszPrivilege, BOOL bEnablePrivilege)
- {
- LUID luid;
- BOOL bRet=FALSE;
- if (LookupPrivilegeValue(NULL, lpszPrivilege, &luid))
- {
- TOKEN_PRIVILEGE tp;
- tp.PrivilegeCount=1;
- tp.Privileges[0].Luid=luid;
- tp.Privileges[0].Attributes=(bEnablePrivilege) ? SE_PRIVILEGE_ENABLED: 0;
- //
- // Enable the privilege or disable all privileges.
- //
- if (AdjustTokenPrivileges(hToken, FALSE, &tp, NULL, (PTOKEN_PRIVILEGES)NULL, (PDWORD)NULL))
- {
- //
- // Check to see if you have proper access.
- // You may get "ERROR_NOT_ALL_ASSIGNED".
- //
- bRet=(GetLastError() == ERROR_SUCCESS);
- }
- }
- return bRet;
- }
复制代码
| 源 |
Debug.7z
(12.85 KB, 下载次数: 18)
|
|
|