NtUserBuildHwndList() returns NTSTATUS, not ULONG. More correct fix than 33483 to some of the winetest problems. Pass return value as out parameter instead.

svn path=/trunk/; revision=33500
This commit is contained in:
Gregor Brunmar 2008-05-13 18:09:08 +00:00
parent 8efa2c983f
commit 9736840986
4 changed files with 28 additions and 28 deletions

View file

@ -133,12 +133,11 @@ HWND* WIN_ListChildren (HWND hWndparent)
DWORD dwCount = 0; DWORD dwCount = 0;
HWND* pHwnd = NULL; HWND* pHwnd = NULL;
HANDLE hHeap; HANDLE hHeap;
NTSTATUS Status;
SetLastError(0); Status = NtUserBuildHwndList ( NULL, hWndparent, FALSE, 0, 0, NULL, &dwCount );
dwCount = NtUserBuildHwndList ( NULL, hWndparent, FALSE, 0, 0, NULL, 0 ); if ( !NT_SUCCESS( Status ) )
if ( !dwCount || GetLastError() )
return 0; return 0;
/* allocate buffer to receive HWND handles */ /* allocate buffer to receive HWND handles */
@ -152,9 +151,9 @@ HWND* WIN_ListChildren (HWND hWndparent)
} }
/* now call kernel again to fill the buffer this time */ /* now call kernel again to fill the buffer this time */
dwCount = NtUserBuildHwndList (NULL, hWndparent, FALSE, 0, 0, pHwnd, dwCount ); Status = NtUserBuildHwndList (NULL, hWndparent, FALSE, 0, 0, pHwnd, &dwCount );
if ( !dwCount || GetLastError() ) if ( !NT_SUCCESS( Status ) )
{ {
if ( pHwnd ) if ( pHwnd )
HeapFree ( hHeap, 0, pHwnd ); HeapFree ( hHeap, 0, pHwnd );

View file

@ -558,6 +558,7 @@ User32EnumWindows (
DWORD i, dwCount = 0; DWORD i, dwCount = 0;
HWND* pHwnd = NULL; HWND* pHwnd = NULL;
HANDLE hHeap; HANDLE hHeap;
NTSTATUS Status;
if ( !lpfn ) if ( !lpfn )
{ {
@ -569,9 +570,9 @@ User32EnumWindows (
sort of persistent buffer and only grow it ( requiring a 2nd sort of persistent buffer and only grow it ( requiring a 2nd
call ) when the buffer wasn't already big enough? */ call ) when the buffer wasn't already big enough? */
/* first get how many window entries there are */ /* first get how many window entries there are */
dwCount = NtUserBuildHwndList ( Status = NtUserBuildHwndList (
hDesktop, hWndparent, bChildren, dwThreadId, lParam, NULL, 0 ); hDesktop, hWndparent, bChildren, dwThreadId, lParam, NULL, &dwCount );
if ( !dwCount ) if ( !NT_SUCCESS( Status ) )
return FALSE; return FALSE;
/* allocate buffer to receive HWND handles */ /* allocate buffer to receive HWND handles */
@ -584,9 +585,9 @@ User32EnumWindows (
} }
/* now call kernel again to fill the buffer this time */ /* now call kernel again to fill the buffer this time */
dwCount = NtUserBuildHwndList ( Status = NtUserBuildHwndList (
hDesktop, hWndparent, bChildren, dwThreadId, lParam, pHwnd, dwCount ); hDesktop, hWndparent, bChildren, dwThreadId, lParam, pHwnd, &dwCount );
if ( !dwCount ) if ( !NT_SUCCESS( Status ) )
{ {
if ( pHwnd ) if ( pHwnd )
HeapFree ( hHeap, 0, pHwnd ); HeapFree ( hHeap, 0, pHwnd );

View file

@ -481,7 +481,7 @@ NTAPI
NtUserBlockInput( NtUserBlockInput(
BOOL BlockIt); BOOL BlockIt);
ULONG NTSTATUS
NTAPI NTAPI
NtUserBuildHwndList( NtUserBuildHwndList(
HDESK hDesktop, HDESK hDesktop,
@ -490,7 +490,7 @@ NtUserBuildHwndList(
ULONG dwThreadId, ULONG dwThreadId,
ULONG lParam, ULONG lParam,
HWND* pWnd, HWND* pWnd,
ULONG nBufSize); ULONG* nBufSize);
NTSTATUS NTAPI NTSTATUS NTAPI
NtUserBuildNameList( NtUserBuildNameList(

View file

@ -1212,7 +1212,7 @@ NtUserAlterWindowStyle(DWORD Unknown0,
/* /*
* @implemented * @implemented
*/ */
ULONG NTSTATUS
STDCALL STDCALL
NtUserBuildHwndList( NtUserBuildHwndList(
HDESK hDesktop, HDESK hDesktop,
@ -1221,11 +1221,14 @@ NtUserBuildHwndList(
ULONG dwThreadId, ULONG dwThreadId,
ULONG lParam, ULONG lParam,
HWND* pWnd, HWND* pWnd,
ULONG nBufSize) ULONG* pBufSize)
{ {
NTSTATUS Status; NTSTATUS Status;
ULONG dwCount = 0; ULONG dwCount = 0;
if (pBufSize == 0)
return ERROR_INVALID_PARAMETER;
if (hwndParent || !dwThreadId) if (hwndParent || !dwThreadId)
{ {
PDESKTOP_OBJECT Desktop; PDESKTOP_OBJECT Desktop;
@ -1235,8 +1238,7 @@ NtUserBuildHwndList(
{ {
if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop())) if(hDesktop == NULL && !(Desktop = IntGetActiveDesktop()))
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE;
return 0;
} }
if(hDesktop) if(hDesktop)
@ -1247,8 +1249,7 @@ NtUserBuildHwndList(
&Desktop); &Desktop);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastWin32Error(ERROR_INVALID_HANDLE); return ERROR_INVALID_HANDLE;
return 0;
} }
} }
hwndParent = Desktop->DesktopWindow; hwndParent = Desktop->DesktopWindow;
@ -1268,7 +1269,7 @@ NtUserBuildHwndList(
{ {
if (bGoDown) if (bGoDown)
{ {
if(dwCount++ < nBufSize && pWnd) if(dwCount++ < *pBufSize && pWnd)
{ {
_SEH_TRY _SEH_TRY
{ {
@ -1323,15 +1324,13 @@ NtUserBuildHwndList(
Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread); Status = PsLookupThreadByThreadId((HANDLE)dwThreadId, &Thread);
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastWin32Error(ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER;
return 0;
} }
if(!(W32Thread = (PW32THREAD)Thread->Tcb.Win32Thread)) if(!(W32Thread = (PW32THREAD)Thread->Tcb.Win32Thread))
{ {
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
DPRINT("Thread is not a GUI Thread!\n"); DPRINT("Thread is not a GUI Thread!\n");
SetLastWin32Error(ERROR_INVALID_PARAMETER); return ERROR_INVALID_PARAMETER;
return 0;
} }
Current = W32Thread->WindowListHead.Flink; Current = W32Thread->WindowListHead.Flink;
@ -1342,7 +1341,7 @@ NtUserBuildHwndList(
if(bChildren || Window->hOwner != NULL) if(bChildren || Window->hOwner != NULL)
{ {
if(dwCount < nBufSize && pWnd) if(dwCount < *pBufSize && pWnd)
{ {
Status = MmCopyToCaller(pWnd++, &Window->hSelf, sizeof(HWND)); Status = MmCopyToCaller(pWnd++, &Window->hSelf, sizeof(HWND));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
@ -1359,7 +1358,8 @@ NtUserBuildHwndList(
ObDereferenceObject(Thread); ObDereferenceObject(Thread);
} }
return dwCount; *pBufSize = dwCount;
return STATUS_SUCCESS;
} }