Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3699)

Unified Diff: base/process_util_win.cc

Issue 19064002: Split ProcessHandle and its related routines into base/process/process_handle.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ready for review Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process_util_win.cc
diff --git a/base/process_util_win.cc b/base/process_util_win.cc
index 691e1ae0b20312359ef75b56c88303c999268c84..480cf8bc5adfe33853686ef13386e9398d5d1ab0 100644
--- a/base/process_util_win.cc
+++ b/base/process_util_win.cc
@@ -100,117 +100,6 @@ void RouteStdioToConsole() {
std::ios::sync_with_stdio();
}
-ProcessId GetCurrentProcId() {
- return ::GetCurrentProcessId();
-}
-
-ProcessHandle GetCurrentProcessHandle() {
- return ::GetCurrentProcess();
-}
-
-bool OpenProcessHandle(ProcessId pid, ProcessHandle* handle) {
- // We try to limit privileges granted to the handle. If you need this
- // for test code, consider using OpenPrivilegedProcessHandle instead of
- // adding more privileges here.
- ProcessHandle result = OpenProcess(PROCESS_TERMINATE |
- PROCESS_QUERY_INFORMATION |
- SYNCHRONIZE,
- FALSE, pid);
-
- if (result == NULL)
- return false;
-
- *handle = result;
- return true;
-}
-
-bool OpenPrivilegedProcessHandle(ProcessId pid, ProcessHandle* handle) {
- ProcessHandle result = OpenProcess(PROCESS_DUP_HANDLE |
- PROCESS_TERMINATE |
- PROCESS_QUERY_INFORMATION |
- PROCESS_VM_READ |
- SYNCHRONIZE,
- FALSE, pid);
-
- if (result == NULL)
- return false;
-
- *handle = result;
- return true;
-}
-
-bool OpenProcessHandleWithAccess(ProcessId pid,
- uint32 access_flags,
- ProcessHandle* handle) {
- ProcessHandle result = OpenProcess(access_flags, FALSE, pid);
-
- if (result == NULL)
- return false;
-
- *handle = result;
- return true;
-}
-
-void CloseProcessHandle(ProcessHandle process) {
- CloseHandle(process);
-}
-
-ProcessId GetProcId(ProcessHandle process) {
- // This returns 0 if we have insufficient rights to query the process handle.
- return GetProcessId(process);
-}
-
-bool GetProcessIntegrityLevel(ProcessHandle process, IntegrityLevel *level) {
- if (!level)
- return false;
-
- if (win::GetVersion() < base::win::VERSION_VISTA)
- return false;
-
- HANDLE process_token;
- if (!OpenProcessToken(process, TOKEN_QUERY | TOKEN_QUERY_SOURCE,
- &process_token))
- return false;
-
- win::ScopedHandle scoped_process_token(process_token);
-
- DWORD token_info_length = 0;
- if (GetTokenInformation(process_token, TokenIntegrityLevel, NULL, 0,
- &token_info_length) ||
- GetLastError() != ERROR_INSUFFICIENT_BUFFER)
- return false;
-
- scoped_ptr<char[]> token_label_bytes(new char[token_info_length]);
- if (!token_label_bytes.get())
- return false;
-
- TOKEN_MANDATORY_LABEL* token_label =
- reinterpret_cast<TOKEN_MANDATORY_LABEL*>(token_label_bytes.get());
- if (!token_label)
- return false;
-
- if (!GetTokenInformation(process_token, TokenIntegrityLevel, token_label,
- token_info_length, &token_info_length))
- return false;
-
- DWORD integrity_level = *GetSidSubAuthority(token_label->Label.Sid,
- (DWORD)(UCHAR)(*GetSidSubAuthorityCount(token_label->Label.Sid)-1));
-
- if (integrity_level < SECURITY_MANDATORY_MEDIUM_RID) {
- *level = LOW_INTEGRITY;
- } else if (integrity_level >= SECURITY_MANDATORY_MEDIUM_RID &&
- integrity_level < SECURITY_MANDATORY_HIGH_RID) {
- *level = MEDIUM_INTEGRITY;
- } else if (integrity_level >= SECURITY_MANDATORY_HIGH_RID) {
- *level = HIGH_INTEGRITY;
- } else {
- NOTREACHED();
- return false;
- }
-
- return true;
-}
-
bool LaunchProcess(const string16& cmdline,
const LaunchOptions& options,
ProcessHandle* process_handle) {
« no previous file with comments | « base/process_util_posix.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698