| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/app/close_handle_hook_win.h" | 5 #include "chrome/app/close_handle_hook_win.h" |
| 6 | 6 |
| 7 #include <Windows.h> | 7 #include <Windows.h> |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 void CloseHandleHooks::Unpatch() { | 61 void CloseHandleHooks::Unpatch() { |
| 62 for (std::vector<base::win::IATPatchFunction*>::iterator it = hooks_.begin(); | 62 for (std::vector<base::win::IATPatchFunction*>::iterator it = hooks_.begin(); |
| 63 it != hooks_.end(); ++it) { | 63 it != hooks_.end(); ++it) { |
| 64 (*it)->Unpatch(); | 64 (*it)->Unpatch(); |
| 65 } | 65 } |
| 66 } | 66 } |
| 67 | 67 |
| 68 bool UseHooks() { | 68 bool UseHooks() { |
| 69 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 70 if (channel == chrome::VersionInfo::CHANNEL_CANARY || |
| 71 channel == chrome::VersionInfo::CHANNEL_DEV) { |
| 72 return true; |
| 73 } |
| 74 |
| 69 return false; | 75 return false; |
| 70 } | 76 } |
| 71 | 77 |
| 72 base::string16 GetModuleName(HMODULE module) { | 78 base::string16 GetModuleName(HMODULE module) { |
| 73 base::string16 name; | 79 base::string16 name; |
| 74 if (!module) | 80 if (!module) |
| 75 return name; | 81 return name; |
| 76 wchar_t buffer[MAX_PATH]; | 82 wchar_t buffer[MAX_PATH]; |
| 77 int rv = GetModuleFileName(module, buffer, MAX_PATH); | 83 int rv = GetModuleFileName(module, buffer, MAX_PATH); |
| 78 if (rv == MAX_PATH) | 84 if (rv == MAX_PATH) |
| (...skipping 24 matching lines...) Expand all Loading... |
| 103 hooks->AddIATPatch(L"chrome.exe"); | 109 hooks->AddIATPatch(L"chrome.exe"); |
| 104 hooks->AddIATPatch(GetModuleName(GetChromeDLLModule())); | 110 hooks->AddIATPatch(GetModuleName(GetChromeDLLModule())); |
| 105 } else { | 111 } else { |
| 106 base::win::DisableHandleVerifier(); | 112 base::win::DisableHandleVerifier(); |
| 107 } | 113 } |
| 108 } | 114 } |
| 109 | 115 |
| 110 void RemoveCloseHandleHooks() { | 116 void RemoveCloseHandleHooks() { |
| 111 g_hooks.Get().Unpatch(); | 117 g_hooks.Get().Unpatch(); |
| 112 } | 118 } |
| OLD | NEW |