Initialize Security attributes for CreateJobObject()
Posted on 2003-10-27
Unfortunately, I've never gotten a chance to pass a non-NULL value to a LPSECURITY_ATTRIBUTES before.
And now, when I tried I'm doomed. Well, let me explain what I'm trying to do.
I create a Job object with CreateJobObject(). Then I try to assign a process handle to it using AssignProcessToJobObject().
This is what I tried.
1) Called OpenProcess() on my target processID with following access rights.
Success !! I got the handle.
2) Called CreateJobObject(NULL, NULL).
Wow! I got a job handle with default rigths.
3) I called AssignProcessToJobObject() with the above 2 handles
Duh!! Error 5, Access Denied !!!
The error here could be because of the access rights of the Process object OR the Job Object.
I dont think the process object is the bad guy because I specify all the required flags to perform the Assign operation.
So, I believe my Job handle doesnot come with JOB_OBJECT_ASSIGN_PROCESS right, which I thought a part of default rights.
In brief, my question is : How to Initialize a SECURITY_ATTRIBUTES with JOB_OBJECT_ASSIGN_PROCESS rights, which I can pass to CreateJobObject(), or how to setup SECURITY_ATTRIBUTES structure in general for a given access right.
I tried searching Google for CreateJobObject JOB_OBJECT_ASSIGN_PROCESS and and all I'm finding is MSDN library entry for CreateJobObject in English and Japanese :)
I'd be glad if you could provide me with some code snippets.
Please dont give me MSDN links again..