Home > Software engineering >  Windows job found abnormal when using SetInformationJobObject restrict permissions UI
Windows job found abnormal when using SetInformationJobObject restrict permissions UI

Time:11-14

//create a job kernel object 
HANDLE hJob=CreateJobObject (NULL, NULL);//
//for homework to add some basic restrictions

//basic limit structure
JOBOBJECT_BASIC_LIMIT_INFORMATION jobli={0};

//assignment priority
Jobli. PriorityClass=NORMAL_PRIORITY_CLASS;//

//assignments of CPU time limit
//jobli. PerJobUserTimeLimit. QuadPart=10000000;//1 seconds, the unit is 100 nanoseconds

//specify constraints
Jobli. LimitFlags=JOB_OBJECT_LIMIT_PRIORITY_CLASS | JOB_OBJECT_LIMIT_JOB_TIME;

//limit set homework
SetInformationJobObject (hJob, JobObjectBasicLimitInformation, & amp; Jobli, sizeof (jobli));

////////////////////////////////////////////////////////////
//for homework to add some basic UI limit

//basic UI limit structure
JOBOBJECT_BASIC_UI_RESTRICTIONS jobuir;

//initial unlimited
Jobuir. UIRestrictionsClass=JOB_OBJECT_UILIMIT_NONE;//

Increased restrictions://assignment (processes) can't cancel the operating system
//jobuir UIRestrictionsClass |=JOB_OBJECT_UILIMIT_EXITWINDOWS;


//jobuir UIRestrictionsClass |=JOB_OBJECT_UILIMIT_SYSTEMPARAMETERS;
Increased restrictions://assignment (processes) can't access the system user objects (such as other Windows)
//jobuir UIRestrictionsClass |=JOB_OBJECT_UILIMIT_HANDLES;

//jobuir UIRestrictionsClass |=JOB_OBJECT_UILIMIT_READCLIPBOARD;//banned process reads the clipboard content
//limit set homework
SetInformationJobObject (hJob, JobObjectBasicUIRestrictions, & amp; Jobuir, sizeof (jobuir));

////////////////////////////////////////////////////////////
//create the process, and added to the job, the initialization process must be in a pending state, ensure before added to the homework will not perform any code

//create the process
STARTUPINFO si={sizeof (si)};
PROCESS_INFORMATION PI;
TCHAR sz []=TEXT (" C: \ \ Program Files \ \ (x86) Google \ \ Chrome \ \ Application \ \ Chrome exe ");
CreateProcess (NULL, sz, NULL, NULL,
FALSE, the CREATE_SUSPENDED, NULL, NULL, & amp; Si, & amp; PI);
//wake up the process (the main thread)
ResumeThread (PI) hThread);

//close the handle
The CloseHandle (PI. HThread);


In the way SetInformationJobObject (hJob, JobObjectBasicUIRestrictions, & amp; Jobuir, sizeof (jobuir));
Even in JobObjectBasicUIRestrictions add no limits, just will jobuir. UIRestrictionsClass set to JOB_OBJECT_UILIMIT_NONE;
Abnormal, start the browser will be unable to access the website, and do not set permissions UI, so open the browser can normal use, have know can set permissions UI
And can launch a browser normal way? Please answer

CodePudding user response:

SetInformationJobObject (hJob, JobObjectBasicUIRestrictions, & amp; Jobuir, sizeof (jobuir)), start the browser, can be normal use

CodePudding user response:

No one reply us,,,
  • Related