OLD | NEW |
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/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 // N.B. Windows XP/W2K3 only. | 124 // N.B. Windows XP/W2K3 only. |
125 class SasInjectorXp : public SasInjector { | 125 class SasInjectorXp : public SasInjector { |
126 public: | 126 public: |
127 SasInjectorXp(); | 127 SasInjectorXp(); |
128 virtual ~SasInjectorXp(); | 128 virtual ~SasInjectorXp(); |
129 | 129 |
130 // SasInjector implementation. | 130 // SasInjector implementation. |
131 virtual bool InjectSas() override; | 131 virtual bool InjectSas() override; |
132 }; | 132 }; |
133 | 133 |
134 SasInjectorWin::SasInjectorWin() : send_sas_(NULL) { | 134 SasInjectorWin::SasInjectorWin() : send_sas_(nullptr) { |
135 } | 135 } |
136 | 136 |
137 SasInjectorWin::~SasInjectorWin() { | 137 SasInjectorWin::~SasInjectorWin() { |
138 } | 138 } |
139 | 139 |
140 bool SasInjectorWin::InjectSas() { | 140 bool SasInjectorWin::InjectSas() { |
141 // Load sas.dll. The library is expected to be in the same folder as this | 141 // Load sas.dll. The library is expected to be in the same folder as this |
142 // binary. | 142 // binary. |
143 if (!sas_dll_.is_valid()) { | 143 if (!sas_dll_.is_valid()) { |
144 base::FilePath dir_path; | 144 base::FilePath dir_path; |
145 if (!PathService::Get(base::DIR_EXE, &dir_path)) { | 145 if (!PathService::Get(base::DIR_EXE, &dir_path)) { |
146 LOG(ERROR) << "Failed to get the executable file name."; | 146 LOG(ERROR) << "Failed to get the executable file name."; |
147 return false; | 147 return false; |
148 } | 148 } |
149 | 149 |
150 sas_dll_.Reset(base::LoadNativeLibrary(dir_path.Append(kSasDllFileName), | 150 sas_dll_.Reset(base::LoadNativeLibrary(dir_path.Append(kSasDllFileName), |
151 NULL)); | 151 nullptr)); |
152 } | 152 } |
153 if (!sas_dll_.is_valid()) { | 153 if (!sas_dll_.is_valid()) { |
154 LOG(ERROR) << "Failed to load '" << kSasDllFileName << "'"; | 154 LOG(ERROR) << "Failed to load '" << kSasDllFileName << "'"; |
155 return false; | 155 return false; |
156 } | 156 } |
157 | 157 |
158 // Get the pointer to sas!SendSAS(). | 158 // Get the pointer to sas!SendSAS(). |
159 if (send_sas_ == NULL) { | 159 if (send_sas_ == nullptr) { |
160 send_sas_ = reinterpret_cast<SendSasFunc>( | 160 send_sas_ = reinterpret_cast<SendSasFunc>( |
161 sas_dll_.GetFunctionPointer(kSendSasName)); | 161 sas_dll_.GetFunctionPointer(kSendSasName)); |
162 } | 162 } |
163 if (send_sas_ == NULL) { | 163 if (send_sas_ == nullptr) { |
164 LOG(ERROR) << "Failed to retrieve the address of '" << kSendSasName | 164 LOG(ERROR) << "Failed to retrieve the address of '" << kSendSasName |
165 << "()'"; | 165 << "()'"; |
166 return false; | 166 return false; |
167 } | 167 } |
168 | 168 |
169 // Enable software SAS generation by services and send SAS. SAS can still fail | 169 // Enable software SAS generation by services and send SAS. SAS can still fail |
170 // if the policy does not allow services to generate software SAS. | 170 // if the policy does not allow services to generate software SAS. |
171 ScopedSoftwareSasPolicy enable_sas; | 171 ScopedSoftwareSasPolicy enable_sas; |
172 if (!enable_sas.Apply()) | 172 if (!enable_sas.Apply()) |
173 return false; | 173 return false; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 scoped_ptr<SasInjector> SasInjector::Create() { | 221 scoped_ptr<SasInjector> SasInjector::Create() { |
222 if (base::win::GetVersion() < base::win::VERSION_VISTA) { | 222 if (base::win::GetVersion() < base::win::VERSION_VISTA) { |
223 return make_scoped_ptr(new SasInjectorXp()); | 223 return make_scoped_ptr(new SasInjectorXp()); |
224 } else { | 224 } else { |
225 return make_scoped_ptr(new SasInjectorWin()); | 225 return make_scoped_ptr(new SasInjectorWin()); |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 } // namespace remoting | 229 } // namespace remoting |
OLD | NEW |