I'm currently attempting to expand this to allow me to access more of the possibilities with managing job objects. However, I'm running into issues whenever I try to set the JobMemoryLimit defined in the Limit objects.
I made a function that duplicates the set information logic in the JobObject constructor with some additional steps. First I set the additional flag
info.LimitFlags |= (uint)JobObjectLimitFlags.JOB_OBJECT_LIMIT_JOB_MEMORY;
And that alone is enough to break my code. When I call SetInformationJobObject it returns false and the job is not modified. My call to Marshal.GetLastWin32Error() returns the code for ERROR_BAD_LENGTH. Setting extendedInfo.JobMemoryLimit makes no difference.
I should note that in this example I am attempting to modify an existing Job, but I've tried it both ways. Plugging the above line into the JobObject constructor still results in a return of false from SetInformationJobObject, but now the error code is 0.
What does an ERROR_BAD_LENGTH mean in this case, and why is it triggered by changing my flags?