-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins: make test/example plugins work on windows
Generate a qemu_plugin_api.lib delay import lib on windows, for windows qemu plugins to link against. Implement an example dll load fail hook to link up the API functions correctly when a plugin is loaded on windows. Update the build scripts for the test and example plugins to use these things. Signed-off-by: Greg Manning <gmanning@rapitasystems.com> Acked-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20231102172053.17692-3-gmanning@rapitasystems.com> [AJB: use find_program for dlltool, s/Windows/windows/] Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20231106185112.2755262-15-alex.bennee@linaro.org>
- Loading branch information
Showing
5 changed files
with
83 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (C) 2023, Greg Manning <gmanning@rapitasystems.com> | ||
* | ||
* This hook, __pfnDliFailureHook2, is documented in the microsoft documentation here: | ||
* https://learn.microsoft.com/en-us/cpp/build/reference/error-handling-and-notification | ||
* It gets called when a delay-loaded DLL encounters various errors. | ||
* We handle the specific case of a DLL looking for a "qemu.exe", | ||
* and give it the running executable (regardless of what it is named). | ||
* | ||
* This work is licensed under the terms of the GNU LGPL, version 2 or later. | ||
* See the COPYING.LIB file in the top-level directory. | ||
*/ | ||
|
||
#include <windows.h> | ||
#include <delayimp.h> | ||
|
||
FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli); | ||
|
||
|
||
PfnDliHook __pfnDliFailureHook2 = dll_failure_hook; | ||
|
||
FARPROC WINAPI dll_failure_hook(unsigned dliNotify, PDelayLoadInfo pdli) { | ||
if (dliNotify == dliFailLoadLib) { | ||
/* If the failing request was for qemu.exe, ... */ | ||
if (strcmp(pdli->szDll, "qemu.exe") == 0) { | ||
/* Then pass back a pointer to the top level module. */ | ||
HMODULE top = GetModuleHandle(NULL); | ||
return (FARPROC) top; | ||
} | ||
} | ||
/* Otherwise we can't do anything special. */ | ||
return 0; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters