ReactOS 0.4.16-dev-340-g0540c21
callproc.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * PURPOSE: Callproc support
5 * FILE: win32ss/user/ntuser/callproc.c
6 * PROGRAMER: Thomas Weidenmueller <w3seek@reactos.com>
7 */
8
9#include <win32k.h>
11
12/* CALLPROC ******************************************************************/
13
16{
17 /* FIXME: Check for 64 bit architectures... */
18 return (WNDPROC)((ULONG_PTR)UserHMGetHandle(CallProc) | 0xFFFF0000);
19}
20
23{
25 return TRUE;
26}
27
31 IN BOOL Unicode,
33{
34 PCALLPROCDATA NewCallProc;
36
37 /* We can send any thread pointer to the object manager here,
38 * What's important is the process info */
40 Desktop,
41 pi->ptiList,
42 &Handle,
44 sizeof(CALLPROCDATA));
45 if (NewCallProc != NULL)
46 {
47 NewCallProc->pfnClientPrevious = WndProc;
48 NewCallProc->wType |= Unicode ? UserGetCPDA2U : UserGetCPDU2A ;
49 NewCallProc->spcpdNext = NULL;
50
51 /* Release the extra reference (UserCreateObject added 2 references) */
52 UserDereferenceObject(NewCallProc);
53 }
54
55 return NewCallProc;
56}
57
58BOOL
60 OUT PWNDPROC_INFO wpInfo)
61{
62 PCALLPROCDATA CallProc;
63
64 CallProc = UserGetObject(gHandleTable,
65 hCallProc,
67 if (CallProc == NULL)
68 {
69 return FALSE;
70 }
71
72/* Use Handle pEntry->ppi!
73 if (CallProc->pi != GetW32ProcessInfo())
74 {
75 return FALSE;
76 }*/
77
78 wpInfo->WindowProc = CallProc->pfnClientPrevious;
79 wpInfo->IsUnicode = !!(CallProc->wType & UserGetCPDA2U);
80
81 return TRUE;
82}
83
84/*
85 Based on UserFindCallProc.
86 */
90 PCALLPROCDATA pcpd,
93{
94 while ( pcpd && (pcpd->pfnClientPrevious != WndProc || pcpd->wType != Type) )
95 {
96 pcpd = pcpd->spcpdNext;
97 }
98 return pcpd;
99}
100
101/*
102 Get Call Proc Data handle for the window proc being requested or create a
103 new Call Proc Data handle to be return for the requested window proc.
104 */
108 PVOID pvClsWnd,
110 ULONG_PTR ProcIn)
111{
112 PCLS pCls;
113 PWND pWnd;
114 PDESKTOP pDesk;
115 PCALLPROCDATA CallProc = NULL;
116 PTHREADINFO pti;
117
119
122 {
123 pWnd = pvClsWnd;
124 pCls = pWnd->pcls;
125 }
126 else
127 pCls = pvClsWnd;
128
129 // Search Class call proc data list.
130 if (pCls->spcpdFirst)
131 CallProc = UserSearchForCallProc( pCls->spcpdFirst, (WNDPROC)ProcIn, Flags);
132
133 // No luck, create a new one for the requested proc.
134 if (!CallProc)
135 {
136 if (!pCls->rpdeskParent)
137 {
138 TRACE("Null DESKTOP Atom %u\n",pCls->atomClassName);
139 pDesk = pti->rpdesk;
140 }
141 else
142 pDesk = pCls->rpdeskParent;
143 CallProc = CreateCallProc( pDesk,
144 (WNDPROC)ProcIn,
145 !!(Flags & UserGetCPDA2U),
146 pti->ppi);
147 if (CallProc)
148 {
149 CallProc->spcpdNext = pCls->spcpdFirst;
151 CallProc);
152 CallProc->wType = Flags;
153 }
154 }
155 return (ULONG_PTR)(CallProc ? GetCallProcHandle(CallProc) : NULL);
156}
157
158/* SYSCALLS *****************************************************************/
159
160/*
161 Retrieve the WinProcA/W or CallProcData handle for Class, Dialog or Window.
162 This Function called from user space uses Window handle for class, window
163 and dialog procs only.
164
165 Note:
166 ProcIn is the default proc from pCls/pDlg/pWnd->lpfnXxyz, caller is
167 looking for another type of proc if the original lpfnXxyz proc is preset
168 to Ansi or Unicode.
169
170 Example:
171 If pWnd is created from Ansi and lpfnXxyz is assumed to be Ansi, caller
172 will ask for Unicode Proc return Proc or CallProcData handle.
173*/
177 HWND hWnd,
179 ULONG_PTR ProcIn)
180{
181 PWND Wnd;
182 ULONG_PTR Result = 0;
183
185 if (!(Wnd = UserGetWindowObject(hWnd)))
186 {
187 goto Cleanup;
188 }
189
190 // Processing Window only from User space.
192 Result = UserGetCPD(Wnd, Flags, ProcIn);
193
194Cleanup:
195 UserLeave();
196 return Result;
197}
198
unsigned char BOOLEAN
Type
Definition: Type.h:7
HWND hWnd
Definition: settings.c:17
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
PCALLPROCDATA CreateCallProc(IN PDESKTOP Desktop, IN WNDPROC WndProc, IN BOOL Unicode, IN PPROCESSINFO pi)
Definition: callproc.c:29
ULONG_PTR FASTCALL UserGetCPD(PVOID pvClsWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:107
BOOL UserGetCallProcInfo(IN HANDLE hCallProc, OUT PWNDPROC_INFO wpInfo)
Definition: callproc.c:59
ULONG_PTR APIENTRY NtUserGetCPD(HWND hWnd, GETCPD Flags, ULONG_PTR ProcIn)
Definition: callproc.c:176
WNDPROC GetCallProcHandle(IN PCALLPROCDATA CallProc)
Definition: callproc.c:15
PCALLPROCDATA FASTCALL UserSearchForCallProc(PCALLPROCDATA pcpd, WNDPROC WndProc, GETCPD Type)
Definition: callproc.c:89
BOOLEAN DestroyCallProc(_Inout_ PVOID Object)
Definition: callproc.c:22
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define APIENTRY
Definition: api.h:79
static const WCHAR Cleanup[]
Definition: register.c:80
#define ULONG_PTR
Definition: config.h:101
#define InterlockedExchangePointer(Target, Value)
Definition: dshow.h:45
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG Handle
Definition: gdb_input.c:15
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
@ UserGetCPDWndtoCls
Definition: ntuser.h:545
@ UserGetCPDClass
Definition: ntuser.h:542
@ UserGetCPDU2A
Definition: ntuser.h:541
@ UserGetCPDDialog
Definition: ntuser.h:544
@ UserGetCPDWindow
Definition: ntuser.h:543
@ UserGetCPDA2U
Definition: ntuser.h:540
struct _CALLPROCDATA * PCALLPROCDATA
@ TYPE_CALLPROC
Definition: ntuser.h:47
enum _GETCPD GETCPD
static refpint_t pi[]
Definition: server.c:96
#define _Inout_
Definition: no_sal2.h:162
#define FASTCALL
Definition: nt_native.h:50
PVOID NTAPI PsGetCurrentThreadWin32Thread(VOID)
Definition: thread.c:805
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT CALLBACK WndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
Definition: solitaire.cpp:614
GETCPD wType
Definition: ntuser.h:553
WNDPROC pfnClientPrevious
Definition: ntuser.h:552
struct _CALLPROCDATA * spcpdNext
Definition: ntuser.h:551
Definition: ntuser.h:566
struct _DESKTOP * rpdeskParent
Definition: ntuser.h:571
PCALLPROCDATA spcpdFirst
Definition: ntuser.h:576
RTL_ATOM atomClassName
Definition: ntuser.h:568
PPROCESSINFO ppi
Definition: win32.h:88
struct _DESKTOP * rpdesk
Definition: win32.h:92
Definition: ntuser.h:694
PCLS pcls
Definition: ntuser.h:720
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
#define OUT
Definition: typedefs.h:40
PWND FASTCALL UserGetWindowObject(HWND hWnd)
Definition: window.c:124
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
PVOID UserGetObject(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:495
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2909
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170