| 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 #include <psapi.h> | 8 #include <psapi.h> |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 delete *it; | 178 delete *it; |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 bool UseHooks() { | 182 bool UseHooks() { |
| 183 #if defined(ARCH_CPU_X86_64) | 183 #if defined(ARCH_CPU_X86_64) |
| 184 return false; | 184 return false; |
| 185 #elif defined(NDEBUG) | 185 #elif defined(NDEBUG) |
| 186 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); | 186 chrome::VersionInfo::Channel channel = chrome::VersionInfo::GetChannel(); |
| 187 if (channel == chrome::VersionInfo::CHANNEL_CANARY || | 187 if (channel == chrome::VersionInfo::CHANNEL_CANARY || |
| 188 channel == chrome::VersionInfo::CHANNEL_DEV) { | 188 channel == chrome::VersionInfo::CHANNEL_DEV || |
| 189 channel == chrome::VersionInfo::CHANNEL_UNKNOWN) { |
| 189 return true; | 190 return true; |
| 190 } | 191 } |
| 191 | 192 |
| 192 return false; | 193 return false; |
| 193 #else // NDEBUG | 194 #else // NDEBUG |
| 194 return true; | 195 return true; |
| 195 #endif | 196 #endif |
| 196 } | 197 } |
| 197 | 198 |
| 198 void PatchLoadedModules(CloseHandleHooks* hooks) { | 199 void PatchLoadedModules(CloseHandleHooks* hooks) { |
| (...skipping 15 matching lines...) Expand all Loading... |
| 214 } // namespace | 215 } // namespace |
| 215 | 216 |
| 216 void InstallCloseHandleHooks() { | 217 void InstallCloseHandleHooks() { |
| 217 if (UseHooks()) { | 218 if (UseHooks()) { |
| 218 CloseHandleHooks* hooks = g_hooks.Pointer(); | 219 CloseHandleHooks* hooks = g_hooks.Pointer(); |
| 219 | 220 |
| 220 // Performing EAT interception first is safer in the presence of other | 221 // Performing EAT interception first is safer in the presence of other |
| 221 // threads attempting to call CloseHandle. | 222 // threads attempting to call CloseHandle. |
| 222 hooks->AddEATPatch(); | 223 hooks->AddEATPatch(); |
| 223 PatchLoadedModules(hooks); | 224 PatchLoadedModules(hooks); |
| 224 } else { | |
| 225 base::win::DisableHandleVerifier(); | |
| 226 } | 225 } |
| 227 } | 226 } |
| 228 | 227 |
| 229 void RemoveCloseHandleHooks() { | 228 void RemoveCloseHandleHooks() { |
| 230 // We are partching all loaded modules without forcing them to stay in memory, | 229 // We are partching all loaded modules without forcing them to stay in memory, |
| 231 // removing patches is not safe. | 230 // removing patches is not safe. |
| 232 } | 231 } |
| OLD | NEW |