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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/host/win/elevation_helpers.cc
diff --git a/remoting/host/win/elevation_helpers.cc b/remoting/host/win/elevation_helpers.cc
index 7e8fb76cd21168f98e8b362165291a7c7e091297..dee90162d9469f3a007957bfe2a8d3a85bc5f0f0 100644
--- a/remoting/host/win/elevation_helpers.cc
+++ b/remoting/host/win/elevation_helpers.cc
@@ -6,23 +6,52 @@
#include <windows.h>
+#include "base/logging.h"
#include "base/win/scoped_handle.h"
-namespace remoting {
+namespace {
+
+void GetCurrentProcessToken(base::win::ScopedHandle* scoped_handle) {
+ DCHECK(scoped_handle);
-bool IsProcessElevated() {
HANDLE process_token;
OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &process_token);
+ scoped_handle->Set(process_token);
+ DCHECK(scoped_handle->IsValid());
+}
+
+} // namespace
+
+namespace remoting {
- base::win::ScopedHandle scoped_process_token(process_token);
+bool IsProcessElevated() {
+ base::win::ScopedHandle scoped_process_token;
+ GetCurrentProcessToken(&scoped_process_token);
// Unlike TOKEN_ELEVATION_TYPE which returns TokenElevationTypeDefault when
- // UAC is turned off, TOKEN_ELEVATION will tell you the process is elevated.
+ // UAC is turned off, TOKEN_ELEVATION returns whether the process is elevated.
DWORD size;
TOKEN_ELEVATION elevation;
- GetTokenInformation(process_token, TokenElevation,
- &elevation, sizeof(elevation), &size);
+ if (!GetTokenInformation(scoped_process_token.Get(), TokenElevation,
+ &elevation, sizeof(elevation), &size)) {
+ PLOG(ERROR) << "GetTokenInformation() failed";
+ return false;
+ }
return elevation.TokenIsElevated != 0;
}
+bool CurrentProcessHasUiAccess() {
+ base::win::ScopedHandle scoped_process_token;
+ GetCurrentProcessToken(&scoped_process_token);
+
+ DWORD size;
+ DWORD uiaccess_value = 0;
+ if (!GetTokenInformation(scoped_process_token.Get(), TokenUIAccess,
+ &uiaccess_value, sizeof(uiaccess_value), &size)) {
+ PLOG(ERROR) << "GetTokenInformation() failed";
+ return false;
+ }
+ return uiaccess_value != 0;
+}
+
} // namespace remoting
« 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