https://git.reactos.org/?p=reactos.git;a=commitdiff;h=68430db4622d6920be154…
commit 68430db4622d6920be15484108f0c75e43c6b86a
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Mar 17 23:45:40 2018 +0100
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sat Mar 17 23:47:16 2018 +0100
[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 388ef25bb1..c95b8dfbcc 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;
}