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>
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.
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();
45 // Returns the unique ID for the specified process. This is functionally the
46 // same as Windows' GetProcessId(), but works on versions of Windows before
47 // Win XP SP1 as well.
48 BASE_EXPORT ProcessId
GetProcId(ProcessHandle process
);
57 // Determine the integrity level of the specified process. Returns false
58 // if the system does not support integrity levels (pre-Vista) or in the case
59 // of an underlying system failure.
60 BASE_EXPORT
bool GetProcessIntegrityLevel(ProcessHandle process
,
61 IntegrityLevel
* level
);
65 // Returns the path to the executable of the given process.
66 BASE_EXPORT FilePath
GetProcessExecutablePath(ProcessHandle process
);
68 // Returns the ID for the parent of the given process.
69 BASE_EXPORT ProcessId
GetParentProcessId(ProcessHandle process
);
74 #endif // BASE_PROCESS_PROCESS_HANDLE_H_