[Win32SS]

- Fix the remaining wine Win tests for FindWindow/Ex/A/W. Check the buffer not the length, buffer could be pointing to a null. Enable the message window handling. Use wine code for FindWindowExA.

svn path=/trunk/; revision=56557
This commit is contained in:
James Tabor
2012-05-10 06:08:51 +00:00
parent e65f13023e
commit 13ebffa83e
2 changed files with 28 additions and 52 deletions
+12 -11
View File
@@ -2509,7 +2509,7 @@ IntFindWindow(PWND Parent,
ASSERT(Parent);
CheckWindowName = WindowName->Length != 0;
CheckWindowName = WindowName->Buffer != 0;
if((List = IntWinListChildren(Parent)))
{
@@ -2588,6 +2588,7 @@ NtUserFindWindowEx(HWND hwndParent,
PWND Parent, ChildAfter;
UNICODE_STRING ClassName = {0}, WindowName = {0};
HWND Desktop, Ret = NULL;
BOOL DoMessageWnd = FALSE;
RTL_ATOM ClassAtom = (RTL_ATOM)0;
DECLARE_RETURN(HWND);
@@ -2657,7 +2658,10 @@ NtUserFindWindowEx(HWND hwndParent,
Desktop = IntGetCurrentThreadDesktopWindow();
if(hwndParent == NULL)
{
hwndParent = Desktop;
DoMessageWnd = TRUE;
}
else if(hwndParent == HWND_MESSAGE)
{
hwndParent = IntGetMessageWindow();
@@ -2698,7 +2702,7 @@ NtUserFindWindowEx(HWND hwndParent,
;
}
CheckWindowName = WindowName.Length != 0;
CheckWindowName = WindowName.Buffer != 0;
/* search children */
while(*phWnd)
@@ -2741,15 +2745,13 @@ NtUserFindWindowEx(HWND hwndParent,
}
}
else
Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
#if 0
if(Ret == NULL && hwndParent == NULL && hwndChildAfter == NULL)
{
/* FIXME: If both hwndParent and hwndChildAfter are NULL, we also should
search the message-only windows. Should this also be done if
Parent is the desktop window??? */
ERR("FindWindowEx: Not Desktop Parent!\n");
Ret = IntFindWindow(Parent, ChildAfter, ClassAtom, &WindowName);
}
if (Ret == NULL && DoMessageWnd)
{
PWND MsgWindows;
if((MsgWindows = UserGetWindowObject(IntGetMessageWindow())))
@@ -2757,7 +2759,6 @@ NtUserFindWindowEx(HWND hwndParent,
Ret = IntFindWindow(MsgWindows, ChildAfter, ClassAtom, &WindowName);
}
}
#endif
}
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
{
+16 -41
View File
@@ -744,54 +744,29 @@ FindWindowExA(HWND hwndParent,
LPCSTR lpszClass,
LPCSTR lpszWindow)
{
UNICODE_STRING ucClassName, *pucClassName = NULL;
UNICODE_STRING ucWindowName, *pucWindowName = NULL;
HWND Result;
LPWSTR titleW = NULL;
HWND hwnd = 0;
if (IS_ATOM(lpszClass))
if (lpszWindow)
{
ucClassName.Buffer = (LPWSTR)lpszClass;
ucClassName.Length = 0;
pucClassName = &ucClassName;
}
else if (lpszClass != NULL)
{
if (!RtlCreateUnicodeStringFromAsciiz(&ucClassName,
(LPSTR)lpszClass))
{
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
pucClassName = &ucClassName;
DWORD len = MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, NULL, 0 );
if (!(titleW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) return 0;
MultiByteToWideChar( CP_ACP, 0, lpszWindow, -1, titleW, len );
}
if (lpszWindow != NULL)
if (!IS_INTRESOURCE(lpszClass))
{
if (!RtlCreateUnicodeStringFromAsciiz(&ucWindowName,
(LPSTR)lpszWindow))
{
if (!IS_ATOM(lpszClass) && lpszClass != NULL)
RtlFreeUnicodeString(&ucWindowName);
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
return NULL;
}
pucWindowName = &ucWindowName;
WCHAR classW[256];
if (MultiByteToWideChar( CP_ACP, 0, lpszClass, -1, classW, sizeof(classW)/sizeof(WCHAR) ))
hwnd = FindWindowExW( hwndParent, hwndChildAfter, classW, titleW );
}
else
{
hwnd = FindWindowExW( hwndParent, hwndChildAfter, (LPCWSTR)lpszClass, titleW );
}
Result = NtUserFindWindowEx(hwndParent,
hwndChildAfter,
pucClassName,
pucWindowName,
0);
if (!IS_ATOM(lpszClass) && lpszClass != NULL)
RtlFreeUnicodeString(&ucClassName);
if (lpszWindow != NULL)
RtlFreeUnicodeString(&ucWindowName);
return Result;
HeapFree( GetProcessHeap(), 0, titleW );
return hwnd;
}