[ros-kernel] SEH testing

Royce Mitchell III royce3 at ev1.net
Wed Jun 23 01:28:20 CEST 2004


Okay, I made the following change per Hyperion's directions:

Index: ntoskrnl/rtl/i386/exception.c
===================================================================
RCS file: /CVS/ReactOS/reactos/ntoskrnl/rtl/i386/exception.c,v
retrieving revision 1.10
diff -u -r1.10 exception.c
--- ntoskrnl/rtl/i386/exception.c    24 Feb 2004 23:51:04 -0000    1.10
+++ ntoskrnl/rtl/i386/exception.c    23 Jun 2004 04:11:02 -0000
@@ -96,7 +96,7 @@
 
 #define SehpCaptureContext(Context) \
 { \
-    KeTrapFrameToContext(KeGetCurrentThread()->TrapFrame, (Context)); \
+    RtlpCaptureContext(Context); \
 }
 
 #define SehpContinue(Context, TestAlert) \

Arty sent me his modified null.sys that has some SEH testing code in it....

Index: drivers/dd/null/makefile
===================================================================
RCS file: /CVS/ReactOS/reactos/drivers/dd/null/makefile,v
retrieving revision 1.18
diff -u -r1.18 makefile
--- drivers/dd/null/makefile    17 Nov 2003 20:48:22 -0000    1.18
+++ drivers/dd/null/makefile    18 Jun 2004 20:51:06 -0000
@@ -6,7 +6,12 @@
 
 TARGET_NAME = null
 
-TARGET_OBJECTS = null.o
+full: all
+
+$(PATH_TO_TOP)/dk/w32/lib/pseh.a:
+    $(MAKE) -C $(PATH_TO_TOP)/lib/pseh
+
+TARGET_OBJECTS = null.o $(PATH_TO_TOP)/dk/w32/lib/pseh.a
 
 TARGET_CFLAGS = -Wall -Werror
 
Index: drivers/dd/null/null.c
===================================================================
RCS file: /CVS/ReactOS/reactos/drivers/dd/null/null.c,v
retrieving revision 1.13
diff -u -r1.13 null.c
--- drivers/dd/null/null.c    10 Feb 2004 16:22:55 -0000    1.13
+++ drivers/dd/null/null.c    18 Jun 2004 21:20:00 -0000
@@ -13,6 +13,7 @@
 /* INCLUDES */
 #include <ddk/ntddk.h>
 #include <rosrtl/string.h>
+#include <pseh.h>
 #include "null.h"
 
 /* OBJECTS */
@@ -34,7 +35,13 @@
   case IRP_MJ_CREATE:
   case IRP_MJ_CLOSE:
   {
-   break;
+      char *foo = 0;
+      _SEH_TRY {
+      *foo = 1;
+      } _SEH_HANDLE {
+      DbgPrint("Foo: %x\n", foo);
+      } _SEH_END
+      break;
   }
 
   /* write data */


Anyways, with this change, I experience a crash, but a different one 
than we've been getting in kmode ( to my knowledge ) so we're not quite 
there.. here are the particulars:

KeBugCheckWithTf at ke/catch.c:172
Bug detected (code 1e param 0 0 0 0)
  KMODE_EXCEPTION_NOT_HANDLED

Page Fault Exception: 14(0)
Processor: 0 CS:EIP 8:c0007fd0 <ntoskrnl.exe: 7fd0>
cr2 0 cr3 47f5000 Proc: c15dbb48 Pid: 9 <cmd> Thrd: c15d74d8 Tid: 31
DS 10 ES 10 FS 30 GS 10
EAX: 00000002   EBX: df32173c   ECX: df321408
EDX: c0008001   EBP: df321378   ESI: 0000000e   ESP: df3212e8
EDI: c15d74d8   EFLAGS: 00000246 kESP df3212e8 kernel stack base df31f000
Frames:
 <ntoskrnl.exe: 81b6> RtlpDispatchException
 <ntoskrnl.exe: 996f> _KiDispatchException
 <ntoskrnl.exe: 1550> _KiKernelTrapHandler
 <ntoskrnl.exe: 1f2a> _KiTrapHandler
 <ntoskrnl.exe: 32ad> _KiTrapProlog
 <DF3217BF>


Here's a snip of ntoskrnl/rtl/i386/except.s, I've notated the line 
assocated with EIP above.

_RtlpExecuteHandler:
    pushl    %ebp
    movl     %esp, %ebp
    pushl    REH_RFRAME(%ebp)

    pushl    %edx
    pushl    %fs:0x0
    movl     %esp, %fs:0x0

    // Prepare to call the exception handler
    pushl    REH_DCONTEXT(%ebp)
    pushl    REH_CONTEXT(%ebp)
    pushl    REH_RFRAME(%ebp)
    pushl    REH_ERECORD(%ebp)

    // Now call the exception handler
    movl     REH_EROUTINE(%ebp), %eax
    call    *%eax

    cmpl    $-1, %fs:0x0
    jne        .reh_stack_looks_ok

    // This should not happen
    pushl    0 // <<<<< EIP in my crash, i.e. <ntoskrnl.exe: 7fd0>
    pushl    0
    pushl    0
    pushl    0
    call    _RtlAssert at 16


Lemme know what else to try Hyperion... or whomever.....




More information about the Ros-kernel mailing list