1. reverted my last change to SendMessageTimeout() which was wrong

2. fixed UserGetWindowIcon(), SendMessageTimeout() usually overwrites the result variable, even if it failed!

svn path=/trunk/; revision=9466
This commit is contained in:
Thomas Bluemel 2004-05-22 09:22:41 +00:00
parent 1404258b13
commit dd55a50761
2 changed files with 52 additions and 38 deletions

View file

@ -147,23 +147,38 @@ UserHasMenu(HWND hWnd, ULONG Style)
HICON HICON
UserGetWindowIcon(HWND hwnd) UserGetWindowIcon(HWND hwnd)
{ {
HICON Ret = 0; HICON Ret;
SendMessageTimeoutW(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret); if(SendMessageTimeoutW(hwnd, WM_GETICON, ICON_SMALL2, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret) && Ret)
if (!Ret) {
SendMessageTimeoutW(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret); return Ret;
if (!Ret) }
SendMessageTimeoutW(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret); if(SendMessageTimeoutW(hwnd, WM_GETICON, ICON_SMALL, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret) && Ret)
if (!Ret) {
Ret = (HICON)GetClassLongW(hwnd, GCL_HICONSM); return Ret;
if (!Ret) }
Ret = (HICON)GetClassLongW(hwnd, GCL_HICON); if(SendMessageTimeoutW(hwnd, WM_GETICON, ICON_BIG, 0, SMTO_ABORTIFHUNG, 1000, (LPDWORD)&Ret) && Ret)
if (!Ret) {
SendMessageTimeoutW(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&Ret); return Ret;
if (!Ret) }
Ret = LoadIconW(0, IDI_APPLICATION); if((Ret = (HICON)GetClassLongW(hwnd, GCL_HICONSM)))
{
return Ret;
}
if((Ret = (HICON)GetClassLongW(hwnd, GCL_HICON)))
{
return Ret;
}
if(SendMessageTimeoutW(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, (LPDWORD)&Ret) && Ret)
{
return Ret;
}
if((Ret = LoadIconW(0, IDI_APPLICATION)))
{
return Ret;
}
return Ret; return NULL;
} }
BOOL BOOL

View file

