blob: 108de03ae5c0382926457b664b086e1b82203c8c [file] [log] [blame]
Avi Drissmane4622aa2022-09-08 20:36:061// Copyright 2015 The Chromium Authors
Will Harrisd4b45e02022-05-21 00:30:482// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_DEBUG_HANDLE_HOOKS_WIN_H_
6#define BASE_DEBUG_HANDLE_HOOKS_WIN_H_
7
8#include "base/base_export.h"
9#include "base/win/windows_types.h"
10#include "build/build_config.h"
11
12namespace base {
13namespace debug {
14
15// Provides the ability to intercept functions which could possibly close
16// handles in support of the handle tracker.
17// This is a currently a container class for static functions because there is
18// ongoing work to make the patches unhook, currently blocked by test failures.
19// See https://crbug.com/1327397.
20class BASE_EXPORT HandleHooks {
21 public:
22 HandleHooks() = delete;
23
24 HandleHooks(const HandleHooks&) = delete;
25 HandleHooks& operator=(const HandleHooks&) = delete;
26
27 // Patch IAT for a specified module.
28 static void AddIATPatch(HMODULE module);
29 // Add an EAT patch on kernel32.dll. This patch does not get removed. This is
30 // only supported on 32-bit because the EAT only supports 32-bit RVAs.
31#if defined(ARCH_CPU_32_BITS)
32 static void AddEATPatch();
33#endif
34 // Patch IAT for all currently loaded modules.
35 static void PatchLoadedModules();
36};
37
38} // namespace debug
39} // namespace base
40
41#endif // BASE_DEBUG_HANDLE_HOOKS_WIN_H_