Author: gbrunmar Date: Tue May 13 13:09:08 2008 New Revision: 33500
URL: http://svn.reactos.org/svn/reactos?rev=33500&view=rev Log: NtUserBuildHwndList() returns NTSTATUS, not ULONG. More correct fix than 33483 to some of the winetest problems. Pass return value as out parameter instead.
Modified: trunk/reactos/dll/win32/user32/windows/mdi.c trunk/reactos/dll/win32/user32/windows/window.c trunk/reactos/include/reactos/win32k/ntuser.h trunk/reactos/subsystems/win32/win32k/ntuser/window.c
Modified: trunk/reactos/dll/win32/user32/windows/mdi.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/md... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/mdi.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/mdi.c [iso-8859-1] Tue May 13 13:09:08 2008 @@ -133,12 +133,11 @@ DWORD dwCount = 0; HWND* pHwnd = NULL; HANDLE hHeap; - - SetLastError(0); - - dwCount = NtUserBuildHwndList ( NULL, hWndparent, FALSE, 0, 0, NULL, 0 ); - - if ( !dwCount || GetLastError() ) + NTSTATUS Status; + + Status = NtUserBuildHwndList ( NULL, hWndparent, FALSE, 0, 0, NULL, &dwCount ); + + if ( !NT_SUCCESS( Status ) ) return 0;
/* allocate buffer to receive HWND handles */ @@ -152,12 +151,12 @@ }
/* now call kernel again to fill the buffer this time */ - dwCount = NtUserBuildHwndList (NULL, hWndparent, FALSE, 0, 0, pHwnd, dwCount ); - - if ( !dwCount || GetLastError() ) + Status = NtUserBuildHwndList (NULL, hWndparent, FALSE, 0, 0, pHwnd, &dwCount ); + + if ( !NT_SUCCESS( Status ) ) { if ( pHwnd ) - HeapFree ( hHeap, 0, pHwnd ); + HeapFree ( hHeap, 0, pHwnd ); return 0; }
Modified: trunk/reactos/dll/win32/user32/windows/window.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/wi... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/window.c [iso-8859-1] Tue May 13 13:09:08 2008 @@ -558,6 +558,7 @@ DWORD i, dwCount = 0; HWND* pHwnd = NULL; HANDLE hHeap; + NTSTATUS Status;
if ( !lpfn ) { @@ -569,9 +570,9 @@ sort of persistent buffer and only grow it ( requiring a 2nd call ) when the buffer wasn't already big enough? */ /* first get how many window entries there are */ - dwCount = NtUserBuildHwndList ( - hDesktop, hWndparent, bChildren, dwThreadId, lParam, NULL, 0 ); - if ( !dwCount ) + Status = NtUserBuildHwndList ( + hDesktop, hWndparent, bChildren, dwThreadId, lParam, NULL, &dwCount ); + if ( !NT_SUCCESS( Status ) ) return FALSE;
/* allocate buffer to receive HWND handles */ @@ -584,9 +585,9 @@ }
/* now call kernel again to fill the buffer this time */ - dwCount = NtUserBuildHwndList ( - hDesktop, hWndparent, bChildren, dwThreadId, lParam, pHwnd, dwCount ); - if ( !dwCount ) + Status = NtUserBuildHwndList ( + hDesktop, hWndparent, bChildren, dwThreadId, lParam, pHwnd, &dwCount ); + if ( !NT_SUCCESS( Status ) ) { if ( pHwnd ) HeapFree ( hHeap, 0, pHwnd );
Modified: trunk/reactos/include/reactos/win32k/ntuser.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/win32k/ntus... ============================================================================== --- trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/win32k/ntuser.h [iso-8859-1] Tue May 13 13:09:08 2008 @@ -481,7 +481,7 @@ NtUserBlockInput( BOOL BlockIt);
-ULONG +NTSTATUS NTAPI NtUserBuildHwndList( HDESK hDesktop, @@ -490,7 +490,7 @@ ULONG dwThreadId, ULONG lParam, HWND* pWnd, - ULONG nBufSize); + ULONG* nBufSize);
NTSTATUS NTAPI NtUserBuildNameList(
Modified: trunk/reactos/subsystems/win32/win32k/ntuser/window.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/ntu... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/window.c [iso-8859-1] Tue May 13 13:09:08 2008 @@ -1212,7 +1212,7 @@ /* * @implemented */ -ULONG +NTSTATUS STDCALL NtUserBuildHwndList( HDESK hDesktop, @@ -1221,11 +1221,14 @@ ULONG dwThreadId, ULONG lParam, HWND* pWnd, - ULONG nBufSize) + ULONG* pBufSize) { NTSTATUS Status; ULONG dwCount = 0;
+ if (pBufSize == 0) + return ERROR_INVALID_PARAMETER; + if (hwndParent || !dwThreadId) { PDESKTOP_OBJECT Desktop; @@ -1235,8 +1238,7 @@ { if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop())) { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return 0; + return ERROR_INVALID_HANDLE; }
if(hDesktop) @@ -1247,8 +1249,7 @@ &Desktop); if(!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_HANDLE); - return 0; + return ERROR_INVALID_HANDLE; } } hwndParent = Desktop->DesktopWindow; @@ -1268,7 +1269,7 @@ { if (bGoDown) { - if(dwCount++ < nBufSize && pWnd) + if(dwCount++ < *pBufSize && pWnd) { _SEH_TRY { @@ -1323,15 +1324,13 @@ Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread); if(!NT_SUCCESS(Status)) { - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + return ERROR_INVALID_PARAMETER; } if(!(W32Thread = (PW32THREAD)Thread->Tcb.Win32Thread)) { ObDereferenceObject(Thread); DPRINT("Thread is not a GUI Thread!\n"); - SetLastWin32Error(ERROR_INVALID_PARAMETER); - return 0; + return ERROR_INVALID_PARAMETER; }
Current = W32Thread->WindowListHead.Flink; @@ -1342,7 +1341,7 @@
if(bChildren || Window->hOwner != NULL) { - if(dwCount < nBufSize && pWnd) + if(dwCount < *pBufSize && pWnd) { Status = MmCopyToCaller(pWnd++, &Window->hSelf, sizeof(HWND)); if(!NT_SUCCESS(Status)) @@ -1359,7 +1358,8 @@ ObDereferenceObject(Thread); }
- return dwCount; + *pBufSize = dwCount; + return STATUS_SUCCESS; }