v3: - Introduce a separate syscall dispatcher to be used when the instrumentation callback (which only duplicates a prologue from syscall dispatcher). - Move callback setting to arch specific parts.
I tried to avoid any changes to syscall_dispatcher completely but I didn't find a sane way to do it. Altering return address from __wine_syscall_dispatcher_instrumentation() affects context getting and setting and needs to be fixed up throughout the code. Using CONTEXT_INTEGER won't work because syscall return status is lost this way. This way as now there is just one flag test added for syscall return (that's the only difference the normal path without the callback is hitting) and a few lines of handling the return to callback; the presence of non-NULL callback variable is checked only once only if instrumentation callback is generally enabled.