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

Side by Side Diff: rlz/win/lib/registry_util.cc

Issue 921913002: Move GetProcessIntegrityLevel to file_info.h and remove the handle argument. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix cast Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « rlz/win/lib/process_info.cc ('k') | win8/delegate_execute/command_execute_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // A helper library to keep track of a user's key by SID. 5 // A helper library to keep track of a user's key by SID.
6 // Used by RLZ libary. Also to be used by SearchWithGoogle library. 6 // Used by RLZ libary. Also to be used by SearchWithGoogle library.
7 7
8 #include "rlz/win/lib/registry_util.h" 8 #include "rlz/win/lib/registry_util.h"
9 9
10 #include "base/process/process_handle.h" 10 #include "base/process/process_info.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "base/win/registry.h" 12 #include "base/win/registry.h"
13 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
14 #include "rlz/lib/assert.h" 14 #include "rlz/lib/assert.h"
15 #include "rlz/win/lib/process_info.h" 15 #include "rlz/win/lib/process_info.h"
16 16
17 namespace rlz_lib { 17 namespace rlz_lib {
18 18
19 bool RegKeyReadValue(const base::win::RegKey& key, const wchar_t* name, 19 bool RegKeyReadValue(const base::win::RegKey& key, const wchar_t* name,
20 char* value, size_t* value_size) { 20 char* value, size_t* value_size) {
(...skipping 30 matching lines...) Expand all
51 base::win::RegKey key; 51 base::win::RegKey key;
52 if (key.Open(HKEY_CURRENT_USER, L"Software", KEY_READ) != ERROR_SUCCESS) 52 if (key.Open(HKEY_CURRENT_USER, L"Software", KEY_READ) != ERROR_SUCCESS)
53 ASSERT_STRING("Could not open HKEY_CURRENT_USER"); 53 ASSERT_STRING("Could not open HKEY_CURRENT_USER");
54 54
55 if (ProcessInfo::IsRunningAsSystem()) { 55 if (ProcessInfo::IsRunningAsSystem()) {
56 ASSERT_STRING("UserKey::HasAccess: No access as SYSTEM without SID set."); 56 ASSERT_STRING("UserKey::HasAccess: No access as SYSTEM without SID set.");
57 return false; 57 return false;
58 } 58 }
59 59
60 if (write_access) { 60 if (write_access) {
61 if (base::win::GetVersion() < base::win::VERSION_VISTA) return true; 61 if (base::win::GetVersion() < base::win::VERSION_VISTA)
62 base::ProcessHandle process_handle = base::GetCurrentProcessHandle(); 62 return true;
63 base::IntegrityLevel level = base::INTEGRITY_UNKNOWN;
64 63
65 if (!base::GetProcessIntegrityLevel(process_handle, &level)) { 64 if (base::GetCurrentProcessIntegrityLevel() <= base::LOW_INTEGRITY) {
66 ASSERT_STRING("UserKey::HasAccess: Cannot determine Integrity Level.");
67 return false;
68 }
69 if (level <= base::LOW_INTEGRITY) {
70 ASSERT_STRING("UserKey::HasAccess: Cannot write from Low Integrity."); 65 ASSERT_STRING("UserKey::HasAccess: Cannot write from Low Integrity.");
71 return false; 66 return false;
72 } 67 }
73 } 68 }
74 return true; 69 return true;
75 } 70 }
76 71
77 } // namespace rlz_lib 72 } // namespace rlz_lib
OLDNEW
« no previous file with comments | « rlz/win/lib/process_info.cc ('k') | win8/delegate_execute/command_execute_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698