文件名称:JobObject
介绍说明--下载内容均来自于网络,请自行研究使用
通过windows的内核对象JobObject实现对程序的运行时间和内存使用的控制,开发初衷是作为一个简陋的acm判题沙箱.
大致步骤:
1.通过CreateJobObject创建一个工作对象
2.通过SetInformationJobObject设置工作对象的参数,详见MSDN(http://msdn.microsoft.com/zh-cn/library/ms686216)
3.以CREATE_SUSPENDED方式启动进程,通过CreateProcessAsUser或者CreateProcess函数,可能还有其他函数,未做研究.
4.通过AssignProcessToJobObject将工作对象应用到指定进程中.
5.通过ResumeThread恢复已暂停的进程.
6.通过WaitForSingleObject等待正在运行的工作对象,设置好允许使用时间.
7.通过QueryInformationJobObject获取工作对象的最终状态.运行程序的退出状态可以通过GetExitCodeProcess获取.
8.扫尾工作(必须使用TerminateJobObject结束当前的工作对象,因为工作对象即便设置了PerProcessUserTimeLimit也无法使程序在超时后退出,没有研究原因).
编译时请包含Kernel32.lib.-By the windows kernel objects JobObject control program run time and memory usage, originally developed as a rudimentary the acm sentenced Title sandbox. Roughly steps: 1. Through CreateJobObject create a work object 2. Through SetInformationJobObject set object parameters, see the MSDN (http://msdn.microsoft.com/zh-cn/library/ms686216) start the process to CREATE_SUSPENDED way through CreateProcessAsUser or CreateProcess function, may have other functions, without making research. by AssignProcessToJobObject work object applied to the specified process. 5. through ResumeThread recovery process has been suspended. 6. WaitForSingleObject to wait for running work object, set up to allow the use of time. through QueryInformationJobObject get the final state of the work objects run the program exit the state by GetExitCodeProcess get off the work (must use TerminateJobObject the end of the current work object, because the work object even set PerProcessUserTimeLimit can not make the prog
大致步骤:
1.通过CreateJobObject创建一个工作对象
2.通过SetInformationJobObject设置工作对象的参数,详见MSDN(http://msdn.microsoft.com/zh-cn/library/ms686216)
3.以CREATE_SUSPENDED方式启动进程,通过CreateProcessAsUser或者CreateProcess函数,可能还有其他函数,未做研究.
4.通过AssignProcessToJobObject将工作对象应用到指定进程中.
5.通过ResumeThread恢复已暂停的进程.
6.通过WaitForSingleObject等待正在运行的工作对象,设置好允许使用时间.
7.通过QueryInformationJobObject获取工作对象的最终状态.运行程序的退出状态可以通过GetExitCodeProcess获取.
8.扫尾工作(必须使用TerminateJobObject结束当前的工作对象,因为工作对象即便设置了PerProcessUserTimeLimit也无法使程序在超时后退出,没有研究原因).
编译时请包含Kernel32.lib.-By the windows kernel objects JobObject control program run time and memory usage, originally developed as a rudimentary the acm sentenced Title sandbox. Roughly steps: 1. Through CreateJobObject create a work object 2. Through SetInformationJobObject set object parameters, see the MSDN (http://msdn.microsoft.com/zh-cn/library/ms686216) start the process to CREATE_SUSPENDED way through CreateProcessAsUser or CreateProcess function, may have other functions, without making research. by AssignProcessToJobObject work object applied to the specified process. 5. through ResumeThread recovery process has been suspended. 6. WaitForSingleObject to wait for running work object, set up to allow the use of time. through QueryInformationJobObject get the final state of the work objects run the program exit the state by GetExitCodeProcess get off the work (must use TerminateJobObject the end of the current work object, because the work object even set PerProcessUserTimeLimit can not make the prog
(系统自动生成,下载前可以参看下载内容)
下载文件列表
main.cpp