@ -16,7 +16,7 @@
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/ */
/* $Id: message.c,v 1.67 2004/05/22 08:27:15 weiden Exp $ /* $Id: message.c,v 1.68 2004/05/22 09:22:41 weiden Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -38,6 +38,7 @@ typedef struct
{ {
UINT uFlags; UINT uFlags;
UINT uTimeout; UINT uTimeout;
ULONG_PTR Result;
} DOSENDMESSAGE, *PDOSENDMESSAGE; } DOSENDMESSAGE, *PDOSENDMESSAGE;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
@ -1116,10 +1117,10 @@ IntSendMessage(HWND hWnd,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
LRESULT Result = 0; ULONG_PTR Result = 0;
if(IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result)) if(IntSendMessageTimeout(hWnd, Msg, wParam, lParam, SMTO_NORMAL, 0, &Result))
{ {
return Result; return (LRESULT)Result;
} }
return 0; return 0;
} }
@ -1133,7 +1134,7 @@ IntSendMessageTimeoutSingle(HWND hWnd,
UINT uTimeout, UINT uTimeout,
ULONG_PTR *uResult) ULONG_PTR *uResult)
{ {
LRESULT Result; ULONG_PTR Result;
NTSTATUS Status; NTSTATUS Status;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
PMSGMEMORY MsgMemoryEntry; PMSGMEMORY MsgMemoryEntry;
@ -1180,26 +1181,28 @@ IntSendMessageTimeoutSingle(HWND hWnd,
} }
if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000))
{ {
Result = IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam, Result = (ULONG_PTR)IntCallWindowProc(Window->WndProcW, FALSE, hWnd, Msg, wParam,
lParamPacked,lParamBufferSize); lParamPacked,lParamBufferSize);
} }
else else
{ {
Result = IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam, Result = (ULONG_PTR)IntCallWindowProc(Window->WndProcA, TRUE, hWnd, Msg, wParam,
lParamPacked,lParamBufferSize); lParamPacked,lParamBufferSize);
} }
if(uResult)
{
*uResult = Result;
}
if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam))) if (! NT_SUCCESS(UnpackParam(lParamPacked, Msg, wParam, lParam)))
{ {
IntReleaseWindowObject(Window); IntReleaseWindowObject(Window);
DPRINT1("Failed to unpack message parameters\n"); DPRINT1("Failed to unpack message parameters\n");
if(uResult)
*uResult = Result;
return TRUE; return TRUE;
} }
IntReleaseWindowObject(Window); IntReleaseWindowObject(Window);
if(uResult)
*uResult = Result;
return TRUE; return TRUE;
} }
@ -1211,19 +1214,15 @@ IntSendMessageTimeoutSingle(HWND hWnd,
} }
Status = MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam, Status = MsqSendMessage(Window->MessageQueue, hWnd, Msg, wParam, lParam,
uTimeout, (uFlags & SMTO_BLOCK), &Result); uTimeout, (uFlags & SMTO_BLOCK), uResult);
if(Status == STATUS_TIMEOUT) if(Status == STATUS_TIMEOUT)
{ {
IntReleaseWindowObject(Window); IntReleaseWindowObject(Window);
if(uResult)
*uResult = Result;
SetLastWin32Error(ERROR_TIMEOUT); SetLastWin32Error(ERROR_TIMEOUT);
return FALSE; return FALSE;
} }
IntReleaseWindowObject(Window); IntReleaseWindowObject(Window);
if(uResult)
*uResult = Result;
return TRUE; return TRUE;
} }
@ -1278,7 +1277,7 @@ IntPostOrSendMessage(HWND hWnd,
WPARAM wParam, WPARAM wParam,
LPARAM lParam) LPARAM lParam)
{ {
LRESULT Result; ULONG_PTR Result;
PWINDOW_OBJECT Window; PWINDOW_OBJECT Window;
if(hWnd == HWND_BROADCAST) if(hWnd == HWND_BROADCAST)
@ -1307,7 +1306,7 @@ IntPostOrSendMessage(HWND hWnd,
IntReleaseWindowObject(Window); IntReleaseWindowObject(Window);
return Result; return (LRESULT)Result;
} }
LRESULT FASTCALL LRESULT FASTCALL
@ -1407,7 +1406,7 @@ IntDoSendMessage(HWND Wnd,
{ {
Result = IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message, Result = IntSendMessageTimeout(KernelModeMsg.hwnd, KernelModeMsg.message,
KernelModeMsg.wParam, KernelModeMsg.lParam, KernelModeMsg.wParam, KernelModeMsg.lParam,
dsm->uFlags, dsm->uTimeout, &Result); dsm->uFlags, dsm->uTimeout, &dsm->Result);
} }
Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg); Status = CopyMsgToUserMem(&UserModeMsg, &KernelModeMsg);
if (! NT_SUCCESS(Status)) if (! NT_SUCCESS(Status))
@ -1424,7 +1423,7 @@ IntDoSendMessage(HWND Wnd,
SetLastWin32Error(ERROR_INVALID_PARAMETER); SetLastWin32Error(ERROR_INVALID_PARAMETER);
} }
return Result; return (LRESULT)Result;
} }
LRESULT STDCALL LRESULT STDCALL
@ -1443,11 +1442,11 @@ NtUserSendMessageTimeout(HWND hWnd,
dsm.uFlags = uFlags; dsm.uFlags = uFlags;
dsm.uTimeout = uTimeout; dsm.uTimeout = uTimeout;
Result = IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo); Result = IntDoSendMessage(hWnd, Msg, wParam, lParam, &dsm, UnsafeInfo);
if(uResult) if(uResult != NULL && Result != 0)
{ {
NTSTATUS Status; NTSTATUS Status;
Status = MmCopyToCaller(uResult, &Result, sizeof(ULONG_PTR)); Status = MmCopyToCaller(uResult, &dsm.Result, sizeof(ULONG_PTR));
if(!NT_SUCCESS(Status)) if(!NT_SUCCESS(Status))
{ {
SetLastWin32Error(ERROR_INVALID_PARAMETER); SetLastWin32Error(ERROR_INVALID_PARAMETER);