From: Jinoh Kang jinoh.kang.kr@gmail.com
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/ntdll/tests/exception.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 820e435bc1b..006da0336be 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -4949,6 +4949,7 @@ static void test_syscall_clobbered_regs(void) struct regs { UINT64 rcx; + UINT32 eflags; }; static const BYTE code[] = { @@ -4959,6 +4960,7 @@ static void test_syscall_clobbered_regs(void) 0x48, 0x83, 0xe8, 0x08, /* subq $8,%rax */ 0x48, 0x89, 0x20, /* movq %rsp,0(%rax) */ 0x48, 0x89, 0xc4, /* movq %rax,%rsp */ + 0xfd, /* std */ 0x41, 0x50, /* push %r8 */ 0x53, 0x55, 0x57, 0x56, 0x41, 0x54, 0x41, 0x55, 0x41, 0x56, 0x41, 0x57, /* push %rbx, %rbp, %rdi, %rsi, %r12, %r13, %r14, %r15 */ @@ -4967,12 +4969,17 @@ static void test_syscall_clobbered_regs(void) /* pop %r15, %r14, %r13, %r12, %rsi, %rdi, %rbp, %rbx */ 0x41, 0x58, /* pop %r8 */ 0x49, 0x89, 0x48, 0x00, /* mov %rcx,(%r8) */ + 0x9c, /* pushfq */ + 0x59, /* pop %rcx */ + 0xfc, /* cld */ + 0x41, 0x89, 0x48, 0x08, /* mov %ecx,0x8(%r8) */ 0x5c, /* pop %rsp */ 0xc3, /* ret */ };
NTSTATUS (WINAPI *func)(void *arg1, void *arg2, struct regs *, void *call_addr); NTSTATUS (WINAPI *pNtCancelTimer)(HANDLE, BOOLEAN *); + NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(DWORD, const HANDLE *, BOOLEAN, BOOLEAN, const LARGE_INTEGER *); HMODULE hntdll = GetModuleHandleA("ntdll.dll"); struct regs regs; CONTEXT context; @@ -4985,6 +4992,7 @@ static void test_syscall_clobbered_regs(void) memset(®s, 0, sizeof(regs)); status = func((HANDLE)0xdeadbeef, NULL, ®s, pNtCancelTimer); ok(status == STATUS_INVALID_HANDLE, "Got unexpected status %#lx.\n", status); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
/* After the syscall instruction rcx contains the address of the instruction next after syscall. */ ok((BYTE *)regs.rcx > (BYTE *)pNtCancelTimer && (BYTE *)regs.rcx < (BYTE *)pNtCancelTimer + 0x20, @@ -4994,28 +5002,42 @@ static void test_syscall_clobbered_regs(void) ok(status == STATUS_ACCESS_VIOLATION, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtCancelTimer && (BYTE *)regs.rcx < (BYTE *)pNtCancelTimer + 0x20, "Got unexpected rcx %s, pNtCancelTimer %p.\n", wine_dbgstr_longlong(regs.rcx), pNtCancelTimer); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags); + + pNtWaitForMultipleObjects = (void *)GetProcAddress(hntdll, "NtWaitForMultipleObjects"); + ok(!!pNtWaitForMultipleObjects, "NtWaitForMultipleObjects not found.\n"); + status = func((DWORD)0, (HANDLE *)NULL, ®s, pNtWaitForMultipleObjects); + ok(status == STATUS_INVALID_PARAMETER_1, "Got unexpected status %#lx.\n", status); + ok((BYTE *)regs.rcx > (BYTE *)pNtWaitForMultipleObjects && (BYTE *)regs.rcx < (BYTE *)pNtWaitForMultipleObjects + 0x20, + "Got unexpected rcx %s, pNtWaitForMultipleObjects %p.\n", wine_dbgstr_longlong(regs.rcx), pNtWaitForMultipleObjects); + todo_wine + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
context.ContextFlags = CONTEXT_CONTROL; status = func(GetCurrentThread(), &context, ®s, pNtGetContextThread); ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtGetContextThread && (BYTE *)regs.rcx < (BYTE *)pNtGetContextThread + 0x20, "Got unexpected rcx %s, pNtGetContextThread %p.\n", wine_dbgstr_longlong(regs.rcx), pNtGetContextThread); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
status = func(GetCurrentThread(), &context, ®s, pNtSetContextThread); ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtGetContextThread && (BYTE *)regs.rcx < (BYTE *)pNtGetContextThread + 0x20, "Got unexpected rcx %s, pNtGetContextThread %p.\n", wine_dbgstr_longlong(regs.rcx), pNtGetContextThread); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
context.ContextFlags = CONTEXT_INTEGER; status = func(GetCurrentThread(), &context, ®s, pNtGetContextThread); ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtGetContextThread && (BYTE *)regs.rcx < (BYTE *)pNtGetContextThread + 0x20, "Got unexpected rcx %s, pNtGetContextThread %p.\n", wine_dbgstr_longlong(regs.rcx), pNtGetContextThread); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
status = func(GetCurrentThread(), &context, ®s, pNtSetContextThread); ok(status == STATUS_SUCCESS, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtSetContextThread && (BYTE *)regs.rcx < (BYTE *)pNtSetContextThread + 0x20, "Got unexpected rcx %s, pNtSetContextThread %p.\n", wine_dbgstr_longlong(regs.rcx), pNtSetContextThread); + ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
} #elif defined(__arm__)
From: Jinoh Kang jinoh.kang.kr@gmail.com
Signed-off-by: Jinoh Kang jinoh.kang.kr@gmail.com --- dlls/ntdll/tests/exception.c | 1 - dlls/ntdll/unix/signal_x86_64.c | 10 ++++++---- 2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 006da0336be..9f4477a4da1 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -5010,7 +5010,6 @@ static void test_syscall_clobbered_regs(void) ok(status == STATUS_INVALID_PARAMETER_1, "Got unexpected status %#lx.\n", status); ok((BYTE *)regs.rcx > (BYTE *)pNtWaitForMultipleObjects && (BYTE *)regs.rcx < (BYTE *)pNtWaitForMultipleObjects + 0x20, "Got unexpected rcx %s, pNtWaitForMultipleObjects %p.\n", wine_dbgstr_longlong(regs.rcx), pNtWaitForMultipleObjects); - todo_wine ok((regs.eflags & 0x400) != 0, "Expected direction flag to be set in EFLAGS (%#x).\n", regs.eflags);
context.ContextFlags = CONTEXT_CONTROL; diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 6c87e347eac..87ff148a628 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -3415,13 +3415,15 @@ __ASM_GLOBAL_FUNC( __wine_syscall_dispatcher, "movq 0x28(%rcx),%rdi\n\t" "movq 0x20(%rcx),%rsi\n\t" "movq 0x08(%rcx),%rbx\n\t" + "leaq 0x70(%rcx),%rsp\n\t" "testl $0x3,%edx\n\t" /* CONTEXT_CONTROL | CONTEXT_INTEGER */ "jnz 1f\n\t" - "movq 0x88(%rcx),%rsp\n\t" - "movq 0x70(%rcx),%rcx\n\t" /* frame->rip */ + "pop %rcx\n\t" /* frame->rip */ + "add $8,%rsp\n\t" + "popfq\n\t" + "pop %rsp\n\t" "jmpq *%rcx\n\t" - "1:\tleaq 0x70(%rcx),%rsp\n\t" - "testl $0x2,%edx\n\t" /* CONTEXT_INTEGER */ + "1:\ttestl $0x2,%edx\n\t" /* CONTEXT_INTEGER */ "jnz 1f\n\t" "movq (%rsp),%rcx\n\t" /* frame->rip */ "iretq\n"