[2/3] Don't send EXCEPTION_EXECUTE_FAULT to Windows programs that didn't enable DEP (try 4).
Michael Karcher
wine at mkarcher.dialup.fu-berlin.de
Mon Aug 17 18:20:53 CDT 2009
This is what Windows does, too. If Data Execution Prevention is not enabled
for a process, Windows does not use the EXCEPTION_EXECUTE_FAULT flag, as
the program might be incompatible with it and expect EXCEPTION_READ_FAULT.
This fixes the non-functional single-stepping in Delphi,
as reported for example in
http://appdb.winehq.org/objectManager.php?sClass=version&iId=22&iTestingId=10795
try 4: call NtQueryInformationProcess only on execute faults
---
dlls/ntdll/signal_i386.c | 10 ++++++++++
dlls/ntdll/tests/exception.c | 6 +-----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index d0e0172..eddd595 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -1833,6 +1833,16 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
rec->ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec->NumberParameters = 2;
rec->ExceptionInformation[0] = (get_error_code(context) >> 1) & 0x09;
+ /* Send code 8 (EXCEPTION_EXECUTE_FAULT) only if data execution
+ prevention is enabled */
+ if (rec->ExceptionInformation[0] & 8);
+ {
+ ULONG ExecuteFlags;
+ NtQueryInformationProcess(GetCurrentProcess(), ProcessExecuteFlags,
+ &ExecuteFlags, sizeof ExecuteFlags, NULL);
+ if (!(ExecuteFlags & MEM_EXECUTE_OPTION_DISABLE))
+ rec->ExceptionInformation[0] &= 1;
+ }
rec->ExceptionInformation[1] = (ULONG_PTR)siginfo->si_addr;
break;
case TRAP_x86_ALIGNFLT: /* Alignment check exception */
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index d0b85f6..f3f61e3 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -1053,11 +1053,7 @@ static void test_dpe_exceptions(void)
info.exception_caught = FALSE;
run_exception_test(dpe_exception_handler, &info, single_ret, sizeof(single_ret), PAGE_NOACCESS);
ok(info.exception_caught == TRUE, "Execution of disabled memory suceeded\n");
- if(has_hw_support)
- todo_wine ok(info.exception_info == EXCEPTION_READ_FAULT,
- "Access violation type: %08x\n", (unsigned)info.exception_info);
- else
- ok(info.exception_info == EXCEPTION_READ_FAULT,
+ ok(info.exception_info == EXCEPTION_READ_FAULT,
"Access violation type: %08x\n", (unsigned)info.exception_info);
}
else
--
1.6.3.3
More information about the wine-patches
mailing list