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

Side by Side Diff: remoting/host/win/elevation_helpers.cc

Issue 2179353004: Update Windows It2Me to allow remote users to interact with elevated windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@it2me_uiaccess
Patch Set: Removing the CHECK assertion and replacing it with LOG(ERROR) instead. Created 4 years, 3 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 #include "remoting/host/win/elevation_helpers.h" 5 #include "remoting/host/win/elevation_helpers.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 8
9 #include "base/logging.h"
9 #include "base/win/scoped_handle.h" 10 #include "base/win/scoped_handle.h"
10 11
12 namespace {
13
14 void GetCurrentProcessToken(base::win::ScopedHandle* scoped_handle) {
15 DCHECK(scoped_handle);
16
17 HANDLE process_token;
18 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token);
19 scoped_handle->Set(process_token);
20 DCHECK(scoped_handle->IsValid());
21 }
22
23 } // namespace
24
11 namespace remoting { 25 namespace remoting {
12 26
13 bool IsProcessElevated() { 27 bool IsProcessElevated() {
14 HANDLE process_token; 28 base::win::ScopedHandle scoped_process_token;
15 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token); 29 GetCurrentProcessToken(&scoped_process_token);
16
17 base::win::ScopedHandle scoped_process_token(process_token);
18 30
19 // Unlike TOKEN_ELEVATION_TYPE which returns TokenElevationTypeDefault when 31 // Unlike TOKEN_ELEVATION_TYPE which returns TokenElevationTypeDefault when
20 // UAC is turned off, TOKEN_ELEVATION will tell you the process is elevated. 32 // UAC is turned off, TOKEN_ELEVATION returns whether the process is elevated.
21 DWORD size; 33 DWORD size;
22 TOKEN_ELEVATION elevation; 34 TOKEN_ELEVATION elevation;
23 GetTokenInformation(process_token, TokenElevation, 35 if (!GetTokenInformation(scoped_process_token.Get(), TokenElevation,
24 &elevation, sizeof(elevation), &size); 36 &elevation, sizeof(elevation), &size)) {
37 PLOG(ERROR) << "GetTokenInformation() failed";
38 return false;
39 }
25 return elevation.TokenIsElevated != 0; 40 return elevation.TokenIsElevated != 0;
26 } 41 }
27 42
43 bool CurrentProcessHasUiAccess() {
44 base::win::ScopedHandle scoped_process_token;
45 GetCurrentProcessToken(&scoped_process_token);
46
47 DWORD size;
48 DWORD uiaccess_value = 0;
49 if (!GetTokenInformation(scoped_process_token.Get(), TokenUIAccess,
50 &uiaccess_value, sizeof(uiaccess_value), &size)) {
51 PLOG(ERROR) << "GetTokenInformation() failed";
52 return false;
53 }
54 return uiaccess_value != 0;
55 }
56
28 } // namespace remoting 57 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/elevation_helpers.h ('k') | remoting/host/win/launch_native_messaging_host_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698