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__)