hw/ide: Add the possibility to disable the CompactFlash device in the build
[qemu/ar7.git] / contrib / plugins / win32_linker.c
blob7534b2b8bf81015b9af3c1e2f1927dc9ae1ac3ed
1 /*
2 * Copyright (C) 2023, Greg Manning <gmanning@rapitasystems.com>
4 * This hook, __pfnDliFailureHook2, is documented in the microsoft documentation here:
5 * https://learn.microsoft.com/en-us/cpp/build/reference/error-handling-and-notification
6 * It gets called when a delay-loaded DLL encounters various errors.
7 * We handle the specific case of a DLL looking for a "qemu.exe",
8 * and give it the running executable (regardless of what it is named).
10 * This work is licensed under the terms of the GNU LGPL, version 2 or later.
11 * See the COPYING.LIB file in the top-level directory.
14 #include <windows.h>
15 #include <delayimp.h>
17 FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli);
20 PfnDliHook __pfnDliFailureHook2 = dll_failure_hook;
22 FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli) {
23 if (dliNotify == dliFailLoadLib) {
24 /* If the failing request was for qemu.exe, ... */
25 if (strcmp(pdli->szDll, "qemu.exe") == 0) {
26 /* Then pass back a pointer to the top level module. */
27 HMODULE top = GetModuleHandle(NULL);
28 return (FARPROC) top;
31 /* Otherwise we can't do anything special. */
32 return 0;