diff options
-rw-r--r-- | chrome_frame/chrome_tab.cc | 9 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 15 | ||||
-rw-r--r-- | chrome_frame/utils.h | 3 |
3 files changed, 26 insertions, 1 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index 8036536..5e712a22 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -298,8 +298,15 @@ HRESULT SetupRunOnce() { return S_OK; } + HKEY hive = HKEY_CURRENT_USER; + if (IsSystemProcess()) { + // For system installs, our updates will be running as SYSTEM which + // makes writing to a RunOnce key under HKCU not so terribly useful. + hive = HKEY_LOCAL_MACHINE; + } + RegKey run_once; - if (run_once.Create(HKEY_CURRENT_USER, kRunOnce, KEY_READ | KEY_WRITE)) { + if (run_once.Create(hive, kRunOnce, KEY_READ | KEY_WRITE)) { CommandLine run_once_command(chrome_launcher::GetChromeExecutablePath()); run_once_command.AppendSwitchASCII(switches::kAutomationClientChannelID, "0"); diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index e8dfb4b..31cf389 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -7,6 +7,8 @@ #include <shlobj.h> #include <wininet.h> +#include <atlsecurity.h> + #include "base/file_util.h" #include "base/file_version_info.h" #include "base/lazy_instance.h" @@ -1127,6 +1129,19 @@ bool IsIBrowserServicePatchEnabled() { return patch_method == PATCH_METHOD_IBROWSER; } +bool IsSystemProcess() { + bool is_system = false; + CAccessToken process_token; + if (process_token.GetProcessToken(TOKEN_QUERY, GetCurrentProcess())) { + CSid logon_sid; + if (process_token.GetUser(&logon_sid)) { + is_system = logon_sid == Sids::System(); + } + } + return is_system; +} + + std::string BindStatus2Str(ULONG bind_status) { std::string s; static const char* const bindstatus_txt[] = { diff --git a/chrome_frame/utils.h b/chrome_frame/utils.h index 477084d..0587fdd 100644 --- a/chrome_frame/utils.h +++ b/chrome_frame/utils.h @@ -460,6 +460,9 @@ ProtocolPatchMethod GetPatchMethod(); // Returns true if the IMoniker patch is enabled. bool IsIBrowserServicePatchEnabled(); +// Returns true if we can detect that we are running as SYSTEM, false otherwise. +bool IsSystemProcess(); + // STL helper class that implements a functor to delete objects. // E.g: std::for_each(v.begin(), v.end(), utils::DeleteObject()); namespace utils { |