LvR 2016-09-09 05:49 采纳率: 0%
浏览 1298

C# 评测C++程序

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

  • 写回答

1条回答 默认 最新

  • threenewbee 2016-09-09 15:14
    关注

    看.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只有终止进程的权限。

    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用