https://bugs.winehq.org/show_bug.cgi?id=53682
--- Comment #6 from Kevin Puetz PuetzKevinA@JohnDeere.com --- Created attachment 73231 --> https://bugs.winehq.org/attachment.cgi?id=73231 Working patch
Here's a maybe-less-hacky patch based on your initial approach, but taken farther. This actually does get wineboot to succeed and cmd.exe will launch; haven't tested it further than that yet.
I changed it so the __wine_jmp_buf and NTSTATUS belong to KeUserModeCallback, and are passed in (and represented in the user_callback_frame) as pointers so we don't have to deep-copy anything. This actually makes them a bit more consistent the usage pattern of ret_ptr and ret_len in NtCallbackReturn, so that part seems OK.
I was then getting SIGBUS errors due to the stack not being properly aligned; I thought this was due to call_user_mode_callback lacking WINAPI, but that didn't help (I add it though, since that seems right; KeUserModeCallback had it). It turns out the actual reason is that it was the __wine_jmpbuf that had been giving user_callback_frame its alignment, and with that gone the compiler didn't see any reason to. the syscall_frame becomes $sp, so it has its own reason to need 16 byte alignment, so I added that DECLSPEC_ALIGN.
I think my fudging of the STATUS_STACK_OVERFLOW path is probably still dubious, but all it was really checking before was "some pointer on the stack of KeUserModeCallback", since we already know &callback_frame wasn't actually the bottom of that stack frame. Suggestions welcome.