[PATCH 0/3] MR327: ntdll/tests: Tests for bug 53270.
I don't know how to fix the bug itself, though. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/327
From: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/ntdll/tests/exception.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 820e435bc1b..86f2f5d6cb2 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8784,7 +8784,27 @@ static void test_user_apc(void) pass = 0; InterlockedIncrement(&pass); +#ifdef __i386__ + { + /* RtlCaptureContext puts the return address of the caller's stack + * frame into %eip, so we need a thunk to get it to return here */ + static const BYTE code[] = + { + 0x55, /* pushl %ebp */ + 0x89, 0xe5, /* movl %esp, %ebp */ + 0xff, 0x75, 0x0c, /* pushl 0xc(%ebp) */ + 0xff, 0x55, 0x08, /* call *0x8(%ebp) */ + 0xc9, /* leave */ + 0xc3, /* ret */ + }; + void (__cdecl *func)(void *capture, CONTEXT *context) = code_mem; + + memcpy(code_mem, code, sizeof(code)); + func(RtlCaptureContext, &context); + } +#else RtlCaptureContext(&context); +#endif InterlockedIncrement(&pass); if (pass == 2) -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/327
From: Zebediah Figura <zfigura(a)codeweavers.com> --- dlls/ntdll/tests/exception.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 86f2f5d6cb2..748ee0e52ee 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8801,6 +8801,9 @@ static void test_user_apc(void) memcpy(code_mem, code, sizeof(code)); func(RtlCaptureContext, &context); + /* work around broken RtlCaptureContext on Windows < 7 which doesn't set + * ContextFlags */ + context.ContextFlags = CONTEXT_FULL; } #else RtlCaptureContext(&context); @@ -8824,8 +8827,7 @@ static void test_user_apc(void) ok(!status, "Got unexpected status %#lx.\n", status); status = NtContinue(&c[0], TRUE ); - /* Broken before Win7, in that case NtContinue returns here instead of restoring context after calling APC. */ - ok(broken(TRUE), "Should not get here, status %#lx.\n", status); + ok(0, "Should not get here, status %#lx.\n", status); return; } ok(pass == 3, "Got unexpected pass %ld.\n", pass); -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/327
From: Zebediah Figura <zfigura(a)codeweavers.com> This is currently broken on WoW64. --- dlls/ntdll/tests/exception.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 748ee0e52ee..753a44c769b 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -8775,6 +8775,7 @@ static void test_user_apc(void) NTSTATUS status; CONTEXT context; LONG pass; + int ret; if (!pNtQueueApcThread) { @@ -8797,16 +8798,20 @@ static void test_user_apc(void) 0xc9, /* leave */ 0xc3, /* ret */ }; - void (__cdecl *func)(void *capture, CONTEXT *context) = code_mem; + int (__cdecl *func)(void *capture, CONTEXT *context) = code_mem; memcpy(code_mem, code, sizeof(code)); - func(RtlCaptureContext, &context); + ret = func(RtlCaptureContext, &context); /* work around broken RtlCaptureContext on Windows < 7 which doesn't set * ContextFlags */ context.ContextFlags = CONTEXT_FULL; } #else - RtlCaptureContext(&context); + { + int (WINAPI *func)(CONTEXT *context) = (void *)RtlCaptureContext; + + ret = func(&context); + } #endif InterlockedIncrement(&pass); @@ -8815,6 +8820,16 @@ static void test_user_apc(void) /* Try to make sure context data is far enough below context.Esp. */ CONTEXT c[4]; +#ifdef __i386__ + context.Eax = 0xabacab; +#elif defined(__x86_64__) + context.Rax = 0xabacab; +#elif defined(__arm__) + context.R0 = 0xabacab; +#elif defined(__aarch64__) + context.X0 = 0xabacab; +#endif + c[0] = context; test_apc_called = FALSE; @@ -8830,6 +8845,7 @@ static void test_user_apc(void) ok(0, "Should not get here, status %#lx.\n", status); return; } + ok(ret == 0xabacab, "Got return value %#x.\n", ret); ok(pass == 3, "Got unexpected pass %ld.\n", pass); ok(test_apc_called, "Test user APC was not called.\n"); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/327
participants (2)
-
Zebediah Figura -
Zebediah Figura (@zfigura)