[PATCH 1/2] ntdll/tests: Add a test for segment register contents in x86_64 exception handlers.

Zebediah Figura z.figura12 at gmail.com
Wed Mar 24 22:47:54 CDT 2021


Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/ntdll/tests/exception.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index da88ca449fb..e2a8071168d 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -2812,7 +2812,7 @@ static void test___C_specific_handler(void)
 /* This is heavily based on the i386 exception tests. */
 static const struct exception
 {
-    BYTE     code[18];      /* asm code */
+    BYTE     code[24];      /* asm code */
     BYTE     offset;        /* offset of faulting instruction */
     BYTE     length;        /* length of faulting instruction */
     NTSTATUS status;        /* expected status code */
@@ -2921,6 +2921,14 @@ static const struct exception
 /* 35 */
     { { 0xa3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xc3 },  /* movl %eax,0xffffffffffffffff; ret */
       0, 9, STATUS_ACCESS_VIOLATION, 2, { 1, 0xffffffffffffffff } },
+
+    /* test exception with cleared %ds and %es */
+    { { 0x8c, 0xd8, 0x50, 0x8c, 0xc0, 0x50, 0x31, 0xc0, 0x8e, 0xd8, 0x8e, 0xc0,
+        0xfa, 0x58, 0x8e, 0xc0, 0x58, 0x8e, 0xd8, 0xc3 },
+          /* mov %ds,%eax; pushq %rax; mov %es,%eax; pushq %rax; xorl %eax,%eax; mov %eax,%ds; mov %eax,%es;
+           * cli; popq %rax; mov %eax,%es; popq %rax; mov %eax,%ds; ret */
+      12, 1, STATUS_PRIVILEGED_INSTRUCTION, 0 },
+
     { { 0xf1, 0x90, 0xc3 },  /* icebp; nop; ret */
       1, 1, STATUS_SINGLE_STEP, 0 },
     { { 0xcd, 0x2c, 0xc3 },
@@ -2992,6 +3000,9 @@ static DWORD WINAPI handler( EXCEPTION_RECORD *rec, ULONG64 frame,
         "%u: Unexpected exception address %p/%p\n", entry,
         rec->ExceptionAddress, (char*)context->Rip );
 
+    todo_wine ok( context->SegDs == context->SegSs,
+        "%u: ds %#x does not match ss %#x\n", entry, context->SegDs, context->SegSs );
+
     if (except->status == STATUS_BREAKPOINT && is_wow64)
         parameter_count = 1;
     else if (except->alt_status == 0 || rec->ExceptionCode != except->alt_status)
-- 
2.30.2




More information about the wine-devel mailing list