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 | |
75 return false; | 69 return false; |
76 } | 70 } |
77 | 71 |
78 base::string16 GetModuleName(HMODULE module) { | 72 base::string16 GetModuleName(HMODULE module) { |
79 base::string16 name; | 73 base::string16 name; |
80 if (!module) | 74 if (!module) |
81 return name; | 75 return name; |
82 wchar_t buffer[MAX_PATH]; | 76 wchar_t buffer[MAX_PATH]; |
83 int rv = GetModuleFileName(module, buffer, MAX_PATH); | 77 int rv = GetModuleFileName(module, buffer, MAX_PATH); |
84 if (rv == MAX_PATH) | 78 if (rv == MAX_PATH) |
(...skipping 24 matching lines...) Expand all Loading... |
109 hooks->AddIATPatch(L"chrome.exe"); | 103 hooks->AddIATPatch(L"chrome.exe"); |
110 hooks->AddIATPatch(GetModuleName(GetChromeDLLModule())); | 104 hooks->AddIATPatch(GetModuleName(GetChromeDLLModule())); |
111 } else { | 105 } else { |
112 base::win::DisableHandleVerifier(); | 106 base::win::DisableHandleVerifier(); |
113 } | 107 } |
114 } | 108 } |
115 | 109 |
116 void RemoveCloseHandleHooks() { | 110 void RemoveCloseHandleHooks() { |
117 g_hooks.Get().Unpatch(); | 111 g_hooks.Get().Unpatch(); |
118 } | 112 } |
OLD | NEW |