1 // Copyright 2022 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/app/delay_load_failure_hook_win.h"
7 // windows.h needs to be included before delayimp.h.
12 #include "chrome/common/win/delay_load_failure_support.h"
18 bool g_hooks_enabled = true;
20 // Delay load failure hook that generates a crash report. By default a failure
21 // to delay load will trigger an exception handled by the delay load runtime and
22 // this won't generate a crash report.
23 FARPROC WINAPI DelayLoadFailureHookEXE(unsigned reason,
24 DelayLoadInfo* dll_info) {
28 return HandleDelayLoadFailureCommon(reason, dll_info);
33 void DisableDelayLoadFailureHooksForMainExecutable() {
34 g_hooks_enabled = false;
39 // Set the delay load failure hook to the function above.
41 // The |__pfnDliFailureHook2| failure notification hook gets called
42 // automatically by the delay load runtime in case of failure, see
43 // https://docs.microsoft.com/en-us/cpp/build/reference/failure-hooks?view=vs-2019
44 // for more information about this.
45 extern "C" const PfnDliHook __pfnDliFailureHook2 =
46 chrome::DelayLoadFailureHookEXE;