2006-05-03 04:17:50 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS kernel
|
2011-09-20 19:41:33 +00:00
|
|
|
* PURPOSE: Callproc support
|
2015-11-10 17:41:55 +00:00
|
|
|
* FILE: win32ss/user/ntuser/callproc.c
|
2006-05-03 04:17:50 +00:00
|
|
|
* PROGRAMER: Thomas Weidenmueller <w3seek@reactos.com>
|
|
|
|
*/
|
|
|
|
|
2010-04-26 13:58:46 +00:00
|
|
|
#include <win32k.h>
|
2014-10-21 03:02:07 +00:00
|
|
|
DBG_DEFAULT_CHANNEL(UserClass);
|
2006-05-03 04:17:50 +00:00
|
|
|
|
|
|
|
/* CALLPROC ******************************************************************/
|
|
|
|
|
|
|
|
WNDPROC
|
2009-07-25 00:41:22 +00:00
|
|
|
GetCallProcHandle(IN PCALLPROCDATA CallProc)
|
2006-05-03 04:17:50 +00:00
|
|
|
{
|
2011-12-14 04:07:06 +00:00
|
|
|
/* FIXME: Check for 64 bit architectures... */
|
2010-01-15 13:47:25 +00:00
|
|
|
return (WNDPROC)((ULONG_PTR)UserHMGetHandle(CallProc) | 0xFFFF0000);
|
2006-05-03 04:17:50 +00:00
|
|
|
}
|
|
|
|
|
2014-09-21 17:44:40 +00:00
|
|
|
BOOLEAN
|
|
|
|
DestroyCallProc(_Inout_ PVOID Object)
|
2006-05-03 04:17:50 +00:00
|
|
|
{
|
2014-09-21 17:44:40 +00:00
|
|
|
UserDeleteObject(UserHMGetHandle((PCALLPROCDATA)Object), TYPE_CALLPROC);
|
|
|
|
return TRUE;
|
2006-05-03 04:17:50 +00:00
|
|
|
}
|
|
|
|
|
2009-07-25 00:41:22 +00:00
|
|
|
PCALLPROCDATA
|
2010-01-15 13:47:25 +00:00
|
|
|
CreateCallProc(IN PDESKTOP Desktop,
|
2006-05-03 04:17:50 +00:00
|
|
|
IN WNDPROC WndProc,
|
|
|
|
IN BOOL Unicode,
|
2009-03-30 05:45:08 +00:00
|
|
|
IN PPROCESSINFO pi)
|
2006-05-03 04:17:50 +00:00
|
|
|
{
|
2009-07-25 00:41:22 +00:00
|
|
|
PCALLPROCDATA NewCallProc;
|
2006-05-03 04:17:50 +00:00
|
|
|
HANDLE Handle;
|
|
|
|
|
2014-09-21 17:44:40 +00:00
|
|
|
/* We can send any thread pointer to the object manager here,
|
|
|
|
* What's important is the process info */
|
2009-07-25 00:41:22 +00:00
|
|
|
NewCallProc = (PCALLPROCDATA)UserCreateObject(gHandleTable,
|
2010-01-15 13:47:25 +00:00
|
|
|
Desktop,
|
2014-09-21 17:44:40 +00:00
|
|
|
pi->ptiList,
|
2006-05-03 04:17:50 +00:00
|
|
|
&Handle,
|
2012-12-29 19:14:30 +00:00
|
|
|
TYPE_CALLPROC,
|
2009-07-25 00:41:22 +00:00
|
|
|
sizeof(CALLPROCDATA));
|
2006-05-03 04:17:50 +00:00
|
|
|
if (NewCallProc != NULL)
|
|
|
|
{
|
2009-07-25 00:41:22 +00:00
|
|
|
NewCallProc->pfnClientPrevious = WndProc;
|
2009-09-07 04:55:00 +00:00
|
|
|
NewCallProc->wType |= Unicode ? UserGetCPDA2U : UserGetCPDU2A ;
|
2009-07-25 00:41:22 +00:00
|
|
|
NewCallProc->spcpdNext = NULL;
|
2006-05-03 04:17:50 +00:00
|
|
|
|
2017-02-22 10:29:03 +00:00
|
|
|
/* Release the extra reference (UserCreateObject added 2 references) */
|
|
|
|
UserDereferenceObject(NewCallProc);
|
|
|
|
}
|
2012-10-28 17:31:33 +00:00
|
|
|
|
2006-05-03 04:17:50 +00:00
|
|
|
return NewCallProc;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
UserGetCallProcInfo(IN HANDLE hCallProc,
|
|
|
|
OUT PWNDPROC_INFO wpInfo)
|
|
|
|
{
|
2009-07-25 00:41:22 +00:00
|
|
|
PCALLPROCDATA CallProc;
|
2006-05-03 04:17:50 +00:00
|
|
|
|
|
|
|
CallProc = UserGetObject(gHandleTable,
|
|
|
|
hCallProc,
|
2012-12-29 19:14:30 +00:00
|
|
|
TYPE_CALLPROC);
|
2006-05-03 04:17:50 +00:00
|
|
|
if (CallProc == NULL)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-07-25 00:41:22 +00:00
|
|
|
/* Use Handle pEntry->ppi!
|
2006-05-03 04:17:50 +00:00
|
|
|
if (CallProc->pi != GetW32ProcessInfo())
|
|
|
|
{
|
|
|
|
return FALSE;
|
2009-07-25 00:41:22 +00:00
|
|
|
}*/
|
2006-05-03 04:17:50 +00:00
|
|
|
|
2009-07-25 00:41:22 +00:00
|
|
|
wpInfo->WindowProc = CallProc->pfnClientPrevious;
|
2009-09-07 04:55:00 +00:00
|
|
|
wpInfo->IsUnicode = !!(CallProc->wType & UserGetCPDA2U);
|
2006-05-03 04:17:50 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2009-07-25 00:41:22 +00:00
|
|
|
|
2009-08-12 07:35:15 +00:00
|
|
|
/*
|
|
|
|
Based on UserFindCallProc.
|
|
|
|
*/
|
|
|
|
PCALLPROCDATA
|
|
|
|
FASTCALL
|
|
|
|
UserSearchForCallProc(
|
|
|
|
PCALLPROCDATA pcpd,
|
|
|
|
WNDPROC WndProc,
|
|
|
|
GETCPD Type)
|
|
|
|
{
|
|
|
|
while ( pcpd && (pcpd->pfnClientPrevious != WndProc || pcpd->wType != Type) )
|
|
|
|
{
|
|
|
|
pcpd = pcpd->spcpdNext;
|
|
|
|
}
|
|
|
|
return pcpd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Get Call Proc Data handle for the window proc being requested or create a
|
|
|
|
new Call Proc Data handle to be return for the requested window proc.
|
|
|
|
*/
|
|
|
|
ULONG_PTR
|
|
|
|
FASTCALL
|
|
|
|
UserGetCPD(
|
|
|
|
PVOID pvClsWnd,
|
|
|
|
GETCPD Flags,
|
|
|
|
ULONG_PTR ProcIn)
|
|
|
|
{
|
|
|
|
PCLS pCls;
|
|
|
|
PWND pWnd;
|
2014-10-21 03:02:07 +00:00
|
|
|
PDESKTOP pDesk;
|
2009-08-12 07:35:15 +00:00
|
|
|
PCALLPROCDATA CallProc = NULL;
|
|
|
|
PTHREADINFO pti;
|
|
|
|
|
|
|
|
pti = PsGetCurrentThreadWin32Thread();
|
|
|
|
|
|
|
|
if ( Flags & (UserGetCPDWindow|UserGetCPDDialog) ||
|
|
|
|
Flags & UserGetCPDWndtoCls)
|
|
|
|
{
|
|
|
|
pWnd = pvClsWnd;
|
|
|
|
pCls = pWnd->pcls;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pCls = pvClsWnd;
|
|
|
|
|
|
|
|
// Search Class call proc data list.
|
|
|
|
if (pCls->spcpdFirst)
|
|
|
|
CallProc = UserSearchForCallProc( pCls->spcpdFirst, (WNDPROC)ProcIn, Flags);
|
|
|
|
|
|
|
|
// No luck, create a new one for the requested proc.
|
|
|
|
if (!CallProc)
|
|
|
|
{
|
2014-10-21 03:02:07 +00:00
|
|
|
if (!pCls->rpdeskParent)
|
|
|
|
{
|
2015-03-10 00:12:41 +00:00
|
|
|
TRACE("Null DESKTOP Atom %u\n",pCls->atomClassName);
|
2014-10-21 03:02:07 +00:00
|
|
|
pDesk = pti->rpdesk;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
pDesk = pCls->rpdeskParent;
|
|
|
|
CallProc = CreateCallProc( pDesk,
|
2009-08-12 07:35:15 +00:00
|
|
|
(WNDPROC)ProcIn,
|
2009-09-07 04:55:00 +00:00
|
|
|
!!(Flags & UserGetCPDA2U),
|
2009-08-12 07:35:15 +00:00
|
|
|
pti->ppi);
|
|
|
|
if (CallProc)
|
|
|
|
{
|
|
|
|
CallProc->spcpdNext = pCls->spcpdFirst;
|
|
|
|
(void)InterlockedExchangePointer((PVOID*)&pCls->spcpdFirst,
|
|
|
|
CallProc);
|
|
|
|
CallProc->wType = Flags;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return (ULONG_PTR)(CallProc ? GetCallProcHandle(CallProc) : NULL);
|
|
|
|
}
|
|
|
|
|
2009-07-25 00:41:22 +00:00
|
|
|
/* SYSCALLS *****************************************************************/
|
|
|
|
|
2015-03-10 00:12:41 +00:00
|
|
|
/*
|
2009-07-25 00:41:22 +00:00
|
|
|
Retrieve the WinProcA/W or CallProcData handle for Class, Dialog or Window.
|
|
|
|
This Function called from user space uses Window handle for class, window
|
|
|
|
and dialog procs only.
|
|
|
|
|
|
|
|
Note:
|
|
|
|
ProcIn is the default proc from pCls/pDlg/pWnd->lpfnXxyz, caller is
|
|
|
|
looking for another type of proc if the original lpfnXxyz proc is preset
|
|
|
|
to Ansi or Unicode.
|
|
|
|
|
|
|
|
Example:
|
|
|
|
If pWnd is created from Ansi and lpfnXxyz is assumed to be Ansi, caller
|
|
|
|
will ask for Unicode Proc return Proc or CallProcData handle.
|
2010-06-03 16:12:43 +00:00
|
|
|
*/
|
2009-07-25 00:41:22 +00:00
|
|
|
ULONG_PTR
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetCPD(
|
|
|
|
HWND hWnd,
|
|
|
|
GETCPD Flags,
|
|
|
|
ULONG_PTR ProcIn)
|
|
|
|
{
|
|
|
|
PWND Wnd;
|
|
|
|
ULONG_PTR Result = 0;
|
|
|
|
|
|
|
|
UserEnterExclusive();
|
2010-10-11 03:41:41 +00:00
|
|
|
if (!(Wnd = UserGetWindowObject(hWnd)))
|
2015-03-10 00:12:41 +00:00
|
|
|
{
|
2009-07-25 00:41:22 +00:00
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
|
2009-08-12 07:35:15 +00:00
|
|
|
// Processing Window only from User space.
|
2015-03-10 00:12:41 +00:00
|
|
|
if ((Flags & ~(UserGetCPDU2A|UserGetCPDA2U)) != UserGetCPDClass)
|
2009-08-12 07:35:15 +00:00
|
|
|
Result = UserGetCPD(Wnd, Flags, ProcIn);
|
2009-07-25 00:41:22 +00:00
|
|
|
|
|
|
|
Cleanup:
|
|
|
|
UserLeave();
|
|
|
|
return Result;
|
|
|
|
}
|
|
|
|
|