I am writing a program that will open a job object present in \BaseNamedObjects
namespace using OpenJobObjectA
. Below is snippet of code:
hJob = OpenJobObjectA(JOB_OBJECT_QUERY, FALSE, "\\BaseNamedObjects\\SAC10680");
if (hJob == NULL) {
fprintf(stderr, "Failed to open job object. Error code: %d\n", GetLastError());
return 1;
}
Now, even though the job object is present(which I verify using winobj) I am not able to open the object. And getting below error:
Failed to open job object. Error code: 161
I know error 161 means path is invalid. But that's not true!!
The code should open the job object.
According to the Doc:OpenJobObjectA function
The name can have a "Global" or "Local" prefix to explicitly open the object in the global or session namespace. The remainder of the name can contain any character except the backslash character ().
The driver creates a named event object in the global \BaseNamedObjects
object directory. To access a kernel-mode event from user-mode, use the name Global\\Xxx
.
I agree with RbMm, you should try to use Global\\SAC10680
.