| 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/daemon_process.h" | 5 #include "remoting/host/daemon_process.h" |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 const base::Closure& stopped_callback) { | 230 const base::Closure& stopped_callback) { |
| 231 scoped_ptr<DaemonProcessWin> daemon_process( | 231 scoped_ptr<DaemonProcessWin> daemon_process( |
| 232 new DaemonProcessWin(caller_task_runner, io_task_runner, | 232 new DaemonProcessWin(caller_task_runner, io_task_runner, |
| 233 stopped_callback)); | 233 stopped_callback)); |
| 234 daemon_process->Initialize(); | 234 daemon_process->Initialize(); |
| 235 return daemon_process.Pass(); | 235 return daemon_process.Pass(); |
| 236 } | 236 } |
| 237 | 237 |
| 238 void DaemonProcessWin::DisableAutoStart() { | 238 void DaemonProcessWin::DisableAutoStart() { |
| 239 ScopedScHandle scmanager( | 239 ScopedScHandle scmanager( |
| 240 OpenSCManager(NULL, SERVICES_ACTIVE_DATABASE, | 240 OpenSCManager(nullptr, SERVICES_ACTIVE_DATABASE, |
| 241 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); | 241 SC_MANAGER_CONNECT | SC_MANAGER_ENUMERATE_SERVICE)); |
| 242 if (!scmanager.IsValid()) { | 242 if (!scmanager.IsValid()) { |
| 243 PLOG(INFO) << "Failed to connect to the service control manager"; | 243 PLOG(INFO) << "Failed to connect to the service control manager"; |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 | 246 |
| 247 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS; | 247 DWORD desired_access = SERVICE_CHANGE_CONFIG | SERVICE_QUERY_STATUS; |
| 248 ScopedScHandle service( | 248 ScopedScHandle service( |
| 249 OpenService(scmanager.Get(), kWindowsServiceName, desired_access)); | 249 OpenService(scmanager.Get(), kWindowsServiceName, desired_access)); |
| 250 if (!service.IsValid()) { | 250 if (!service.IsValid()) { |
| 251 PLOG(INFO) << "Failed to open to the '" << kWindowsServiceName | 251 PLOG(INFO) << "Failed to open to the '" << kWindowsServiceName |
| 252 << "' service"; | 252 << "' service"; |
| 253 return; | 253 return; |
| 254 } | 254 } |
| 255 | 255 |
| 256 // Change the service start type to 'manual'. All |NULL| parameters below mean | 256 // Change the service start type to 'manual'. All |nullptr| parameters below |
| 257 // that there is no change to the corresponding service parameter. | 257 // mean that there is no change to the corresponding service parameter. |
| 258 if (!ChangeServiceConfig(service.Get(), | 258 if (!ChangeServiceConfig(service.Get(), |
| 259 SERVICE_NO_CHANGE, | 259 SERVICE_NO_CHANGE, |
| 260 SERVICE_DEMAND_START, | 260 SERVICE_DEMAND_START, |
| 261 SERVICE_NO_CHANGE, | 261 SERVICE_NO_CHANGE, |
| 262 NULL, | 262 nullptr, |
| 263 NULL, | 263 nullptr, |
| 264 NULL, | 264 nullptr, |
| 265 NULL, | 265 nullptr, |
| 266 NULL, | 266 nullptr, |
| 267 NULL, | 267 nullptr, |
| 268 NULL)) { | 268 nullptr)) { |
| 269 PLOG(INFO) << "Failed to change the '" << kWindowsServiceName | 269 PLOG(INFO) << "Failed to change the '" << kWindowsServiceName |
| 270 << "'service start type to 'manual'"; | 270 << "'service start type to 'manual'"; |
| 271 } | 271 } |
| 272 } | 272 } |
| 273 | 273 |
| 274 bool DaemonProcessWin::InitializePairingRegistry() { | 274 bool DaemonProcessWin::InitializePairingRegistry() { |
| 275 if (!pairing_registry_privileged_key_.Valid()) { | 275 if (!pairing_registry_privileged_key_.Valid()) { |
| 276 if (!OpenPairingRegistry()) | 276 if (!OpenPairingRegistry()) |
| 277 return false; | 277 return false; |
| 278 } | 278 } |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 PLOG(ERROR) << "Failed to create a security descriptor for the pairing" | 351 PLOG(ERROR) << "Failed to create a security descriptor for the pairing" |
| 352 << "registry privileged key."; | 352 << "registry privileged key."; |
| 353 return false; | 353 return false; |
| 354 } | 354 } |
| 355 | 355 |
| 356 SECURITY_ATTRIBUTES security_attributes = {0}; | 356 SECURITY_ATTRIBUTES security_attributes = {0}; |
| 357 security_attributes.nLength = sizeof(security_attributes); | 357 security_attributes.nLength = sizeof(security_attributes); |
| 358 security_attributes.lpSecurityDescriptor = sd.get(); | 358 security_attributes.lpSecurityDescriptor = sd.get(); |
| 359 security_attributes.bInheritHandle = FALSE; | 359 security_attributes.bInheritHandle = FALSE; |
| 360 | 360 |
| 361 HKEY key = NULL; | 361 HKEY key = nullptr; |
| 362 result = ::RegCreateKeyEx( | 362 result = ::RegCreateKeyEx( |
| 363 root.Handle(), kPairingRegistrySecretsKeyName, 0, nullptr, 0, | 363 root.Handle(), kPairingRegistrySecretsKeyName, 0, nullptr, 0, |
| 364 KEY_READ | KEY_WRITE, &security_attributes, &key, &disposition); | 364 KEY_READ | KEY_WRITE, &security_attributes, &key, &disposition); |
| 365 privileged.Set(key); | 365 privileged.Set(key); |
| 366 } | 366 } |
| 367 | 367 |
| 368 if (result != ERROR_SUCCESS) { | 368 if (result != ERROR_SUCCESS) { |
| 369 ::SetLastError(result); | 369 ::SetLastError(result); |
| 370 PLOG(ERROR) << "Failed to open or create HKLM\\" << kPairingRegistryKeyName | 370 PLOG(ERROR) << "Failed to open or create HKLM\\" << kPairingRegistryKeyName |
| 371 << "\\" << kPairingRegistrySecretsKeyName; | 371 << "\\" << kPairingRegistrySecretsKeyName; |
| 372 return false; | 372 return false; |
| 373 } | 373 } |
| 374 | 374 |
| 375 pairing_registry_privileged_key_.Set(privileged.Take()); | 375 pairing_registry_privileged_key_.Set(privileged.Take()); |
| 376 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); | 376 pairing_registry_unprivileged_key_.Set(unprivileged.Take()); |
| 377 return true; | 377 return true; |
| 378 } | 378 } |
| 379 | 379 |
| 380 } // namespace remoting | 380 } // namespace remoting |
| OLD | NEW |