C# 评测C++程序

最近想编一个C++评测软件,但不知道如何设置Process启动的程序的文件访问权限,曾经看过一个人写的,运用反射,把Process中的m_ProcessAccess改为0x0001(不知道有没有记错),就可以防止启动的线程调用或更改外部文件,但不懂什么意思,求大神帮忙!!! (在线等)

1个回答

看.net源代码

    [Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), MonitoringDescription(SR.ProcessHandle)]
    public IntPtr Handle {
        [ResourceExposure(ResourceScope.Machine)]
        [ResourceConsumption(ResourceScope.Machine)]
        get {
            EnsureState(State.Associated);
            return OpenProcessHandle(this.m_processAccess).DangerousGetHandle();
        }
    }

再查msdn的api函数定义
https://msdn.microsoft.com/en-us/library/windows/desktop/ms684320(v=vs.85).aspx

dwDesiredAccess [in]
The access to the process object. This access right is checked against the security descriptor for the process. This parameter can be one or more of the process access rights.
If the caller has enabled the SeDebugPrivilege privilege, the requested access is granted regardless of the contents of the security descriptor.

https://msdn.microsoft.com/en-us/library/windows/desktop/ms684880(v=vs.85).aspx
PROCESS_TERMINATE (0x0001)

0x0001使得对于这个handle只有终止进程的权限。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问