[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 14/22] plugins: make test/example plugins work on windows
From: |
Greg Manning |
Subject: |
Re: [PATCH 14/22] plugins: make test/example plugins work on windows |
Date: |
Tue, 7 Nov 2023 12:43:06 +0000 |
> > A bit more important: would it make sense to include the hook *in the
> > QEMU executable itself*, rather than in the DLL? If it works, it would
> > be much preferrable. You still would have to add the .lib file to the
> > compilation, but win32_linker.c could simply be placed in os-win32.c
> > with fewer changes to meson.build and the makefiles.
> My initial trials of this didn't work. But having read the docs again, I'm
> going to have another go at it now...
Here is a diagram of what's going on.
/---dynamic load------v
qemu libplugin.dll
^---delay load--------/
First, qemu dynamically loads the plugin, which does no linking. It finds
the function qemu_plugin_install, and invokes it. As soon as libplugin.dll
calls any qemu_plugin_* function, the delay loader steps in and searches for
qemu.exe. It fails to find it, and the delay failure helper steps in and
returns the right reference to the top level executable. Everything gets
linked OK.
Windows will look for __pfnDliFailureHook2 in the module doing the delay
loading, which in this case is the plugin DLL. So, the __pfnDliFailureHook2
function pointer needs to be in the plugin DLL. We could have qemu set the
value of that pointer before it calls install, but I can't find the way to
expose a function pointer in such a way that `g_module_symbol` can find it.
Possibly we could pass in a pointer to it in qemu_plugin_install or a new
qemu_plugin_set_linker_fn, but that is getting back to the sort of
shenanigans we're trying to avoid, and which previous attempts at windows
plugins were based on.
so: maybe, but I'm not sure it would be any tidier.
Greg.
--
Follow Rapita Systems on
LinkedIn<https://www.linkedin.com/company/rapita-systems?utm_source=rs_email_sig>
- Re: [PATCH 08/22] gdbstub: Add num_regs member to GDBFeature, (continued)
[PATCH 10/22] gdbstub: Introduce GDBFeatureBuilder, Alex Bennée, 2023/11/06
[PATCH 07/22] tests/avocado: update the tcg_plugins test, Alex Bennée, 2023/11/06
[PATCH 06/22] tests/tcg: add an explicit gdbstub register tester, Alex Bennée, 2023/11/06
[PATCH 09/22] gdbstub: Introduce gdb_find_static_feature(), Alex Bennée, 2023/11/06
[PATCH 14/22] plugins: make test/example plugins work on windows, Alex Bennée, 2023/11/06
[PATCH 12/22] configure: tell meson and contrib_plugins about DLLTOOL, Alex Bennée, 2023/11/06
[PATCH 11/22] cpu: Call plugin hooks only when ready, Alex Bennée, 2023/11/06
[PATCH 13/22] plugins: add dllexport and dllimport to api funcs, Alex Bennée, 2023/11/06
[PATCH 21/22] mailmap: fixup some more corrupted author fields, Alex Bennée, 2023/11/06
[PATCH 20/22] contrib/gitdm: add Daynix to domain-map, Alex Bennée, 2023/11/06