| 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/dll_redirector.h" | 5 #include "chrome_frame/dll_redirector.h" |
| 6 | 6 |
| 7 #include <aclapi.h> | 7 #include <aclapi.h> |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlsecurity.h> | 9 #include <atlsecurity.h> |
| 10 #include <sddl.h> | 10 #include <sddl.h> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 const wchar_t kSharedMemoryName[] = L"ChromeFrameVersionBeacon_"; | 23 const wchar_t kSharedMemoryName[] = L"ChromeFrameVersionBeacon_"; |
| 24 const uint32 kSharedMemorySize = 128; | 24 const uint32 kSharedMemorySize = 128; |
| 25 const uint32 kSharedMemoryLockTimeoutMs = 1000; | 25 const uint32 kSharedMemoryLockTimeoutMs = 1000; |
| 26 | 26 |
| 27 // static | 27 // static |
| 28 DllRedirector::DllRedirector() : first_module_handle_(NULL) { | 28 DllRedirector::DllRedirector() : first_module_handle_(NULL) { |
| 29 // TODO(robertshield): Allow for overrides to be taken from the environment. | 29 // TODO(robertshield): Allow for overrides to be taken from the environment. |
| 30 std::wstring beacon_name(kSharedMemoryName); | 30 std::wstring beacon_name(kSharedMemoryName); |
| 31 beacon_name += GetHostProcessName(false); | 31 beacon_name += GetHostProcessName(false); |
| 32 shared_memory_.reset(new base::SharedMemory(beacon_name)); | 32 shared_memory_.reset(new base::SharedMemory(beacon_name)); |
| 33 shared_memory_name_ = WideToUTF8(beacon_name); | 33 shared_memory_name_ = base::WideToUTF8(beacon_name); |
| 34 } | 34 } |
| 35 | 35 |
| 36 DllRedirector::DllRedirector(const char* shared_memory_name) | 36 DllRedirector::DllRedirector(const char* shared_memory_name) |
| 37 : shared_memory_name_(shared_memory_name), first_module_handle_(NULL) { | 37 : shared_memory_name_(shared_memory_name), first_module_handle_(NULL) { |
| 38 shared_memory_.reset(new base::SharedMemory(ASCIIToWide(shared_memory_name))); | 38 shared_memory_.reset( |
| 39 new base::SharedMemory(base::ASCIIToWide(shared_memory_name))); |
| 39 } | 40 } |
| 40 | 41 |
| 41 DllRedirector::~DllRedirector() { | 42 DllRedirector::~DllRedirector() { |
| 42 if (first_module_handle_) { | 43 if (first_module_handle_) { |
| 43 if (first_module_handle_ != reinterpret_cast<HMODULE>(&__ImageBase)) { | 44 if (first_module_handle_ != reinterpret_cast<HMODULE>(&__ImageBase)) { |
| 44 FreeLibrary(first_module_handle_); | 45 FreeLibrary(first_module_handle_); |
| 45 } else { | 46 } else { |
| 46 NOTREACHED() << "Error, DllRedirector attempting to free self."; | 47 NOTREACHED() << "Error, DllRedirector attempting to free self."; |
| 47 } | 48 } |
| 48 | 49 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 if (GetModuleFileName(this_module, system_buffer, | 280 if (GetModuleFileName(this_module, system_buffer, |
| 280 arraysize(system_buffer)) != 0) { | 281 arraysize(system_buffer)) != 0) { |
| 281 base::FilePath module_path(system_buffer); | 282 base::FilePath module_path(system_buffer); |
| 282 | 283 |
| 283 // For a module located in | 284 // For a module located in |
| 284 // Foo\XXXXXXXXX\<module>.dll, load | 285 // Foo\XXXXXXXXX\<module>.dll, load |
| 285 // Foo\<version>\<module>.dll: | 286 // Foo\<version>\<module>.dll: |
| 286 base::FilePath module_name = module_path.BaseName(); | 287 base::FilePath module_name = module_path.BaseName(); |
| 287 module_path = module_path.DirName() | 288 module_path = module_path.DirName() |
| 288 .DirName() | 289 .DirName() |
| 289 .Append(ASCIIToWide(version->GetString())) | 290 .Append(base::ASCIIToWide(version->GetString())) |
| 290 .Append(module_name); | 291 .Append(module_name); |
| 291 | 292 |
| 292 hmodule = LoadLibrary(module_path.value().c_str()); | 293 hmodule = LoadLibrary(module_path.value().c_str()); |
| 293 if (hmodule == NULL) { | 294 if (hmodule == NULL) { |
| 294 DPLOG(ERROR) << "Could not load reported module version " | 295 DPLOG(ERROR) << "Could not load reported module version " |
| 295 << version->GetString(); | 296 << version->GetString(); |
| 296 } | 297 } |
| 297 } else { | 298 } else { |
| 298 DPLOG(FATAL) << "Failed to get module file name"; | 299 DPLOG(FATAL) << "Failed to get module file name"; |
| 299 } | 300 } |
| 300 return hmodule; | 301 return hmodule; |
| 301 } | 302 } |
| OLD | NEW |