Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1069)

Side by Side Diff: base/debug/close_handle_hook_win.cc

Issue 1580873003: Enable handle verifier for tests and add some tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not copy variable up scope Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/base.gyp ('k') | base/test/test_suite.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/debug/close_handle_hook_win.h" 5 #include "base/debug/close_handle_hook_win.h"
6 6
7 #include <Windows.h> 7 #include <Windows.h>
8 #include <psapi.h> 8 #include <psapi.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
11 #include <algorithm> 11 #include <algorithm>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/lazy_instance.h" 14 #include "base/lazy_instance.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/scoped_ptr.h" 16 #include "base/memory/scoped_ptr.h"
17 #include "base/win/iat_patch_function.h" 17 #include "base/win/iat_patch_function.h"
18 #include "base/win/pe_image.h" 18 #include "base/win/pe_image.h"
19 #include "base/win/scoped_handle.h" 19 #include "base/win/scoped_handle.h"
20 #include "base/win/windows_version.h"
20 #include "build/build_config.h" 21 #include "build/build_config.h"
21 22
22 namespace { 23 namespace {
23 24
24 typedef BOOL (WINAPI* CloseHandleType) (HANDLE handle); 25 typedef BOOL (WINAPI* CloseHandleType) (HANDLE handle);
25 26
26 typedef BOOL (WINAPI* DuplicateHandleType)(HANDLE source_process, 27 typedef BOOL (WINAPI* DuplicateHandleType)(HANDLE source_process,
27 HANDLE source_handle, 28 HANDLE source_handle,
28 HANDLE target_process, 29 HANDLE target_process,
29 HANDLE* target_handle, 30 HANDLE* target_handle,
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 returned = std::min(kSize, returned); 253 returned = std::min(kSize, returned);
253 254
254 for (DWORD current = 0; current < returned; current++) { 255 for (DWORD current = 0; current < returned; current++) {
255 hooks->AddIATPatch(modules[current]); 256 hooks->AddIATPatch(modules[current]);
256 } 257 }
257 } 258 }
258 259
259 } // namespace 260 } // namespace
260 261
261 void InstallHandleHooks() { 262 void InstallHandleHooks() {
263 #if !defined(DISABLE_HANDLE_VERIFIER_HOOKS)
264 #if defined(_DEBUG)
265 // Handle hooks cause shutdown asserts in Debug on Windows 7. crbug.com/571304
266 if (base::win::GetVersion() < base::win::VERSION_WIN8)
267 return;
268 #endif
262 HandleHooks* hooks = g_hooks.Pointer(); 269 HandleHooks* hooks = g_hooks.Pointer();
263 270
264 // Performing EAT interception first is safer in the presence of other 271 // Performing EAT interception first is safer in the presence of other
265 // threads attempting to call CloseHandle. 272 // threads attempting to call CloseHandle.
266 hooks->AddEATPatch(); 273 hooks->AddEATPatch();
267 PatchLoadedModules(hooks); 274 PatchLoadedModules(hooks);
275 #endif
268 } 276 }
269 277
270 void RemoveHandleHooks() { 278 void RemoveHandleHooks() {
271 // We are partching all loaded modules without forcing them to stay in memory, 279 // We are partching all loaded modules without forcing them to stay in memory,
272 // removing patches is not safe. 280 // removing patches is not safe.
273 } 281 }
274 282
275 } // namespace debug 283 } // namespace debug
276 } // namespace base 284 } // namespace base
OLDNEW
« no previous file with comments | « base/base.gyp ('k') | base/test/test_suite.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698