Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
michael@0 | 2 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 3 | // found in the LICENSE file. |
michael@0 | 4 | |
michael@0 | 5 | #ifndef SANDBOX_SRC_JOB_H_ |
michael@0 | 6 | #define SANDBOX_SRC_JOB_H_ |
michael@0 | 7 | |
michael@0 | 8 | #include "base/basictypes.h" |
michael@0 | 9 | #include "sandbox/win/src/restricted_token_utils.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace sandbox { |
michael@0 | 12 | |
michael@0 | 13 | // Handles the creation of job objects based on a security profile. |
michael@0 | 14 | // Sample usage: |
michael@0 | 15 | // Job job; |
michael@0 | 16 | // job.Init(JOB_LOCKDOWN, NULL); //no job name |
michael@0 | 17 | // job.AssignProcessToJob(process_handle); |
michael@0 | 18 | class Job { |
michael@0 | 19 | public: |
michael@0 | 20 | Job() : job_handle_(NULL) { } |
michael@0 | 21 | |
michael@0 | 22 | ~Job(); |
michael@0 | 23 | |
michael@0 | 24 | // Initializes and creates the job object. The security of the job is based |
michael@0 | 25 | // on the security_level parameter. |
michael@0 | 26 | // job_name can be NULL if the job is unnamed. |
michael@0 | 27 | // If the chosen profile has too many ui restrictions, you can disable some |
michael@0 | 28 | // by specifying them in the ui_exceptions parameters. |
michael@0 | 29 | // If the function succeeds, the return value is ERROR_SUCCESS. If the |
michael@0 | 30 | // function fails, the return value is the win32 error code corresponding to |
michael@0 | 31 | // the error. |
michael@0 | 32 | DWORD Init(JobLevel security_level, wchar_t *job_name, DWORD ui_exceptions); |
michael@0 | 33 | |
michael@0 | 34 | // Assigns the process referenced by process_handle to the job. |
michael@0 | 35 | // If the function succeeds, the return value is ERROR_SUCCESS. If the |
michael@0 | 36 | // function fails, the return value is the win32 error code corresponding to |
michael@0 | 37 | // the error. |
michael@0 | 38 | DWORD AssignProcessToJob(HANDLE process_handle); |
michael@0 | 39 | |
michael@0 | 40 | // Grants access to "handle" to the job. All processes in the job can |
michael@0 | 41 | // subsequently recognize and use the handle. |
michael@0 | 42 | // If the function succeeds, the return value is ERROR_SUCCESS. If the |
michael@0 | 43 | // function fails, the return value is the win32 error code corresponding to |
michael@0 | 44 | // the error. |
michael@0 | 45 | DWORD UserHandleGrantAccess(HANDLE handle); |
michael@0 | 46 | |
michael@0 | 47 | // Revokes ownership to the job handle and returns it. The destructor of the |
michael@0 | 48 | // class won't close the handle when called. |
michael@0 | 49 | // If the object is not yet initialized, it returns 0. |
michael@0 | 50 | HANDLE Detach(); |
michael@0 | 51 | |
michael@0 | 52 | private: |
michael@0 | 53 | // Handle to the job referenced by the object. |
michael@0 | 54 | HANDLE job_handle_; |
michael@0 | 55 | |
michael@0 | 56 | DISALLOW_COPY_AND_ASSIGN(Job); |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | } // namespace sandbox |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | #endif // SANDBOX_SRC_JOB_H_ |