小编Oll*_*hak的帖子

设置类似 chromium 的沙箱(错误 0xc00000a5)

我正在尝试设置一个类似于chromium 的沙箱。特别是,我试图复制他们的技巧,即使用低权限令牌创建睡眠进程,然后在运行之前临时设置高权限令牌。这个想法是让进程在高权限模式下完成所有初始化,然后在运行任何不安全代码之前恢复到低权限令牌。

到目前为止,我正在努力进行基本测试并运行。这是我的代码:

#include "stdafx.h"
#include <atlbase.h>
#include <iostream>
#include <cassert>
#include <vector>
#include <string>
#include <AccCtrl.h>
#include <aclapi.h>

#define VERIFY(x) { bool r = x; assert(r); }

uint8_t* GetTokenInfo(const HANDLE& token, TOKEN_INFORMATION_CLASS info_class, DWORD* error)
{
    // Get the required buffer size.
    DWORD size = 0;
    ::GetTokenInformation(token, info_class, NULL, 0, &size);
    if (!size)
    {
        *error = ::GetLastError();
        return nullptr;
    }

    uint8_t* buffer = new uint8_t[size];
    if (!::GetTokenInformation(token, info_class, buffer, size, &size))
    {
        *error = ::GetLastError();
        return nullptr; …
Run Code Online (Sandbox Code Playgroud)

c++ windows security sandbox

5
推荐指数
1
解决办法
307
查看次数

标签 统计

c++ ×1

sandbox ×1

security ×1

windows ×1