[ros-diffs] [fireball] 34059: - Fix CM SEH by public demand.

fireball at svn.reactos.org fireball at svn.reactos.org
Mon Jun 23 14:45:28 CEST 2008


Author: fireball
Date: Mon Jun 23 07:45:27 2008
New Revision: 34059

URL: http://svn.reactos.org/svn/reactos?rev=34059&view=rev
Log:
- Fix CM SEH by public demand.

Modified:
    trunk/reactos/ntoskrnl/config/ntapi.c

Modified: trunk/reactos/ntoskrnl/config/ntapi.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/config/ntapi.c?rev=34059&r1=34058&r2=34059&view=diff
==============================================================================
--- trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] (original)
+++ trunk/reactos/ntoskrnl/config/ntapi.c [iso-8859-1] Mon Jun 23 07:45:27 2008
@@ -34,11 +34,11 @@
     PAGED_CODE();
     DPRINT("NtCreateKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName);
 
-    /* Prepare to probe parameters */
-    _SEH_TRY
-    {
-        /* Check for user-mode caller */
-        if (PreviousMode == UserMode)
+    /* Check for user-mode caller */
+    if (PreviousMode == UserMode)
+    {
+        /* Prepare to probe parameters */
+        _SEH_TRY
         {
             /* Check if we have a class */
             if (Class)
@@ -50,32 +50,43 @@
                              sizeof(WCHAR));
                 ParseContext.Class = *Class;
             }
-            
+
             /* Probe the key handle */
             ProbeForWriteHandle(KeyHandle);
             *KeyHandle = NULL;
-            
+
             /* Probe object attributes */
             ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4);
         }
-        else
+        _SEH_HANDLE
         {
-            /* Save the class directly */
-            if (Class) ParseContext.Class = *Class;
+            /* Get the error code */
+            Status = _SEH_GetExceptionCode();
         }
-
-        /* Setup the parse context */
-        ParseContext.CreateOperation = TRUE;
-        ParseContext.CreateOptions = CreateOptions;
-
-        /* Do the create */
-        Status = ObOpenObjectByName(ObjectAttributes,
-                                    CmpKeyObjectType,
-                                    PreviousMode,
-                                    NULL,
-                                    DesiredAccess,
-                                    &ParseContext,
-                                    &Handle);
+        _SEH_END;
+        if(!NT_SUCCESS(Status)) return Status;
+    }
+    else
+    {
+        /* Save the class directly */
+        if (Class) ParseContext.Class = *Class;
+    }
+
+    /* Setup the parse context */
+    ParseContext.CreateOperation = TRUE;
+    ParseContext.CreateOptions = CreateOptions;
+
+    /* Do the create */
+    Status = ObOpenObjectByName(ObjectAttributes,
+                                CmpKeyObjectType,
+                                PreviousMode,
+                                NULL,
+                                DesiredAccess,
+                                &ParseContext,
+                                &Handle);
+
+    _SEH_TRY
+    {
         if (NT_SUCCESS(Status)) *KeyHandle = Handle;
 
         /* Return data to user */
@@ -105,11 +116,11 @@
     PAGED_CODE();
     DPRINT("NtOpenKey(OB 0x%wZ)\n", ObjectAttributes->ObjectName);
 
-    /* Prepare to probe parameters */
-    _SEH_TRY
-    {
-        /* Check for user-mode caller */
-        if (PreviousMode == UserMode)
+    /* Check for user-mode caller */
+    if (PreviousMode == UserMode)
+    {
+        /* Prepare to probe parameters */
+        _SEH_TRY
         {
             /* Probe the key handle */
             ProbeForWriteHandle(KeyHandle);
@@ -118,23 +129,36 @@
             /* Probe object attributes */
             ProbeForRead(ObjectAttributes, sizeof(OBJECT_ATTRIBUTES), 4);
         }
-
-        /* Just let the object manager handle this */
-        Status = ObOpenObjectByName(ObjectAttributes,
-                                    CmpKeyObjectType,
-                                    ExGetPreviousMode(),
-                                    NULL,
-                                    DesiredAccess,
-                                    &ParseContext,
-                                    &Handle);
-        if (NT_SUCCESS(Status)) *KeyHandle = Handle;
-    }
-    _SEH_HANDLE
-    {
-        /* Get the status */
-        Status = _SEH_GetExceptionCode();
-    }
-    _SEH_END;
+        _SEH_HANDLE
+        {
+            /* Get the status */
+            Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
+    }
+
+    /* Just let the object manager handle this */
+    Status = ObOpenObjectByName(ObjectAttributes,
+                                CmpKeyObjectType,
+                                ExGetPreviousMode(),
+                                NULL,
+                                DesiredAccess,
+                                &ParseContext,
+                                &Handle);
+
+    if (NT_SUCCESS(Status))
+    {
+        _SEH_TRY
+        {
+            *KeyHandle = Handle;
+        }
+        _SEH_HANDLE
+        {
+            /* Get the status */
+            Status = _SEH_GetExceptionCode();
+        }
+        _SEH_END;
+    }
 
     /* Return status */
     return Status;



More information about the Ros-diffs mailing list