add SEH to NtW32Call and directly use KeUserModeCallback in win32k instead
authorThomas Bluemel <thomas@reactsoft.com>
Sun, 22 Jan 2006 20:34:47 +0000 (20:34 +0000)
committerThomas Bluemel <thomas@reactsoft.com>
Sun, 22 Jan 2006 20:34:47 +0000 (20:34 +0000)
svn path=/trunk/; revision=20984

reactos/include/ndk/kefuncs.h
reactos/ntoskrnl/ps/win32.c
reactos/subsys/win32k/ntuser/callback.c

index 31395e0..1e6aead 100644 (file)
@@ -426,8 +426,8 @@ NtW32Call(
     IN ULONG RoutineIndex,
     IN PVOID Argument,
     IN ULONG ArgumentLength,
-    OUT PVOID* Result OPTIONAL,
-    OUT PULONG ResultLength OPTIONAL
+    OUT PVOID* Result,
+    OUT PULONG ResultLength
 );
 
 NTSTATUS
index 5ce902d..4f38ded 100644 (file)
@@ -192,25 +192,56 @@ STDCALL
 NtW32Call(IN ULONG RoutineIndex,
           IN PVOID Argument,
           IN ULONG ArgumentLength,
-          OUT PVOID* Result OPTIONAL,
-          OUT PULONG ResultLength OPTIONAL)
+          OUT PVOID* Result,
+          OUT PULONG ResultLength)
 {
-    NTSTATUS CallbackStatus;
+    PVOID RetResult;
+    ULONG RetResultLength;
+    NTSTATUS Status = STATUS_SUCCESS;
 
-    DPRINT("NtW32Call(RoutineIndex %d, Argument %X, ArgumentLength %d)\n",
+    DPRINT("NtW32Call(RoutineIndex %d, Argument %p, ArgumentLength %d)\n",
             RoutineIndex, Argument, ArgumentLength);
 
-    /* FIXME: SEH!!! */
+    /* must not be called as KernelMode! */
+    ASSERT(KeGetPreviousMode() != KernelMode);
 
-    /* Call kernel function */
-    CallbackStatus = KeUserModeCallback(RoutineIndex,
-                                        Argument,
-                                        ArgumentLength,
-                                        Result,
-                                        ResultLength);
+    _SEH_TRY
+    {
+        ProbeForWritePointer(Result);
+        ProbeForWriteUlong(ResultLength);
+    }
+    _SEH_HANDLE
+    {
+        Status = _SEH_GetExceptionCode();
+    }
+    _SEH_END;
+
+    if (NT_SUCCESS(Status))
+    {
+        /* Call kernel function */
+        Status = KeUserModeCallback(RoutineIndex,
+                                    Argument,
+                                    ArgumentLength,
+                                    &RetResult,
+                                    &RetResultLength);
+
+        if (NT_SUCCESS(Status))
+        {
+            _SEH_TRY
+            {
+                *Result = RetResult;
+                *ResultLength = RetResultLength;
+            }
+            _SEH_HANDLE
+            {
+                Status = _SEH_GetExceptionCode();
+            }
+            _SEH_END;
+        }
+    }
 
     /* Return the result */
-    return(CallbackStatus);
+    return Status;
 }
 
 /* EOF */
index 606c197..d96d59e 100644 (file)
@@ -116,6 +116,8 @@ co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
                               LRESULT Result)
 {
    SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
+   PVOID ResultPointer;
+   ULONG ResultLength;
    NTSTATUS Status;
 
    Arguments.Callback = CompletionCallback;
@@ -126,11 +128,11 @@ co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
 
    UserLeaveCo();
 
-   Status = NtW32Call(USER32_CALLBACK_SENDASYNCPROC,
-                      &Arguments,
-                      sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
-                      NULL,
-                      NULL);
+   Status = KeUserModeCallback(USER32_CALLBACK_SENDASYNCPROC,
+                               &Arguments,
+                               sizeof(SENDASYNCPROC_CALLBACK_ARGUMENTS),
+                               &ResultPointer,
+                               &ResultLength);
 
    UserEnterCo();
 
@@ -187,11 +189,11 @@ co_IntCallWindowProc(WNDPROC Proc,
 
    UserLeaveCo();
 
-   Status = NtW32Call(USER32_CALLBACK_WINDOWPROC,
-                      Arguments,
-                      ArgumentLength,
-                      &ResultPointer,
-                      &ResultLength);
+   Status = KeUserModeCallback(USER32_CALLBACK_WINDOWPROC,
+                               Arguments,
+                               ArgumentLength,
+                               &ResultPointer,
+                               &ResultLength);
 
    /* Simulate old behaviour: copy into our local buffer */
    RtlMoveMemory(Arguments, ResultPointer, ArgumentLength);
@@ -232,11 +234,11 @@ co_IntLoadSysMenuTemplate()
 
    UserLeaveCo();
 
-   Status = NtW32Call(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
-                      NULL,
-                      0,
-                      &ResultPointer,
-                      &ResultLength);
+   Status = KeUserModeCallback(USER32_CALLBACK_LOADSYSMENUTEMPLATE,
+                               NULL,
+                               0,
+                               &ResultPointer,
+                               &ResultLength);
 
    /* Simulate old behaviour: copy into our local buffer */
    Result = *(LRESULT*)ResultPointer;
@@ -264,11 +266,11 @@ co_IntLoadDefaultCursors(VOID)
 
    UserLeaveCo();
 
-   Status = NtW32Call(USER32_CALLBACK_LOADDEFAULTCURSORS,
-                      &DefaultCursor,
-                      sizeof(BOOL),
-                      &ResultPointer,
-                      &ResultLength);
+   Status = KeUserModeCallback(USER32_CALLBACK_LOADDEFAULTCURSORS,
+                               &DefaultCursor,
+                               sizeof(BOOL),
+                               &ResultPointer,
+                               &ResultLength);
 
    /* Simulate old behaviour: copy into our local buffer */
    Result = *(LRESULT*)ResultPointer;
@@ -398,11 +400,11 @@ co_IntCallHookProc(INT HookId,
 
    UserLeaveCo();
 
-   Status = NtW32Call(USER32_CALLBACK_HOOKPROC,
-                      Argument,
-                      ArgumentLength,
-                      &ResultPointer,
-                      &ResultLength);
+   Status = KeUserModeCallback(USER32_CALLBACK_HOOKPROC,
+                               Argument,
+                               ArgumentLength,
+                               &ResultPointer,
+                               &ResultLength);
 
    /* Simulate old behaviour: copy into our local buffer */
    Result = *(LRESULT*)ResultPointer;