21.03.2013 Views

Problem - Kevin Tafuro

Problem - Kevin Tafuro

Problem - Kevin Tafuro

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Note that the structures as presented here are incomplete. Each one contains several<br />

other members that are of no interest to us in this recipe. In the JOBOBJECT_BASIC_<br />

LIMIT_INFORMATION structure, the LimitFlags member is treated as a set of flags that<br />

control which other structure members are used by SetInformationJobObject( ). The<br />

flags that can be set for LimitFlags that are of interest within the context of this recipe<br />

are:<br />

JOB_OBJECT_LIMIT_ACTIVE_PROCESS<br />

Sets the ActiveProcessLimit member in the JOBOBJECT_BASIC_LIMIT_INFORMATION<br />

structure to the number of processes to be allowed in the job object.<br />

JOB_OBJECT_LIMIT_JOB_TIME<br />

Sets the PerJobUserTimeLimit member in the JOBOBJECT_BASIC_LIMIT_INFORMATION<br />

structure to the combined amount of time all processes in the job may spend<br />

executing in user space. In other words, the time each process in the job spends<br />

executing in user space is totaled, and any process that causes this limit to be<br />

exceeded will be terminated. The limit is specified in units of 100 nanoseconds.<br />

JOB_OBJECT_LIMIT_PROCESS_TIME<br />

Sets the PerProcessUserTimeLimit member in the JOBOBJECT_BASIC_LIMIT_<br />

INFORMATION structure to the amount of time a process in the job may spend executing<br />

in user space. When a process exceeds the limit, it will be terminated. The<br />

limit is specified in units of 100 nanoseconds.<br />

JOB_OBJECT_LIMIT_JOB_MEMORY<br />

Sets the JobMemoryLimit member in the JOBOBJECT_EXTENDED_LIMIT_INFORMATION<br />

structure to the maximum amount of memory that all processes in the job may<br />

commit. When the combined total of committed memory of all processes in the<br />

job exceeds this limit, processes will be terminated as they attempt to commit<br />

more memory. The limit is specified in units of bytes.<br />

JOB_OBJECT_LIMIT_PROCESS_MEMORY<br />

Sets the ProcessMemoryLimit member in the JOBOBJECT_EXTENDED_LIMIT_<br />

INFORMATION structure to the maximum amount of memory that a process in the<br />

job may commit. When a process attempts to commit memory exceeding this<br />

limit, it will be terminated. The limit is specified in units of bytes.<br />

Once a job object has been created and restrictions have been placed on it, processes<br />

can be assigned to the job by calling AssignProcessToJobObject( ), which has the following<br />

signature:<br />

BOOL AssignProcessToJobObject(HANDLE hJob, HANDLE hProcess);<br />

This function has the following arguments:<br />

hJob<br />

Handle to the job object to assign the process.<br />

hProcess<br />

Handle of the process to be assigned.<br />

Guarding Against Resource Starvation Attacks on Windows | 733<br />

This is the Title of the Book, eMatter Edition<br />

Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!