| 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 "chrome_frame/test_utils.h" | 5 #include "chrome_frame/test_utils.h" |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlwin.h> | 8 #include <atlwin.h> |
| 9 #include <shellapi.h> | 9 #include <shellapi.h> |
| 10 | 10 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 "DllUnregisterUserServer", | 81 "DllUnregisterUserServer", |
| 82 }; | 82 }; |
| 83 | 83 |
| 84 DCHECK(!path.empty()); | 84 DCHECK(!path.empty()); |
| 85 DCHECK(registration_type == PER_USER || registration_type == SYSTEM_LEVEL); | 85 DCHECK(registration_type == PER_USER || registration_type == SYSTEM_LEVEL); |
| 86 DCHECK(registration_operation == REGISTER || | 86 DCHECK(registration_operation == REGISTER || |
| 87 registration_operation == UNREGISTER); | 87 registration_operation == UNREGISTER); |
| 88 | 88 |
| 89 int entrypoint_index = 0; | 89 int entrypoint_index = 0; |
| 90 base::LaunchOptions launch_options; | 90 base::LaunchOptions launch_options; |
| 91 base::win::ScopedHandle process_handle; | 91 base::ProcessHandle process_handle = INVALID_HANDLE_VALUE; |
| 92 int exit_code = -1; | 92 int exit_code = -1; |
| 93 | 93 |
| 94 if (registration_type == PER_USER) | 94 if (registration_type == PER_USER) |
| 95 entrypoint_index += 2; | 95 entrypoint_index += 2; |
| 96 if (registration_operation == UNREGISTER) | 96 if (registration_operation == UNREGISTER) |
| 97 entrypoint_index += 1; | 97 entrypoint_index += 1; |
| 98 string16 registration_command(ASCIIToUTF16("\"")); | 98 string16 registration_command(ASCIIToUTF16("\"")); |
| 99 registration_command += | 99 registration_command += |
| 100 CommandLine::ForCurrentProcess()->GetProgram().value(); | 100 CommandLine::ForCurrentProcess()->GetProgram().value(); |
| 101 registration_command += ASCIIToUTF16("\" "); | 101 registration_command += ASCIIToUTF16("\" "); |
| 102 registration_command += kCallRegistrationEntrypointSwitch; | 102 registration_command += kCallRegistrationEntrypointSwitch; |
| 103 registration_command += ASCIIToUTF16(" \""); | 103 registration_command += ASCIIToUTF16(" \""); |
| 104 registration_command += path; | 104 registration_command += path; |
| 105 registration_command += ASCIIToUTF16("\" "); | 105 registration_command += ASCIIToUTF16("\" "); |
| 106 registration_command += ASCIIToUTF16(kEntrypoints[entrypoint_index]); | 106 registration_command += ASCIIToUTF16(kEntrypoints[entrypoint_index]); |
| 107 launch_options.wait = true; | 107 launch_options.wait = true; |
| 108 if (!base::LaunchProcess(registration_command, launch_options, | 108 if (!base::LaunchProcess(registration_command, launch_options, |
| 109 &process_handle)) { | 109 &process_handle)) { |
| 110 PLOG(FATAL) | 110 PLOG(FATAL) |
| 111 << "Failed to register or unregister DLL with command: " | 111 << "Failed to register or unregister DLL with command: " |
| 112 << registration_command; | 112 << registration_command; |
| 113 } else { | 113 } else { |
| 114 base::win::ScopedHandle rundll32(process_handle); |
| 114 if (!base::WaitForExitCodeWithTimeout( | 115 if (!base::WaitForExitCodeWithTimeout( |
| 115 process_handle.Get(), &exit_code, | 116 process_handle, &exit_code, |
| 116 base::TimeDelta::FromMilliseconds(kDllRegistrationTimeoutMs))) { | 117 base::TimeDelta::FromMilliseconds(kDllRegistrationTimeoutMs))) { |
| 117 LOG(ERROR) << "Timeout waiting to register or unregister DLL with " | 118 LOG(ERROR) << "Timeout waiting to register or unregister DLL with " |
| 118 "command: " << registration_command; | 119 "command: " << registration_command; |
| 119 base::KillProcess(process_handle.Get(), 0, false); | 120 base::KillProcess(process_handle, 0, false); |
| 120 NOTREACHED() << "Aborting test due to registration failure."; | 121 NOTREACHED() << "Aborting test due to registration failure."; |
| 121 } | 122 } |
| 122 } | 123 } |
| 123 if (exit_code != 0) { | 124 if (exit_code != 0) { |
| 124 if (registration_operation == REGISTER) { | 125 if (registration_operation == REGISTER) { |
| 125 LOG(ERROR) | 126 LOG(ERROR) |
| 126 << "DLL registration failed (exit code: 0x" << std::hex << exit_code | 127 << "DLL registration failed (exit code: 0x" << std::hex << exit_code |
| 127 << ", command: " << registration_command | 128 << ", command: " << registration_command |
| 128 << "). Make sure you are running as Admin."; | 129 << "). Make sure you are running as Admin."; |
| 129 ::ExitProcess(1); | 130 ::ExitProcess(1); |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 UOI_NAME, | 278 UOI_NAME, |
| 278 name, | 279 name, |
| 279 sizeof(name), | 280 sizeof(name), |
| 280 &needed)) { | 281 &needed)) { |
| 281 is_locked = lstrcmpi(name, L"default") != 0; | 282 is_locked = lstrcmpi(name, L"default") != 0; |
| 282 } | 283 } |
| 283 ::CloseDesktop(input_desk); | 284 ::CloseDesktop(input_desk); |
| 284 } | 285 } |
| 285 return is_locked; | 286 return is_locked; |
| 286 } | 287 } |
| OLD | NEW |