add SEH to NtW32Call and directly use KeUserModeCallback in win32k
instead
Modified: trunk/reactos/include/ndk/kefuncs.h
Modified: trunk/reactos/ntoskrnl/ps/win32.c
Modified: trunk/reactos/subsys/win32k/ntuser/callback.c
_____
Modified: trunk/reactos/include/ndk/kefuncs.h
--- trunk/reactos/include/ndk/kefuncs.h 2006-01-22 15:55:14 UTC (rev
20983)
+++ trunk/reactos/include/ndk/kefuncs.h 2006-01-22 20:34:47 UTC (rev
20984)
@@ -426,8 +426,8 @@
IN ULONG RoutineIndex,
IN PVOID Argument,
IN ULONG ArgumentLength,
- OUT PVOID* Result OPTIONAL,
- OUT PULONG ResultLength OPTIONAL
+ OUT PVOID* Result,
+ OUT PULONG ResultLength
);
NTSTATUS
_____
Modified: trunk/reactos/ntoskrnl/ps/win32.c
--- trunk/reactos/ntoskrnl/ps/win32.c 2006-01-22 15:55:14 UTC (rev
20983)
+++ trunk/reactos/ntoskrnl/ps/win32.c 2006-01-22 20:34:47 UTC (rev
20984)
@@ -192,25 +192,56 @@
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 */
_____
Modified: trunk/reactos/subsys/win32k/ntuser/callback.c
--- trunk/reactos/subsys/win32k/ntuser/callback.c 2006-01-22
15:55:14 UTC (rev 20983)
+++ trunk/reactos/subsys/win32k/ntuser/callback.c 2006-01-22
20:34:47 UTC (rev 20984)
@@ -116,6 +116,8 @@
LRESULT Result)
{
SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
+ PVOID ResultPointer;
+ ULONG ResultLength;
NTSTATUS Status;
Arguments.Callback = CompletionCallback;
@@ -126,11 +128,11 @@
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 @@
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 @@
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 @@
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 @@
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;