mirror of
https://github.com/ApfelTeeSaft/reactos.git
synced 2026-08-29 04:13:32 +00:00
Optimize IsWindow() and IsWindowUnicode()
svn path=/trunk/; revision=30497
This commit is contained in:
@@ -89,3 +89,5 @@ PCALLPROC FASTCALL ValidateCallProc(HANDLE hCallProc);
|
||||
PWINDOW FASTCALL ValidateHwnd(HWND hwnd);
|
||||
PWINDOW FASTCALL ValidateHwndOrDesk(HWND hwnd);
|
||||
PWINDOW FASTCALL GetThreadDesktopWnd(VOID);
|
||||
PVOID FASTCALL ValidateHandleNoErr(HANDLE handle, UINT uType);
|
||||
PWINDOW FASTCALL ValidateHwndNoErr(HWND hwnd);
|
||||
|
||||
@@ -421,6 +421,35 @@ ValidateHandle(HANDLE handle, UINT uType)
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Handle and return the pointer to the object.
|
||||
//
|
||||
PVOID
|
||||
FASTCALL
|
||||
ValidateHandleNoErr(HANDLE handle, UINT uType)
|
||||
{
|
||||
PVOID ret;
|
||||
PUSER_HANDLE_ENTRY pEntry;
|
||||
|
||||
ASSERT(uType <= VALIDATE_TYPE_MONITOR);
|
||||
|
||||
pEntry = GetUser32Handle(handle);
|
||||
|
||||
if (pEntry && uType == 0)
|
||||
uType = pEntry->type;
|
||||
|
||||
// Must have an entry and must be the same type!
|
||||
if ( (!pEntry) || (pEntry->type != uType) || !pEntry->ptr )
|
||||
return NULL;
|
||||
|
||||
if (g_ObjectHeapTypeShared[uType])
|
||||
ret = SharedPtrToUser(pEntry->ptr);
|
||||
else
|
||||
ret = DesktopPtrToUser(pEntry->ptr);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate a callproc handle and return the pointer to the object.
|
||||
//
|
||||
@@ -474,6 +503,45 @@ ValidateHwnd(HWND hwnd)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate a window handle and return the pointer to the object.
|
||||
//
|
||||
PWINDOW
|
||||
FASTCALL
|
||||
ValidateHwndNoErr(HWND hwnd)
|
||||
{
|
||||
PWINDOW Wnd;
|
||||
PW32CLIENTINFO ClientInfo = GetWin32ClientInfo();
|
||||
ASSERT(ClientInfo != NULL);
|
||||
|
||||
/* See if the window is cached */
|
||||
if (hwnd == ClientInfo->hWND)
|
||||
return ClientInfo->pvWND;
|
||||
|
||||
Wnd = ValidateHandleNoErr((HANDLE)hwnd, VALIDATE_TYPE_WIN);
|
||||
if (Wnd != NULL)
|
||||
{
|
||||
/* FIXME: Check if handle table entry is marked as deleting and
|
||||
return NULL in this case! */
|
||||
|
||||
#if 0
|
||||
return Wnd;
|
||||
#else
|
||||
/* HACK HACK HACK! This needs to be done until WINDOW_OBJECT is completely
|
||||
superseded by the WINDOW structure. We *ASSUME* a pointer to the WINDOW
|
||||
structure to be at the beginning of the WINDOW_OBJECT structure!!!
|
||||
|
||||
!!! REMOVE AS SOON AS WINDOW_OBJECT NO LONGER EXISTS !!!
|
||||
*/
|
||||
|
||||
if (*((PVOID*)Wnd) != NULL)
|
||||
return DesktopPtrToUser(*((PVOID*)Wnd));
|
||||
#endif
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PWINDOW
|
||||
FASTCALL
|
||||
GetThreadDesktopWnd(VOID)
|
||||
|
||||
@@ -1201,8 +1201,14 @@ IsIconic(HWND hWnd)
|
||||
BOOL STDCALL
|
||||
IsWindow(HWND hWnd)
|
||||
{
|
||||
DWORD WndProc = NtUserGetWindowLong(hWnd, GWL_WNDPROC, FALSE);
|
||||
return (0 != WndProc || ERROR_INVALID_WINDOW_HANDLE != GetLastError());
|
||||
PWINDOW Wnd = ValidateHwndNoErr(hWnd);
|
||||
if (Wnd != NULL)
|
||||
{
|
||||
/* FIXME: If window is being destroyed return FALSE! */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
@@ -1212,7 +1218,12 @@ IsWindow(HWND hWnd)
|
||||
BOOL STDCALL
|
||||
IsWindowUnicode(HWND hWnd)
|
||||
{
|
||||
return NtUserIsWindowUnicode(hWnd);
|
||||
PWINDOW Wnd = ValidateHwnd(hWnd);
|
||||
|
||||
if (Wnd != NULL)
|
||||
return Wnd->Unicode;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -115,6 +115,8 @@ typedef struct _WINDOW
|
||||
PWINDOWCLASS Class;
|
||||
/* Window name. */
|
||||
UNICODE_STRING WindowName;
|
||||
|
||||
UINT Unicode : 1;
|
||||
} WINDOW, *PWINDOW;
|
||||
|
||||
typedef struct _W32PROCESSINFO
|
||||
|
||||
@@ -78,7 +78,6 @@ typedef struct _WINDOW_OBJECT
|
||||
ULONG PropListItems;
|
||||
/* Scrollbar info */
|
||||
PWINDOW_SCROLLINFO Scroll;
|
||||
BOOL Unicode;
|
||||
WNDPROC WndProc;
|
||||
PETHREAD OwnerThread;
|
||||
HWND hWndLastPopup; /* handle to last active popup window (wine doesn't use pointer, for unk. reason)*/
|
||||
|
||||
@@ -385,7 +385,7 @@ NtUserDispatchMessage(PNTUSERDISPATCHMESSAGEINFO UnsafeMsgInfo)
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgInfo.Ansi = !Window->Unicode;
|
||||
MsgInfo.Ansi = !Window->Wnd->Unicode;
|
||||
MsgInfo.Proc = Window->WndProc;
|
||||
}
|
||||
}
|
||||
@@ -1390,7 +1390,7 @@ co_IntSendMessageTimeoutSingle(HWND hWnd,
|
||||
RETURN( FALSE);
|
||||
}
|
||||
|
||||
Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProc, !Window->Unicode, hWnd, Msg, wParam,
|
||||
Result = (ULONG_PTR)co_IntCallWindowProc(Window->WndProc, !Window->Wnd->Unicode, hWnd, Msg, wParam,
|
||||
lParamPacked,lParamBufferSize);
|
||||
|
||||
if(uResult)
|
||||
@@ -1566,7 +1566,7 @@ co_IntDoSendMessage(HWND hWnd,
|
||||
sizeof(BOOL));
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
Info.Ansi = ! Window->Unicode;
|
||||
Info.Ansi = ! Window->Wnd->Unicode;
|
||||
}
|
||||
|
||||
if (Window->IsSystem)
|
||||
@@ -1575,7 +1575,7 @@ co_IntDoSendMessage(HWND hWnd,
|
||||
}
|
||||
else
|
||||
{
|
||||
Info.Ansi = !Window->Unicode;
|
||||
Info.Ansi = !Window->Wnd->Unicode;
|
||||
Info.Proc = Window->WndProc;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ NtUserCallOneParam(
|
||||
{
|
||||
RETURN( FALSE);
|
||||
}
|
||||
Result = Window->Unicode;
|
||||
Result = Window->Wnd->Unicode;
|
||||
RETURN( Result);
|
||||
}
|
||||
|
||||
|
||||
@@ -525,7 +525,7 @@ IntGetWindowProc(IN PWINDOW_OBJECT Window,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Ansi == Window->Unicode)
|
||||
if (!Ansi == Wnd->Unicode)
|
||||
{
|
||||
return Window->WndProc;
|
||||
}
|
||||
@@ -541,12 +541,12 @@ IntGetWindowProc(IN PWINDOW_OBJECT Window,
|
||||
|
||||
NewCallProc = UserFindCallProc(Wnd->Class,
|
||||
Window->WndProc,
|
||||
Window->Unicode);
|
||||
Wnd->Unicode);
|
||||
if (NewCallProc == NULL)
|
||||
{
|
||||
NewCallProc = CreateCallProc(Wnd->ti->Desktop,
|
||||
Window->WndProc,
|
||||
Window->Unicode,
|
||||
Wnd->Unicode,
|
||||
Wnd->ti->kpi);
|
||||
if (NewCallProc == NULL)
|
||||
{
|
||||
@@ -1649,13 +1649,13 @@ AllocErr:
|
||||
if (Wnd->Class->System)
|
||||
{
|
||||
/* NOTE: Always create a unicode window for system classes! */
|
||||
Window->Unicode = TRUE;
|
||||
Wnd->Unicode = TRUE;
|
||||
Window->WndProc = Wnd->Class->WndProc;
|
||||
Window->WndProcExtra = Wnd->Class->WndProcExtra;
|
||||
}
|
||||
else
|
||||
{
|
||||
Window->Unicode = Wnd->Class->Unicode;
|
||||
Wnd->Unicode = Wnd->Class->Unicode;
|
||||
Window->WndProc = Wnd->Class->WndProc;
|
||||
Window->CallProc = NULL;
|
||||
}
|
||||
@@ -3614,7 +3614,7 @@ IntSetWindowProc(PWINDOW_OBJECT Window,
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!Ansi == Window->Unicode)
|
||||
if (!Ansi == Wnd->Unicode)
|
||||
{
|
||||
Ret = Window->WndProc;
|
||||
}
|
||||
@@ -3622,12 +3622,12 @@ IntSetWindowProc(PWINDOW_OBJECT Window,
|
||||
{
|
||||
CallProc = UserFindCallProc(Wnd->Class,
|
||||
Window->WndProc,
|
||||
Window->Unicode);
|
||||
Wnd->Unicode);
|
||||
if (CallProc == NULL)
|
||||
{
|
||||
CallProc = CreateCallProc(NULL,
|
||||
Window->WndProc,
|
||||
Window->Unicode,
|
||||
Wnd->Unicode,
|
||||
Wnd->ti->kpi);
|
||||
if (CallProc == NULL)
|
||||
{
|
||||
@@ -3656,7 +3656,7 @@ IntSetWindowProc(PWINDOW_OBJECT Window,
|
||||
{
|
||||
Window->WndProc = Wnd->Class->WndProc;
|
||||
Window->WndProcExtra = Wnd->Class->WndProcExtra;
|
||||
Window->Unicode = !Ansi;
|
||||
Wnd->Unicode = !Ansi;
|
||||
return Ret;
|
||||
}
|
||||
}
|
||||
@@ -3665,7 +3665,7 @@ IntSetWindowProc(PWINDOW_OBJECT Window,
|
||||
|
||||
/* update the window procedure */
|
||||
Window->WndProc = NewWndProc;
|
||||
Window->Unicode = !Ansi;
|
||||
Wnd->Unicode = !Ansi;
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user