Mike McCormack : user32: Add an exception handler around the WM_GETTEXT handler.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Jan 18 06:44:50 CST 2007


Module: wine
Branch: master
Commit: ce21d918d85fbf8d75e5bb1d375bdeee079a4cab
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ce21d918d85fbf8d75e5bb1d375bdeee079a4cab

Author: Mike McCormack <mike at codeweavers.com>
Date:   Wed Jan 17 19:51:32 2007 +0900

user32: Add an exception handler around the WM_GETTEXT handler.

---

 dlls/user32/defwnd.c |   59 +++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 46 insertions(+), 13 deletions(-)

diff --git a/dlls/user32/defwnd.c b/dlls/user32/defwnd.c
index 9278ddd..06c10b2 100644
--- a/dlls/user32/defwnd.c
+++ b/dlls/user32/defwnd.c
@@ -36,6 +36,7 @@
 #include "wine/unicode.h"
 #include "wine/winuser16.h"
 #include "wine/server.h"
+#include "wine/exception.h"
 #include "wine/debug.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(win);
@@ -726,7 +727,27 @@ static LRESULT DEFWND_DefWinProc( HWND h
     return 0;
 }
 
+static LPARAM DEFWND_GetTextA( WND *wndPtr, LPSTR dest, WPARAM wParam )
+{
+    LPARAM result = 0;
 
+    __TRY
+    {
+        if (wndPtr->text)
+        {
+            if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
+                                      dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
+            result = strlen( dest );
+        }
+        else dest[0] = '\0';
+    }
+    __EXCEPT_PAGE_FAULT
+    {
+        return 0;
+    }
+    __ENDTRY
+    return result;
+}
 
 /***********************************************************************
  *              DefWindowProcA (USER32.@)
@@ -778,13 +799,8 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd
             WND *wndPtr = WIN_GetPtr( hwnd );
 
             if (!wndPtr) break;
-            if (wndPtr->text)
-            {
-                if (!WideCharToMultiByte( CP_ACP, 0, wndPtr->text, -1,
-                                          dest, wParam, NULL, NULL )) dest[wParam-1] = 0;
-                result = strlen( dest );
-            }
-            else dest[0] = '\0';
+            result = DEFWND_GetTextA( wndPtr, dest, wParam );
+
             WIN_ReleasePtr( wndPtr );
         }
         break;
@@ -862,6 +878,28 @@ LRESULT WINAPI DefWindowProcA( HWND hwnd
 }
 
 
+static LPARAM DEFWND_GetTextW( WND *wndPtr, LPWSTR dest, WPARAM wParam )
+{
+    LPARAM result = 0;
+
+    __TRY
+    {
+        if (wndPtr->text)
+        {
+            lstrcpynW( dest, wndPtr->text, wParam );
+            result = strlenW( dest );
+        }
+        else dest[0] = '\0';
+    }
+    __EXCEPT_PAGE_FAULT
+    {
+        return 0;
+    }
+    __ENDTRY
+
+    return result;
+}
+
 /***********************************************************************
  *              DefWindowProcW (USER32.@) Calls default window message handler
  *
@@ -917,12 +955,7 @@ LRESULT WINAPI DefWindowProcW(
             WND *wndPtr = WIN_GetPtr( hwnd );
 
             if (!wndPtr) break;
-            if (wndPtr->text)
-            {
-                lstrcpynW( dest, wndPtr->text, wParam );
-                result = strlenW( dest );
-            }
-            else dest[0] = '\0';
+            result = DEFWND_GetTextW( wndPtr, dest, wParam );
             WIN_ReleasePtr( wndPtr );
         }
         break;




More information about the wine-cvs mailing list