最近想编一个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).aspxdwDesiredAccess [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只有终止进程的权限。
解决 无用评论 打赏 举报