[win32k]
[reactos.git] / reactos / subsystems / win32 / win32k / ntuser / callback.c
index ff7af45..e536d4c 100644 (file)
@@ -14,7 +14,7 @@
 
 /* INCLUDES ******************************************************************/
 
-#include <w32k.h>
+#include <win32k.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -93,26 +93,26 @@ IntCleanupThreadCallbacks(PTHREADINFO W32Thread)
 // This will help user space programs speed up read access with the window object.
 //
 static VOID
-IntSetTebWndCallback (HWND * hWnd, PVOID * pWnd)
+IntSetTebWndCallback (HWND * hWnd, PWND * pWnd)
 {
   HWND hWndS = *hWnd;
-  PWINDOW_OBJECT Window = UserGetWindowObject(*hWnd);
+  PWND Window = UserGetWindowObject(*hWnd);
   PCLIENTINFO ClientInfo = GetWin32ClientInfo();
 
   *hWnd = ClientInfo->CallbackWnd.hWnd;
-  *pWnd = ClientInfo->CallbackWnd.pvWnd;
+  *pWnd = ClientInfo->CallbackWnd.pWnd;
 
   ClientInfo->CallbackWnd.hWnd  = hWndS;
-  ClientInfo->CallbackWnd.pvWnd = DesktopHeapAddressToUser(Window->Wnd);
+  ClientInfo->CallbackWnd.pWnd = DesktopHeapAddressToUser(Window);
 }
 
 static VOID
-IntRestoreTebWndCallback (HWND hWnd, PVOID pWnd)
+IntRestoreTebWndCallback (HWND hWnd, PWND pWnd)
 {
   PCLIENTINFO ClientInfo = GetWin32ClientInfo();
 
   ClientInfo->CallbackWnd.hWnd = hWnd;
-  ClientInfo->CallbackWnd.pvWnd = pWnd;
+  ClientInfo->CallbackWnd.pWnd = pWnd;
 }
 
 /* FUNCTIONS *****************************************************************/
@@ -125,7 +125,8 @@ co_IntCallSentMessageCallback(SENDASYNCPROC CompletionCallback,
                               LRESULT Result)
 {
    SENDASYNCPROC_CALLBACK_ARGUMENTS Arguments;
-   PVOID ResultPointer, pWnd;
+   PVOID ResultPointer;
+   PWND pWnd;
    ULONG ResultLength;
    NTSTATUS Status;
 
@@ -168,7 +169,8 @@ co_IntCallWindowProc(WNDPROC Proc,
    WINDOWPROC_CALLBACK_ARGUMENTS StackArguments;
    PWINDOWPROC_CALLBACK_ARGUMENTS Arguments;
    NTSTATUS Status;
-   PVOID ResultPointer, pWnd;
+   PVOID ResultPointer;
+   PWND pWnd;
    ULONG ResultLength;
    ULONG ArgumentLength;
    LRESULT Result;
@@ -267,7 +269,16 @@ co_IntLoadSysMenuTemplate()
    if (NT_SUCCESS(Status))
    {
       /* Simulate old behaviour: copy into our local buffer */
-      Result = *(LRESULT*)ResultPointer;
+      _SEH2_TRY
+      {
+        ProbeForRead(ResultPointer, sizeof(LRESULT), 1);
+        Result = *(LRESULT*)ResultPointer;
+      }
+      _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
+      {
+        Result = 0;
+      }
+      _SEH2_END
    }
 
    UserEnterCo();
@@ -328,6 +339,8 @@ co_IntCallHookProc(INT HookId,
    PANSI_STRING asClassName;
    PTHREADINFO pti;
 
+   ASSERT(Proc);
+
    pti = PsGetCurrentThreadWin32Thread();
    if (pti->TIF_flags & TIF_INCLEANUP)
    {
@@ -640,7 +653,7 @@ co_IntCallEventProc(HWINEVENTHOOK hook,
    UserEnterCo();
 
    IntCbFreeMemory(Argument);
-
+  
    if (!NT_SUCCESS(Status))
    {
       return 0;
@@ -700,7 +713,7 @@ co_IntCallLoadMenu( HINSTANCE hModule,
    Result = *(LRESULT*)ResultPointer;
 
    IntCbFreeMemory(Argument);
-  
+
    if (!NT_SUCCESS(Status))
    {
       return 0;