security/sandbox/win/src/job.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/security/sandbox/win/src/job.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,62 @@
     1.4 +// Copyright (c) 2010 The Chromium Authors. All rights reserved.
     1.5 +// Use of this source code is governed by a BSD-style license that can be
     1.6 +// found in the LICENSE file.
     1.7 +
     1.8 +#ifndef SANDBOX_SRC_JOB_H_
     1.9 +#define SANDBOX_SRC_JOB_H_
    1.10 +
    1.11 +#include "base/basictypes.h"
    1.12 +#include "sandbox/win/src/restricted_token_utils.h"
    1.13 +
    1.14 +namespace sandbox {
    1.15 +
    1.16 +// Handles the creation of job objects based on a security profile.
    1.17 +// Sample usage:
    1.18 +//   Job job;
    1.19 +//   job.Init(JOB_LOCKDOWN, NULL);  //no job name
    1.20 +//   job.AssignProcessToJob(process_handle);
    1.21 +class Job {
    1.22 + public:
    1.23 +  Job() : job_handle_(NULL) { }
    1.24 +
    1.25 +  ~Job();
    1.26 +
    1.27 +  // Initializes and creates the job object. The security of the job is based
    1.28 +  // on the security_level parameter.
    1.29 +  // job_name can be NULL if the job is unnamed.
    1.30 +  // If the chosen profile has too many ui restrictions, you can disable some
    1.31 +  // by specifying them in the ui_exceptions parameters.
    1.32 +  // If the function succeeds, the return value is ERROR_SUCCESS. If the
    1.33 +  // function fails, the return value is the win32 error code corresponding to
    1.34 +  // the error.
    1.35 +  DWORD Init(JobLevel security_level, wchar_t *job_name, DWORD ui_exceptions);
    1.36 +
    1.37 +  // Assigns the process referenced by process_handle to the job.
    1.38 +  // If the function succeeds, the return value is ERROR_SUCCESS. If the
    1.39 +  // function fails, the return value is the win32 error code corresponding to
    1.40 +  // the error.
    1.41 +  DWORD AssignProcessToJob(HANDLE process_handle);
    1.42 +
    1.43 +  // Grants access to "handle" to the job. All processes in the job can
    1.44 +  // subsequently recognize and use the handle.
    1.45 +  // If the function succeeds, the return value is ERROR_SUCCESS. If the
    1.46 +  // function fails, the return value is the win32 error code corresponding to
    1.47 +  // the error.
    1.48 +  DWORD UserHandleGrantAccess(HANDLE handle);
    1.49 +
    1.50 +  // Revokes ownership to the job handle and returns it. The destructor of the
    1.51 +  // class won't close the handle when called.
    1.52 +  // If the object is not yet initialized, it returns 0.
    1.53 +  HANDLE Detach();
    1.54 +
    1.55 + private:
    1.56 +  // Handle to the job referenced by the object.
    1.57 +  HANDLE job_handle_;
    1.58 +
    1.59 +  DISALLOW_COPY_AND_ASSIGN(Job);
    1.60 +};
    1.61 +
    1.62 +}  // namespace sandbox
    1.63 +
    1.64 +
    1.65 +#endif  // SANDBOX_SRC_JOB_H_

mercurial