Similar to 4e4847dd71 which disabled writes to fs and gs register in "cleared segment registers" test: https://bugs.winehq.org/show_bug.cgi?id=51152
Followup to 03fe2b36cd.
From: Bernhard Übelacker bernhardu@mailbox.org
Similar to 4e4847dd71 which disabled writes to fs and gs register in "cleared segment registers" test: https://bugs.winehq.org/show_bug.cgi?id=51152
Followup to 03fe2b36cd. --- dlls/ntdll/tests/exception.c | 49 ++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+)
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c index 025923b7d8e..7da6d3a1cf0 100644 --- a/dlls/ntdll/tests/exception.c +++ b/dlls/ntdll/tests/exception.c @@ -9453,6 +9453,12 @@ static void test_debuggee_segments(void) { void (CDECL *func)(void) = code_mem;
+ if (GetEnvironmentVariableA("AVOID_FS_GS_WRITE", NULL, 0)) + { + skip("Processes modifying fs/gs registers are crashing, skipping test.\n"); + return; + } + memcpy( code_mem, except_code_segments, sizeof(except_code_segments)); func(); } @@ -12068,6 +12074,42 @@ static void test_context_exception_request(void) CloseHandle( p.event ); }
+static void fs_gs_write(void) +{ + __asm__( + "mov %fs,%eax; " + "mov %eax,%fs; " + "mov %gs,%eax; " + "mov %eax,%gs" + ); + trace("Wrote to fs and gs registers.\n"); +} + +static void fs_gs_write_check(void) +{ + char **argv; + char cmdline[MAX_PATH]; + STARTUPINFOA si = {.cb = sizeof(si)}; + PROCESS_INFORMATION pi; + DWORD ret; + + if (!winetest_platform_is_wine) + return; + + winetest_get_mainargs(&argv); + sprintf(cmdline, "%s exception fs_gs_write", argv[0]); + ret = CreateProcessA(NULL, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi); + ok(ret, "Failed to create target process.\n"); + + WaitForSingleObject(pi.hProcess, 30000); + ok(GetExitCodeProcess(pi.hProcess, &ret), "GetExitCodeProcess failed.\n"); + if (ret) + SetEnvironmentVariableA("AVOID_FS_GS_WRITE", "1"); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); +} + START_TEST(exception) { HMODULE hkernel32 = GetModuleHandleA("kernel32.dll"); @@ -12081,6 +12123,12 @@ START_TEST(exception) return; }
+ if (my_argc >= 3 && !strcmp(my_argv[2], "fs_gs_write")) + { + fs_gs_write(); + return; + } + code_mem = VirtualAlloc(NULL, 65536, MEM_RESERVE | MEM_COMMIT, PAGE_EXECUTE_READWRITE); if(!code_mem) { trace("VirtualAlloc failed\n"); @@ -12333,6 +12381,7 @@ START_TEST(exception) test_KiUserApcDispatcher(); test_KiUserCallbackDispatcher(); test_rtlraiseexception(); + fs_gs_write_check(); test_debugger(DBG_EXCEPTION_HANDLED, FALSE); test_debugger(DBG_CONTINUE, FALSE); test_debugger(DBG_EXCEPTION_HANDLED, TRUE);