security/sandbox/chromium/base/process/process_handle.h

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
     2 // Use of this source code is governed by a BSD-style license that can be
     3 // found in the LICENSE file.
     5 #ifndef BASE_PROCESS_PROCESS_HANDLE_H_
     6 #define BASE_PROCESS_PROCESS_HANDLE_H_
     8 #include "base/base_export.h"
     9 #include "base/basictypes.h"
    10 #include "base/files/file_path.h"
    11 #include "build/build_config.h"
    13 #include <sys/types.h>
    14 #if defined(OS_WIN)
    15 #include <windows.h>
    16 #endif
    18 namespace base {
    20 // ProcessHandle is a platform specific type which represents the underlying OS
    21 // handle to a process.
    22 // ProcessId is a number which identifies the process in the OS.
    23 #if defined(OS_WIN)
    24 typedef HANDLE ProcessHandle;
    25 typedef DWORD ProcessId;
    26 typedef HANDLE UserTokenHandle;
    27 const ProcessHandle kNullProcessHandle = NULL;
    28 const ProcessId kNullProcessId = 0;
    29 #elif defined(OS_POSIX)
    30 // On POSIX, our ProcessHandle will just be the PID.
    31 typedef pid_t ProcessHandle;
    32 typedef pid_t ProcessId;
    33 const ProcessHandle kNullProcessHandle = 0;
    34 const ProcessId kNullProcessId = 0;
    35 #endif  // defined(OS_WIN)
    37 // Returns the id of the current process.
    38 BASE_EXPORT ProcessId GetCurrentProcId();
    40 // Returns the ProcessHandle of the current process.
    41 BASE_EXPORT ProcessHandle GetCurrentProcessHandle();
    43 // Converts a PID to a process handle. This handle must be closed by
    44 // CloseProcessHandle when you are done with it. Returns true on success.
    45 BASE_EXPORT bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle);
    47 // Converts a PID to a process handle. On Windows the handle is opened
    48 // with more access rights and must only be used by trusted code.
    49 // You have to close returned handle using CloseProcessHandle. Returns true
    50 // on success.
    51 // TODO(sanjeevr): Replace all calls to OpenPrivilegedProcessHandle with the
    52 // more specific OpenProcessHandleWithAccess method and delete this.
    53 BASE_EXPORT bool OpenPrivilegedProcessHandle(ProcessId pid,
    54                                              ProcessHandle* handle);
    56 // Converts a PID to a process handle using the desired access flags. Use a
    57 // combination of the kProcessAccess* flags defined above for |access_flags|.
    58 BASE_EXPORT bool OpenProcessHandleWithAccess(ProcessId pid,
    59                                              uint32 access_flags,
    60                                              ProcessHandle* handle);
    62 // Closes the process handle opened by OpenProcessHandle.
    63 BASE_EXPORT void CloseProcessHandle(ProcessHandle process);
    65 // Returns the unique ID for the specified process. This is functionally the
    66 // same as Windows' GetProcessId(), but works on versions of Windows before
    67 // Win XP SP1 as well.
    68 BASE_EXPORT ProcessId GetProcId(ProcessHandle process);
    70 #if defined(OS_WIN)
    71 enum IntegrityLevel {
    72   INTEGRITY_UNKNOWN,
    73   LOW_INTEGRITY,
    74   MEDIUM_INTEGRITY,
    75   HIGH_INTEGRITY,
    76 };
    77 // Determine the integrity level of the specified process. Returns false
    78 // if the system does not support integrity levels (pre-Vista) or in the case
    79 // of an underlying system failure.
    80 BASE_EXPORT bool GetProcessIntegrityLevel(ProcessHandle process,
    81                                           IntegrityLevel* level);
    82 #endif
    84 #if defined(OS_LINUX) || defined(OS_ANDROID) || defined(OS_BSD)
    85 // Returns the path to the executable of the given process.
    86 BASE_EXPORT FilePath GetProcessExecutablePath(ProcessHandle process);
    87 #endif
    89 #if defined(OS_POSIX)
    90 // Returns the ID for the parent of the given process.
    91 BASE_EXPORT ProcessId GetParentProcessId(ProcessHandle process);
    92 #endif
    94 }  // namespace base
    96 #endif  // BASE_PROCESS_PROCESS_HANDLE_H_

mercurial