[PATCH 0/1] MR688: ntdll: Introduce "WINEWOW64" environment variable, to enable new WoW64 behavior.
From: "Huw D. M. Davies" <huw(a)codeweavers.com> https://www.winehq.org/pipermail/wine-devel/2022-April/213620.html Co-authored-by: Davide Beatrici <git(a)davidebeatrici.dev> --- dlls/ntdll/loader.c | 11 ++++++++++- dlls/ntdll/unix/env.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c index 043bce67ea9..1b706c14b04 100644 --- a/dlls/ntdll/loader.c +++ b/dlls/ntdll/loader.c @@ -1572,7 +1572,16 @@ static NTSTATUS MODULE_InitDLL( WINE_MODREF *wm, UINT reason, LPVOID lpReserved if (wm->ldr.Flags & LDR_DONT_RESOLVE_REFS) return STATUS_SUCCESS; if (wm->ldr.TlsIndex != -1) call_tls_callbacks( wm->ldr.DllBase, reason ); if (wm->ldr.Flags & LDR_WINE_INTERNAL && reason == DLL_PROCESS_ATTACH) - unix_funcs->init_builtin_dll( wm->ldr.DllBase ); + { + UNICODE_STRING name, value = { 0 }; + + RtlInitUnicodeString( &name, L"WINEWOW64" ); + if (RtlQueryEnvironmentVariable_U( NULL, &name, &value ) != STATUS_VARIABLE_NOT_FOUND) + TRACE("WINEWOW64 env var found, not calling init_builtin_dll()\n"); + else + unix_funcs->init_builtin_dll( wm->ldr.DllBase ); + } + if (!entry) return STATUS_SUCCESS; if (TRACE_ON(relay)) diff --git a/dlls/ntdll/unix/env.c b/dlls/ntdll/unix/env.c index 105038a34cb..dc9a2adf9a3 100644 --- a/dlls/ntdll/unix/env.c +++ b/dlls/ntdll/unix/env.c @@ -1929,7 +1929,17 @@ static RTL_USER_PROCESS_PARAMETERS *build_initial_params( void **module ) if (!status) { if (main_image_info.ImageCharacteristics & IMAGE_FILE_DLL) status = STATUS_INVALID_IMAGE_FORMAT; - if (main_image_info.Machine != current_machine) status = STATUS_INVALID_IMAGE_FORMAT; + if (main_image_info.Machine != current_machine) + { + static const WCHAR wow64W[] = {'W','I','N','E','W','O','W','6','4'}; + + if (find_env_var( env, env_pos, wow64W, ARRAY_SIZE(wow64W) )) + TRACE("WINEWOW64 env var found, ignoring arch mismatch (current: %04x, image: %04x)\n", + current_machine, + main_image_info.Machine); + else + status = STATUS_INVALID_IMAGE_FORMAT; + } } if (status) /* try launching it through start.exe */ -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/688
Once this is merged it would be great to perform WoW64 testing on CI, to prevent bugs such as the one fixed in !687. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_6616
Jacek has something similar in https://gitlab.winehq.org/jacek/wine/-/commits/wow -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_6630
Oh, interesting: jacek/wine(a)7ad8beb02f02b7f27be44f3ef136c680d527ea74 His approach is less verbose than mine and he wrote a dedicated function to get the environment variable (`WINEWOW` in his case). I decided not to do that as it's meant to be temporary code, the smaller the footprint the better. However, I'm also noticing the changes to `loader.c` are completely different compared to mine. I initially assumed it was to make WoW64 work when running Wine directly from the build tree, but the commit message explicitly states the method is not supported yet. @jacek Could you explain, please? -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_6634
An update would be helpful. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_8167
On Sat Sep 10 18:21:34 2022 +0000, Davide Beatrici wrote:
Once this is merged it would be great to perform WoW64 testing on CI, to prevent bugs such as the one fixed in !687. Note that WOW64 path and non-WOW64 path has different TODOs; some existing `todo_wine`s will succeed unexpectedly on the wow64 build.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_8168
On Sat Sep 10 18:21:33 2022 +0000, Jinoh Kang wrote:
Note that WOW64 path and non-WOW64 path has different TODOs; some existing `todo_wine`s will succeed unexpectedly on the wow64 build. This patch is not really enough to enable wow64 testing on CI, it will need more complete support. We're getting there, but there is still more work needed for that.
That said, while making testing easier sounds nice, it would be more interesting so have something closer to the final solution. I don't know yet how those parts will look like exactly yet, but ntdll will need to take into account things like running from build tree and proper wow64 build system support (and build system part will probably be nicer to work with once we can get rid of -mcygwin modules, which is still needed for opengl32.dll). While we can probably have a way to enable wow64 before it's all fully implemented, I think this needs more consideration to make sure it all fits. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_8206
On Mon Sep 12 10:13:46 2022 +0000, Jacek Caban wrote:
This patch is not really enough to enable wow64 testing on CI, it will need more complete support. We're getting there, but there is still more work needed for that. That said, while making testing easier sounds nice, it would be more interesting so have something closer to the final solution. I don't know yet how those parts will look like exactly yet, but ntdll will need to take into account things like running from build tree and proper wow64 build system support (and build system part will probably be nicer to work with once we can get rid of -mcygwin modules, which is still needed for opengl32.dll). While we can probably have a way to enable wow64 before it's all fully implemented, I think this needs more consideration to make sure it all fits. WoW64 support when running from build tree is definitely very important, especially for developers; when working on the audio drivers I basically have to perform a `make install` for 32 bit and then 64 bit every time I want to test a change.
Feel free to take over this merge request, as I'm not too familiar with the overall WoW64 progress. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_8269
Closing for now, this needs more thought. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688#note_8314
This merge request was closed by Alexandre Julliard. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/688
participants (7)
-
Alexandre Julliard (@julliard) -
Davide Beatrici (@davidebeatrici) -
Huw D. M. Davies -
Huw Davies (@huw) -
Jacek Caban (@jacek) -
Jinoh Kang (@iamahuman) -
Olivia/Isabelle Mahadevan (@doubledge-spec)