It started with this question, followed up with this question and now led to the present one. :)
The task is as follows: make a Windows program that will run another program in a limited environment. The other program cannot be trusted, so it has to be ready for hackish code. More specifically:
Sleep()
infinitely.This will be needed for a computing olympiad support software. This program will run the participants submissions on the central server, so you can expect pretty much anything there. Crashes will be routine, and some hacking attempts can be expected too.
So - how would you go about making such a program? What would you use? In the previous topics (see above) it has become clear that attaching as a debugger is a bad idea, although perhaps I'm simply too clumsy.
You are pretty much building the same process model as IIS - fun! I would use the same tools that IIS uses, its relatively robust against hacking and its designed to partition your system up into many concurrent jobs.
You can use Win32 Jobs to set quotas for memory, cpu, threads and you can set up a security context for different processes to run in, thus limiting access to the file system.
For monitoring, I would look at WMI.
For stack trace when hanging or crashing, I have used ADPlus again from Microsoft.
For capturing console output, check out Creating a Child Process with Redirected Input Output.
Regarding security restrictions, create a low privilege user account and run the job / process as that user.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With