Alexandre Julliard : ntdll: Fixed some exception codes and parameters.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Mar 14 07:25:27 CDT 2007
Module: wine
Branch: master
Commit: cdb833bf33f319d5063d9d548dce415bd81ce79b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=cdb833bf33f319d5063d9d548dce415bd81ce79b
Author: Alexandre Julliard <julliard at winehq.org>
Date: Wed Mar 14 12:02:43 2007 +0100
ntdll: Fixed some exception codes and parameters.
---
dlls/ntdll/signal_i386.c | 17 +++++++++--------
dlls/ntdll/tests/exception.c | 2 +-
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/dlls/ntdll/signal_i386.c b/dlls/ntdll/signal_i386.c
index edfa5ea..df7b517 100644
--- a/dlls/ntdll/signal_i386.c
+++ b/dlls/ntdll/signal_i386.c
@@ -772,7 +772,7 @@ void set_cpu_context( const CONTEXT *context )
* Check if the fault location is a privileged instruction.
* Based on the instruction emulation code in dlls/kernel/instr.c.
*/
-static inline int is_privileged_instr( CONTEXT86 *context )
+static inline DWORD is_privileged_instr( CONTEXT86 *context )
{
const BYTE *instr;
unsigned int prefix_count = 0;
@@ -794,7 +794,7 @@ static inline int is_privileged_instr( CONTEXT86 *context )
case 0xf0: /* lock */
case 0xf2: /* repne */
case 0xf3: /* repe */
- if (++prefix_count >= 15) return 0;
+ if (++prefix_count >= 15) return EXCEPTION_ILLEGAL_INSTRUCTION;
instr++;
continue;
@@ -805,7 +805,7 @@ static inline int is_privileged_instr( CONTEXT86 *context )
case 0x21: /* mov drX, reg */
case 0x22: /* mov reg, crX */
case 0x23: /* mov reg drX */
- return 1;
+ return EXCEPTION_PRIV_INSTRUCTION;
}
return 0;
case 0x6c: /* insb (%dx) */
@@ -824,7 +824,7 @@ static inline int is_privileged_instr( CONTEXT86 *context )
case 0xf4: /* hlt */
case 0xfa: /* cli */
case 0xfb: /* sti */
- return 1;
+ return EXCEPTION_PRIV_INSTRUCTION;
default:
return 0;
}
@@ -1144,16 +1144,17 @@ static void segv_handler( int signal, siginfo_t *siginfo, void *sigcontext )
case TRAP_x86_SEGNPFLT: /* Segment not present exception */
case TRAP_x86_PROTFLT: /* General protection fault */
case TRAP_x86_UNKNOWN: /* Unknown fault code */
- if (!get_error_code(context) && is_privileged_instr( get_exception_context(rec) ))
- rec->ExceptionCode = EXCEPTION_PRIV_INSTRUCTION;
- else
{
WORD err = get_error_code(context);
+ if (!err && (rec->ExceptionCode = is_privileged_instr( get_exception_context(rec) ))) break;
rec->ExceptionCode = EXCEPTION_ACCESS_VIOLATION;
rec->NumberParameters = 2;
rec->ExceptionInformation[0] = 0;
/* if error contains a LDT selector, use that as fault address */
- rec->ExceptionInformation[1] = (err & 7) == 4 ? (err & ~7) : 0xffffffff;
+ if ((err & 7) == 4 && !wine_ldt_is_system( err | 7 ))
+ rec->ExceptionInformation[1] = err & ~7;
+ else
+ rec->ExceptionInformation[1] = 0xffffffff;
}
break;
case TRAP_x86_PAGEFLT: /* Page fault */
diff --git a/dlls/ntdll/tests/exception.c b/dlls/ntdll/tests/exception.c
index a8aa975..90aa3b6 100644
--- a/dlls/ntdll/tests/exception.c
+++ b/dlls/ntdll/tests/exception.c
@@ -118,7 +118,7 @@ static const struct exception
/* test overlong instruction (limit is 16 bytes) */
{ { 0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0xfa,0xc3 },
- 0, 16, STATUS_ACCESS_VIOLATION, 2, { 0, 0xffffffff } },
+ 0, 16, STATUS_ILLEGAL_INSTRUCTION, 0 },
{ { 0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0x64,0xfa,0xc3 },
0, 15, STATUS_PRIVILEGED_INSTRUCTION, 0 },
More information about the wine-cvs
mailing list