From 68430db4622d6920be15484108f0c75e43c6b86a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herm=C3=A8s=20B=C3=A9lusca-Ma=C3=AFto?= Date: Sat, 17 Mar 2018 23:45:40 +0100 Subject: [PATCH] [USER32] Fix GetWindowTextLength() blocking call using the same technique as in GetWindowText(). Fix indentation in GetWindowText(). --- win32ss/user/user32/windows/window.c | 78 +++++++++++++++++++--------- 1 file changed, 54 insertions(+), 24 deletions(-) diff --git a/win32ss/user/user32/windows/window.c b/win32ss/user/user32/windows/window.c index 388ef25bb10..c95b8dfbcc6 100644 --- a/win32ss/user/user32/windows/window.c +++ b/win32ss/user/user32/windows/window.c @@ -1306,20 +1306,22 @@ GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount) lpString[0] = '\0'; - if (!TestWindowProcess( Wnd)) + if (!TestWindowProcess(Wnd)) { - _SEH2_TRY - { - Length = DefWindowProcA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Length = 0; - } - _SEH2_END; + _SEH2_TRY + { + Length = DefWindowProcA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Length = 0; + } + _SEH2_END; } else - Length = SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + { + Length = SendMessageA(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + } //ERR("GWTA Len %d : %s\n",Length,lpString); return Length; } @@ -1330,7 +1332,20 @@ GetWindowTextA(HWND hWnd, LPSTR lpString, int nMaxCount) int WINAPI GetWindowTextLengthA(HWND hWnd) { - return(SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0)); + PWND Wnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return 0; + + if (!TestWindowProcess(Wnd)) + { + return DefWindowProcA(hWnd, WM_GETTEXTLENGTH, 0, 0); + } + else + { + return SendMessageA(hWnd, WM_GETTEXTLENGTH, 0, 0); + } } /* @@ -1339,7 +1354,20 @@ GetWindowTextLengthA(HWND hWnd) int WINAPI GetWindowTextLengthW(HWND hWnd) { - return(SendMessageW(hWnd, WM_GETTEXTLENGTH, 0, 0)); + PWND Wnd; + + Wnd = ValidateHwnd(hWnd); + if (!Wnd) + return 0; + + if (!TestWindowProcess(Wnd)) + { + return DefWindowProcW(hWnd, WM_GETTEXTLENGTH, 0, 0); + } + else + { + return SendMessageW(hWnd, WM_GETTEXTLENGTH, 0, 0); + } } /* @@ -1360,20 +1388,22 @@ GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount) lpString[0] = L'\0'; - if (!TestWindowProcess( Wnd)) + if (!TestWindowProcess(Wnd)) { - _SEH2_TRY - { - Length = DefWindowProcW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); - } - _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) - { - Length = 0; - } - _SEH2_END; + _SEH2_TRY + { + Length = DefWindowProcW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Length = 0; + } + _SEH2_END; } else - Length = SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + { + Length = SendMessageW(hWnd, WM_GETTEXT, nMaxCount, (LPARAM)lpString); + } //ERR("GWTW Len %d : %S\n",Length,lpString); return Length; }