小编Vla*_*sky的帖子

模拟后 CreateMutex 失败

这是我尝试模拟用户然后创建互斥体的代码。未创建互斥体。我收到 ERROR_ACCESS_DENIED 错误。

void Impersonate()
{
    DWORD logonType = LOGON32_LOGON_INTERACTIVE;
    DWORD logonProvider = LOGON32_PROVIDER_DEFAULT;
    HANDLE userToken;
    HANDLE hMutex;
    DWORD err;

    LPSTR user = "zoom"; // the user I created myself on my machine. 
    // It has Administrator privileges, and my account, 
    // from which I start the app, is Admin too
    LPSTR password = "zoom";
    LPSTR domain = ".";
    hMutex = NULL;

    LogonUserA(user, domain, password, logonType, logonProvider,&userToken);

    // just to make sure that mutexes are created fine before impersonation
    hMutex …
Run Code Online (Sandbox Code Playgroud)

c++ windows impersonation mutex

4
推荐指数
1
解决办法
1264
查看次数

标签 统计

c++ ×1

impersonation ×1

mutex ×1

windows ×1