首页
社区
课程
招聘
收藏
点赞0
打赏
分享
最新回复 (2)
雪    币: 3699
活跃值: (3713)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
Mxixihaha 2023-4-9 22:01
2
0
bool elevateProcessPrivilege()
{
    HANDLE hToken;
    TOKEN_PRIVILEGES tkp;

    // Get a token for this process.
    if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
        return false;

    // Get the LUID for the privilege we want to enable.
    if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &tkp.Privileges[0].Luid))
        return false;

    tkp.PrivilegeCount = 1;  // one privilege to set
    tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

    // Enable the privilege in the access token.
    if (!AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL))
        return false;

    if (GetLastError() == ERROR_NOT_ALL_ASSIGNED)
        return false;

    return true;
}


先调用这个提升自己的权限

雪    币: 243
活跃值: (3261)
能力值: ( LV3,RANK:20 )
在线值:
发帖
回帖
粉丝
wx_好一脚头球 2023-4-11 13:31
3
0
Mxixihaha bool elevateProcessPrivilege() {     HANDLE  ...
okok,谢谢
游客
登录 | 注册 方可回帖
返回