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

Side by Side Diff: remoting/host/sas_injector_win.cc

Issue 11364112: Merge 165565 - Calling SendSAS() from a service to make sure that Secure Attention Sequence can be … (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1312/src/
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/sas_injector.h ('k') | remoting/host/win/session_desktop_environment_factory.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 #include "remoting/host/sas_injector.h" 5 #include "remoting/host/sas_injector.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <string> 8 #include <string>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 16 matching lines...) Expand all
27 27
28 // The prototype of SendSAS(). 28 // The prototype of SendSAS().
29 typedef VOID (WINAPI *SendSasFunc)(BOOL); 29 typedef VOID (WINAPI *SendSasFunc)(BOOL);
30 30
31 // The registry key and value holding the policy controlling software SAS 31 // The registry key and value holding the policy controlling software SAS
32 // generation. 32 // generation.
33 const wchar_t kSystemPolicyKeyName[] = 33 const wchar_t kSystemPolicyKeyName[] =
34 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System"; 34 L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
35 const wchar_t kSoftwareSasValueName[] = L"SoftwareSASGeneration"; 35 const wchar_t kSoftwareSasValueName[] = L"SoftwareSASGeneration";
36 36
37 const DWORD kEnableSoftwareSasByApps = 2; 37 const DWORD kEnableSoftwareSasByServices = 1;
38 38
39 // Toggles the default software SAS generation policy to enable SAS generation 39 // Toggles the default software SAS generation policy to enable SAS generation
40 // by applications. Non-default policy is not changed. 40 // by services. Non-default policy is not changed.
41 class ScopedSoftwareSasPolicy { 41 class ScopedSoftwareSasPolicy {
42 public: 42 public:
43 ScopedSoftwareSasPolicy(); 43 ScopedSoftwareSasPolicy();
44 ~ScopedSoftwareSasPolicy(); 44 ~ScopedSoftwareSasPolicy();
45 45
46 bool Apply(); 46 bool Apply();
47 47
48 private: 48 private:
49 // The handle of the registry key were SoftwareSASGeneration policy is stored. 49 // The handle of the registry key were SoftwareSASGeneration policy is stored.
50 base::win::RegKey system_policy_; 50 base::win::RegKey system_policy_;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 LOG_GETLASTERROR(ERROR) << "Failed to open 'HKLM\\" 82 LOG_GETLASTERROR(ERROR) << "Failed to open 'HKLM\\"
83 << kSystemPolicyKeyName << "'"; 83 << kSystemPolicyKeyName << "'";
84 return false; 84 return false;
85 } 85 }
86 86
87 bool custom_policy = system_policy_.HasValue(kSoftwareSasValueName); 87 bool custom_policy = system_policy_.HasValue(kSoftwareSasValueName);
88 88
89 // Override the default policy (i.e. there is no value in the registry) only. 89 // Override the default policy (i.e. there is no value in the registry) only.
90 if (!custom_policy) { 90 if (!custom_policy) {
91 result = system_policy_.WriteValue(kSoftwareSasValueName, 91 result = system_policy_.WriteValue(kSoftwareSasValueName,
92 kEnableSoftwareSasByApps); 92 kEnableSoftwareSasByServices);
93 if (result != ERROR_SUCCESS) { 93 if (result != ERROR_SUCCESS) {
94 SetLastError(result); 94 SetLastError(result);
95 LOG_GETLASTERROR(ERROR) 95 LOG_GETLASTERROR(ERROR)
96 << "Failed to enable software SAS generation by services"; 96 << "Failed to enable software SAS generation by services";
97 return false; 97 return false;
98 } else { 98 } else {
99 restore_policy_ = true; 99 restore_policy_ = true;
100 } 100 }
101 } 101 }
102 102
103 return true; 103 return true;
104 } 104 }
105 105
106 } // namespace 106 } // namespace
107 107
108 // Sends the Secure Attention Sequence using the SendSAS() function from 108 // Sends Secure Attention Sequence using the SendSAS() function from sas.dll.
109 // sas.dll. This library is shipped starting from Win7/W2K8 R2 only. However 109 // This library is shipped starting from Win7/W2K8 R2 only. However Win7 SDK
110 // Win7 SDK includes a redistributable verion of the same library that works on 110 // includes a redistributable verion of the same library that works on
111 // Vista/W2K8. We install the latter along with our binaries. 111 // Vista/W2K8. We install the latter along with our binaries.
112 class SasInjectorWin : public SasInjector { 112 class SasInjectorWin : public SasInjector {
113 public: 113 public:
114 SasInjectorWin(); 114 SasInjectorWin();
115 virtual ~SasInjectorWin(); 115 virtual ~SasInjectorWin();
116 116
117 // SasInjector implementation. 117 // SasInjector implementation.
118 virtual bool InjectSas() OVERRIDE; 118 virtual bool InjectSas() OVERRIDE;
119 119
120 private: 120 private:
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 send_sas_ = static_cast<SendSasFunc>( 163 send_sas_ = static_cast<SendSasFunc>(
164 sas_dll_.GetFunctionPointer(kSendSasName)); 164 sas_dll_.GetFunctionPointer(kSendSasName));
165 } 165 }
166 if (send_sas_ == NULL) { 166 if (send_sas_ == NULL) {
167 LOG(ERROR) << "Failed to retrieve the address of '" << kSendSasName 167 LOG(ERROR) << "Failed to retrieve the address of '" << kSendSasName
168 << "()'"; 168 << "()'";
169 return false; 169 return false;
170 } 170 }
171 171
172 // Enable software SAS generation by services and send SAS. SAS can still fail 172 // Enable software SAS generation by services and send SAS. SAS can still fail
173 // if the policy does not allow applications to generate software SAS. 173 // if the policy does not allow services to generate software SAS.
174 ScopedSoftwareSasPolicy enable_sas; 174 ScopedSoftwareSasPolicy enable_sas;
175 if (!enable_sas.Apply()) 175 if (!enable_sas.Apply())
176 return false; 176 return false;
177 177
178 (*send_sas_)(FALSE); 178 (*send_sas_)(FALSE);
179 return true; 179 return true;
180 } 180 }
181 181
182 SasInjectorXp::SasInjectorXp() { 182 SasInjectorXp::SasInjectorXp() {
183 } 183 }
(...skipping 28 matching lines...) Expand all
212 212
213 scoped_ptr<SasInjector> SasInjector::Create() { 213 scoped_ptr<SasInjector> SasInjector::Create() {
214 if (base::win::GetVersion() < base::win::VERSION_VISTA) { 214 if (base::win::GetVersion() < base::win::VERSION_VISTA) {
215 return scoped_ptr<SasInjector>(new SasInjectorXp()); 215 return scoped_ptr<SasInjector>(new SasInjectorXp());
216 } else { 216 } else {
217 return scoped_ptr<SasInjector>(new SasInjectorWin()); 217 return scoped_ptr<SasInjector>(new SasInjectorWin());
218 } 218 }
219 } 219 }
220 220
221 } // namespace remoting 221 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/sas_injector.h ('k') | remoting/host/win/session_desktop_environment_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698