ReactOS 0.4.15-dev-7659-ga55345b
ddeserver.c File Reference
#include <user32.h>
Include dependency graph for ddeserver.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddeml)
 
static LRESULT CALLBACK WDML_ServerNameProc (HWND, UINT, WPARAM, LPARAM)
 
static LRESULT CALLBACK WDML_ServerConvProc (HWND, UINT, WPARAM, LPARAM)
 
BOOL WINAPI DdePostAdvise (DWORD idInst, HSZ hszTopic, HSZ hszItem)
 
HDDEDATA WINAPI DdeNameService (DWORD idInst, HSZ hsz1, HSZ hsz2, UINT afCmd)
 
static WDML_CONVWDML_CreateServerConv (WDML_INSTANCE *pInstance, HWND hwndClient, HWND hwndServerName, HSZ hszApp, HSZ hszTopic)
 
static WDML_XACTWDML_ServerQueueRequest (WDML_CONV *pConv, LPARAM lParam)
 
static WDML_QUEUE_STATE WDML_ServerHandleRequest (WDML_CONV *pConv, WDML_XACT *pXAct)
 
static WDML_XACTWDML_ServerQueueAdvise (WDML_CONV *pConv, LPARAM lParam)
 
static WDML_QUEUE_STATE WDML_ServerHandleAdvise (WDML_CONV *pConv, WDML_XACT *pXAct)
 
static WDML_XACTWDML_ServerQueueUnadvise (WDML_CONV *pConv, LPARAM lParam)
 
static WDML_QUEUE_STATE WDML_ServerHandleUnadvise (WDML_CONV *pConv, WDML_XACT *pXAct)
 
static WDML_XACTWDML_ServerQueueExecute (WDML_CONV *pConv, LPARAM lParam)
 
static BOOL data_looks_unicode (const WCHAR *data, DWORD size)
 
static HDDEDATA map_A_to_W (DWORD instance, void *ptr, DWORD size)
 
static HDDEDATA map_W_to_A (DWORD instance, void *ptr, DWORD size)
 
static WDML_QUEUE_STATE WDML_ServerHandleExecute (WDML_CONV *pConv, WDML_XACT *pXAct)
 
static WDML_XACTWDML_ServerQueuePoke (WDML_CONV *pConv, LPARAM lParam)
 
static WDML_QUEUE_STATE WDML_ServerHandlePoke (WDML_CONV *pConv, WDML_XACT *pXAct)
 
static WDML_XACTWDML_ServerQueueTerminate (WDML_CONV *pConv, LPARAM lParam)
 
static WDML_QUEUE_STATE WDML_ServerHandleTerminate (WDML_CONV *pConv, WDML_XACT *pXAct)
 
WDML_QUEUE_STATE WDML_ServerHandle (WDML_CONV *pConv, WDML_XACT *pXAct)
 

Variables

static const WCHAR szServerNameClass [] = L"DDEMLMom"
 
const char WDML_szServerConvClassA [] = "DDEMLAnsiServer"
 
const WCHAR WDML_szServerConvClassW [] = L"DDEMLUnicodeServer"
 

Function Documentation

◆ data_looks_unicode()

static BOOL data_looks_unicode ( const WCHAR data,
DWORD  size 
)
static

Definition at line 749 of file ddeserver.c.

750{
751 DWORD i;
752
753 if (size % sizeof(WCHAR)) return FALSE;
754 for (i = 0; i < size / sizeof(WCHAR); i++) if (data[i] > 255) return FALSE;
755 return TRUE;
756}
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by map_A_to_W(), and map_W_to_A().

◆ DdeNameService()

HDDEDATA WINAPI DdeNameService ( DWORD  idInst,
HSZ  hsz1,
HSZ  hsz2,
UINT  afCmd 
)

Definition at line 154 of file ddeserver.c.

155{
156 WDML_SERVER* pServer;
158 HWND hwndServer;
159 WNDCLASSEXW wndclass;
160
161 TRACE("(%d,%p,%p,%x)\n", idInst, hsz1, hsz2, afCmd);
162
163 /* First check instance
164 */
165 pInstance = WDML_GetInstance(idInst);
166 if (pInstance == NULL)
167 {
168 TRACE("Instance not found as initialised\n");
169 /* Nothing has been initialised - exit now ! can return TRUE since effect is the same */
170 return NULL;
171 }
172
173 if (hsz2 != 0L)
174 {
175 /* Illegal, reserved parameter
176 */
178 WARN("Reserved parameter no-zero !!\n");
179 return NULL;
180 }
181 if (hsz1 == 0 && !(afCmd & DNS_UNREGISTER))
182 {
183 /* don't know if we should check this but it makes sense
184 * why supply REGISTER or filter flags if de-registering all
185 */
186 TRACE("General unregister unexpected flags\n");
188 return NULL;
189 }
190
191 switch (afCmd & (DNS_REGISTER | DNS_UNREGISTER))
192 {
193 case DNS_REGISTER:
194 pServer = WDML_FindServer(pInstance, hsz1, 0);
195 if (pServer)
196 {
197 ERR("Trying to register already registered service!\n");
198 pInstance->lastError = DMLERR_DLL_USAGE;
199 return NULL;
200 }
201
202 TRACE("Adding service name\n");
203
204 WDML_IncHSZ(pInstance, hsz1);
205
206 pServer = WDML_AddServer(pInstance, hsz1, 0);
207
209 pServer->atomService, pServer->atomServiceSpec);
210
211 wndclass.cbSize = sizeof(wndclass);
212 wndclass.style = 0;
214 wndclass.cbClsExtra = 0;
215 wndclass.cbWndExtra = 2 * sizeof(ULONG_PTR);
216 wndclass.hInstance = 0;
217 wndclass.hIcon = 0;
218 wndclass.hCursor = 0;
219 wndclass.hbrBackground = 0;
220 wndclass.lpszMenuName = NULL;
222 wndclass.hIconSm = 0;
223
224 RegisterClassExW(&wndclass);
225
227 WS_POPUP, 0, 0, 0, 0,
228 0, 0, 0, 0);
229
231 SetWindowLongPtrW(hwndServer, GWL_WDML_SERVER, (ULONG_PTR)pServer);
232 TRACE("Created nameServer=%p for instance=%08x\n", hwndServer, idInst);
233
234 pServer->hwndServer = hwndServer;
235 break;
236
237 case DNS_UNREGISTER:
238 if (hsz1 == 0L)
239 {
240 /* General unregister situation
241 * terminate all server side pending conversations
242 */
243 while (pInstance->servers)
244 WDML_RemoveServer(pInstance, pInstance->servers->hszService, 0);
245 pInstance->servers = NULL;
246 TRACE("General de-register - finished\n");
247 }
248 else
249 {
251 }
252 break;
253 }
254
255 if (afCmd & (DNS_FILTERON | DNS_FILTEROFF))
256 {
257 /* Set filter flags on to hold notifications of connection
258 */
259 pServer = WDML_FindServer(pInstance, hsz1, 0);
260 if (!pServer)
261 {
262 /* trying to filter where no service names !!
263 */
264 pInstance->lastError = DMLERR_DLL_USAGE;
265 return NULL;
266 }
267 else
268 {
269 pServer->filterOn = (afCmd & DNS_FILTERON) != 0;
270 }
271 }
272 return (HDDEDATA)TRUE;
273}
#define WARN(fmt,...)
Definition: debug.h:112
#define ERR(fmt,...)
Definition: debug.h:110
#define GWL_WDML_SERVER
Definition: dde_private.h:261
void WDML_RemoveServer(WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic) DECLSPEC_HIDDEN
Definition: ddemisc.c:1670
#define WM_WDML_REGISTER
Definition: dde_private.h:248
WDML_SERVER * WDML_FindServer(WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic) DECLSPEC_HIDDEN
Definition: ddemisc.c:1729
WDML_INSTANCE * WDML_GetInstance(DWORD InstId) DECLSPEC_HIDDEN
Definition: ddemisc.c:1230
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz) DECLSPEC_HIDDEN
Definition: ddemisc.c:362
WDML_SERVER * WDML_AddServer(WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic) DECLSPEC_HIDDEN
Definition: ddemisc.c:1638
void WDML_BroadcastDDEWindows(LPCWSTR clsName, UINT uMsg, WPARAM wParam, LPARAM lParam) DECLSPEC_HIDDEN
Definition: ddemisc.c:2502
#define GWL_WDML_INSTANCE
Definition: dde_private.h:259
const WCHAR WDML_szEventClass[]
Definition: ddemisc.c:38
#define DNS_FILTEROFF
Definition: ddeml.h:155
#define DNS_UNREGISTER
Definition: ddeml.h:153
#define DNS_REGISTER
Definition: ddeml.h:152
#define DMLERR_DLL_USAGE
Definition: ddeml.h:250
#define DNS_FILTERON
Definition: ddeml.h:154
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
static LRESULT CALLBACK WDML_ServerNameProc(HWND, UINT, WPARAM, LPARAM)
Definition: ddeserver.c:365
static const WCHAR szServerNameClass[]
Definition: ddeserver.c:30
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
FxWmiInstanceExternal * pInstance
Definition: fxwmiapi.cpp:113
#define L(x)
Definition: ntvdm.h:50
#define WS_POPUP
Definition: pedump.c:616
#define TRACE(s)
Definition: solgame.cpp:4
LPCWSTR lpszClassName
Definition: winuser.h:3225
LPCWSTR lpszMenuName
Definition: winuser.h:3224
HBRUSH hbrBackground
Definition: winuser.h:3223
WNDPROC lpfnWndProc
Definition: winuser.h:3217
UINT cbSize
Definition: winuser.h:3215
int cbWndExtra
Definition: winuser.h:3219
HCURSOR hCursor
Definition: winuser.h:3222
HICON hIconSm
Definition: winuser.h:3226
HINSTANCE hInstance
Definition: winuser.h:3220
UINT style
Definition: winuser.h:3216
int cbClsExtra
Definition: winuser.h:3218
HICON hIcon
Definition: winuser.h:3221
ATOM atomServiceSpec
Definition: dde_private.h:104
uint32_t ULONG_PTR
Definition: typedefs.h:65
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4315
#define SetWindowLongPtrW
Definition: winuser.h:5345

Referenced by DdeUninitialize(), doChild(), init_dde(), release_dde(), ShellDDEInit(), test_dde_default_app(), test_ddeml_server(), and test_end_to_end_server().

◆ DdePostAdvise()

BOOL WINAPI DdePostAdvise ( DWORD  idInst,
HSZ  hszTopic,
HSZ  hszItem 
)

Definition at line 49 of file ddeserver.c.

50{
52 WDML_LINK* pLink;
53 HDDEDATA hDdeData;
54 HGLOBAL hItemData;
55 WDML_CONV* pConv;
56 ATOM atom;
57 UINT count;
58
59 TRACE("(%d,%p,%p)\n", idInst, hszTopic, hszItem);
60
62
63 if (pInstance == NULL)
64 return FALSE;
65
66 atom = WDML_MakeAtomFromHsz(hszItem);
67 if (!atom) return FALSE;
68
69 /* first compute the number of links which will trigger a message */
70 count = 0;
71 for (pLink = pInstance->links[WDML_SERVER_SIDE]; pLink != NULL; pLink = pLink->next)
72 {
73 if (DdeCmpStringHandles(hszItem, pLink->hszItem) == 0)
74 {
75 count++;
76 }
77 }
78 if (count >= CADV_LATEACK)
79 {
80 FIXME("too high value for count\n");
81 count &= 0xFFFF;
82 }
83
84 for (pLink = pInstance->links[WDML_SERVER_SIDE]; pLink != NULL; pLink = pLink->next)
85 {
86 if (DdeCmpStringHandles(hszItem, pLink->hszItem) == 0)
87 {
88 hDdeData = WDML_InvokeCallback(pInstance, XTYP_ADVREQ, pLink->uFmt, pLink->hConv,
89 hszTopic, hszItem, 0, --count, 0);
90
91 if (hDdeData == CBR_BLOCK)
92 {
93 /* MS doc is not consistent here */
94 FIXME("CBR_BLOCK returned for ADVREQ\n");
95 continue;
96 }
97 if (hDdeData)
98 {
99 if (pLink->transactionType & XTYPF_NODATA)
100 {
101 TRACE("no data\n");
102 hItemData = 0;
103 }
104 else
105 {
106 TRACE("with data\n");
107
108 hItemData = WDML_DataHandle2Global(hDdeData, FALSE, FALSE, FALSE, FALSE);
109 }
110
111 pConv = WDML_GetConv(pLink->hConv, TRUE);
112
113 if (pConv == NULL)
114 {
115 if (!WDML_IsAppOwned(hDdeData)) DdeFreeDataHandle(hDdeData);
116 goto theError;
117 }
118
120 PackDDElParam(WM_DDE_DATA, (UINT_PTR)hItemData, atom)))
121 {
122 ERR("post message failed\n");
123 pConv->wStatus &= ~ST_CONNECTED;
124 pConv->instance->lastError = DMLERR_POSTMSG_FAILED;
125 if (!WDML_IsAppOwned(hDdeData)) DdeFreeDataHandle(hDdeData);
126 GlobalFree(hItemData);
127 goto theError;
128 }
129 if (!WDML_IsAppOwned(hDdeData)) DdeFreeDataHandle(hDdeData);
130 }
131 }
132 }
133 return TRUE;
134
135 theError:
136 GlobalDeleteAtom(atom);
137 return FALSE;
138}
#define FIXME(fmt,...)
Definition: debug.h:111
#define WM_DDE_DATA
Definition: dde.h:42
LPARAM WINAPI PackDDElParam(UINT, UINT_PTR, UINT_PTR)
Definition: ddemisc.c:63
HDDEDATA WDML_InvokeCallback(WDML_INSTANCE *pInst, UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG_PTR dwData1, ULONG_PTR dwData2) DECLSPEC_HIDDEN
Definition: ddemisc.c:1206
ATOM WDML_MakeAtomFromHsz(HSZ hsz) DECLSPEC_HIDDEN
Definition: ddemisc.c:325
HGLOBAL WDML_DataHandle2Global(HDDEDATA hDdeData, BOOL fResponse, BOOL fRelease, BOOL fDeferUpd, BOOL dAckReq) DECLSPEC_HIDDEN
Definition: ddemisc.c:1563
WDML_CONV * WDML_GetConv(HCONV hConv, BOOL checkConnected) DECLSPEC_HIDDEN
Definition: ddemisc.c:2230
@ WDML_SERVER_SIDE
Definition: dde_private.h:181
BOOL WDML_IsAppOwned(HDDEDATA hDdeData) DECLSPEC_HIDDEN
Definition: ddemisc.c:1477
#define XTYP_ADVREQ
Definition: ddeml.h:182
#define XTYPF_NODATA
Definition: ddeml.h:171
INT WINAPI DdeCmpStringHandles(HSZ, HSZ)
Definition: ddemisc.c:685
#define DMLERR_POSTMSG_FAILED
Definition: ddeml.h:258
#define CBR_BLOCK
Definition: ddeml.h:117
#define CADV_LATEACK
Definition: ddeml.h:202
BOOL WINAPI DdeFreeDataHandle(HDDEDATA)
Definition: ddemisc.c:1461
WORD ATOM
Definition: dimm.idl:113
ATOM WINAPI GlobalDeleteAtom(ATOM nAtom)
Definition: atom.c:454
GLuint GLuint GLsizei count
Definition: gl.h:1545
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
unsigned int UINT
Definition: ndis.h:50
static HSZ hszTopic
Definition: shlexec.c:148
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

◆ map_A_to_W()

static HDDEDATA map_A_to_W ( DWORD  instance,
void ptr,
DWORD  size 
)
static

Definition at line 759 of file ddeserver.c.

760{
761 HDDEDATA ret;
762 DWORD len;
763 const char *end;
764
765 if (!data_looks_unicode( ptr, size ))
766 {
767 if ((end = memchr( ptr, 0, size ))) size = end + 1 - (const char *)ptr;
769 ret = DdeCreateDataHandle( instance, NULL, len * sizeof(WCHAR), 0, 0, CF_TEXT, 0);
771 }
772 else ret = DdeCreateDataHandle( instance, ptr, size, 0, 0, CF_TEXT, 0 );
773
774 return ret;
775}
#define CF_TEXT
Definition: constants.h:396
HDDEDATA WINAPI DdeCreateDataHandle(DWORD, LPBYTE, DWORD, DWORD, HSZ, UINT, UINT)
Definition: ddemisc.c:1275
LPBYTE WINAPI DdeAccessData(HDDEDATA, LPDWORD)
Definition: ddemisc.c:1422
static BOOL data_looks_unicode(const WCHAR *data, DWORD size)
Definition: ddeserver.c:749
static HINSTANCE instance
Definition: main.c:40
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLuint GLuint end
Definition: gl.h:1545
GLenum GLsizei len
Definition: glext.h:6722
#define memchr(s, c, n)
Definition: mkisofs.h:875
static PVOID ptr
Definition: dispmode.c:27
int ret

Referenced by WDML_ServerHandleExecute().

◆ map_W_to_A()

static HDDEDATA map_W_to_A ( DWORD  instance,
void ptr,
DWORD  size 
)
static

Definition at line 778 of file ddeserver.c.

779{
780 HDDEDATA ret;
781 DWORD len;
782 const WCHAR *end;
783
785 {
786 size /= sizeof(WCHAR);
787 if ((end = memchrW( ptr, 0, size ))) size = end + 1 - (const WCHAR *)ptr;
791 }
792 else ret = DdeCreateDataHandle( instance, ptr, size, 0, 0, CF_TEXT, 0 );
793
794 return ret;
795}
#define WideCharToMultiByte
Definition: compat.h:111
WINE_UNICODE_INLINE WCHAR * memchrW(const WCHAR *ptr, WCHAR ch, size_t n)
Definition: unicode.h:295

Referenced by WDML_ServerHandleExecute().

◆ WDML_CreateServerConv()

static WDML_CONV * WDML_CreateServerConv ( WDML_INSTANCE pInstance,
HWND  hwndClient,
HWND  hwndServerName,
HSZ  hszApp,
HSZ  hszTopic 
)
static

Definition at line 280 of file ddeserver.c.

282{
283 HWND hwndServerConv;
284 WDML_CONV* pConv;
285
286 if (pInstance->unicode)
287 {
288 WNDCLASSEXW wndclass;
289
290 wndclass.cbSize = sizeof(wndclass);
291 wndclass.style = 0;
293 wndclass.cbClsExtra = 0;
294 wndclass.cbWndExtra = 2 * sizeof(ULONG_PTR);
295 wndclass.hInstance = 0;
296 wndclass.hIcon = 0;
297 wndclass.hCursor = 0;
298 wndclass.hbrBackground = 0;
299 wndclass.lpszMenuName = NULL;
301 wndclass.hIconSm = 0;
302
303 RegisterClassExW(&wndclass);
304
305 hwndServerConv = CreateWindowW(WDML_szServerConvClassW, 0,
306 WS_CHILD, 0, 0, 0, 0,
307 hwndServerName, 0, 0, 0);
308 }
309 else
310 {
311 WNDCLASSEXA wndclass;
312
313 wndclass.cbSize = sizeof(wndclass);
314 wndclass.style = 0;
316 wndclass.cbClsExtra = 0;
317 wndclass.cbWndExtra = 2 * sizeof(ULONG_PTR);
318 wndclass.hInstance = 0;
319 wndclass.hIcon = 0;
320 wndclass.hCursor = 0;
321 wndclass.hbrBackground = 0;
322 wndclass.lpszMenuName = NULL;
324 wndclass.hIconSm = 0;
325
326 RegisterClassExA(&wndclass);
327
328 hwndServerConv = CreateWindowA(WDML_szServerConvClassA, 0,
329 WS_CHILD, 0, 0, 0, 0,
330 hwndServerName, 0, 0, 0);
331 }
332
333 TRACE("Created convServer=%p (nameServer=%p) for instance=%08x unicode=%d\n",
334 hwndServerConv, hwndServerName, pInstance->instanceID, pInstance->unicode);
335
337 hwndClient, hwndServerConv);
338 if (pConv)
339 {
341 SetWindowLongPtrW(hwndServerConv, GWL_WDML_CONVERSATION, (ULONG_PTR)pConv);
342
343 /* this should be the only place using SendMessage for WM_DDE_ACK */
344 /* note: sent messages shall not use packing */
345 SendMessageW(hwndClient, WM_DDE_ACK, (WPARAM)hwndServerConv,
347 /* we assume we're connected since we've sent an answer...
348 * I'm not sure what we can do... it doesn't look like the return value
349 * of SendMessage is used... sigh...
350 */
351 pConv->wStatus |= ST_CONNECTED;
352 }
353 else
354 {
355 DestroyWindow(hwndServerConv);
356 }
357 return pConv;
358}
#define WM_DDE_ACK
Definition: dde.h:41
#define GWL_WDML_CONVERSATION
Definition: dde_private.h:260
WDML_CONV * WDML_AddConv(WDML_INSTANCE *pInstance, WDML_SIDE side, HSZ hszService, HSZ hszTopic, HWND hwndClient, HWND hwndServer) DECLSPEC_HIDDEN
Definition: ddemisc.c:2008
#define ST_CONNECTED
Definition: ddeml.h:80
const WCHAR WDML_szServerConvClassW[]
Definition: ddeserver.c:32
const char WDML_szServerConvClassA[]
Definition: ddeserver.c:31
static LRESULT CALLBACK WDML_ServerConvProc(HWND, UINT, WPARAM, LPARAM)
Definition: ddeserver.c:1016
#define WS_CHILD
Definition: pedump.c:617
int cbClsExtra
Definition: winuser.h:3203
HINSTANCE hInstance
Definition: winuser.h:3205
HCURSOR hCursor
Definition: winuser.h:3207
LPCSTR lpszMenuName
Definition: winuser.h:3209
HICON hIconSm
Definition: winuser.h:3211
UINT style
Definition: winuser.h:3201
int cbWndExtra
Definition: winuser.h:3204
UINT cbSize
Definition: winuser.h:3200
WNDPROC lpfnWndProc
Definition: winuser.h:3202
LPCSTR lpszClassName
Definition: winuser.h:3210
HICON hIcon
Definition: winuser.h:3206
HBRUSH hbrBackground
Definition: winuser.h:3208
#define MAKELPARAM(l, h)
Definition: winuser.h:4007
#define CreateWindowA(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4314
ATOM WINAPI RegisterClassExA(_In_ CONST WNDCLASSEXA *)
BOOL WINAPI DestroyWindow(_In_ HWND)
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by WDML_ServerNameProc().

◆ WDML_ServerConvProc()

static LRESULT CALLBACK WDML_ServerConvProc ( HWND  hwndServer,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 1016 of file ddeserver.c.

1017{
1019 WDML_CONV* pConv;
1020 WDML_XACT* pXAct = NULL;
1021
1022 TRACE("%p %04x %08lx %08lx\n", hwndServer, iMsg, wParam, lParam);
1023
1024 if (iMsg == WM_DESTROY)
1025 {
1026 pConv = WDML_GetConvFromWnd(hwndServer);
1027 if (pConv && !(pConv->wStatus & ST_TERMINATED))
1028 {
1030 }
1031 }
1032 if (iMsg < WM_DDE_FIRST || iMsg > WM_DDE_LAST)
1033 {
1034 return IsWindowUnicode(hwndServer) ? DefWindowProcW(hwndServer, iMsg, wParam, lParam) :
1035 DefWindowProcA(hwndServer, iMsg, wParam, lParam);
1036 }
1037
1038 pInstance = WDML_GetInstanceFromWnd(hwndServer);
1039 pConv = WDML_GetConvFromWnd(hwndServer);
1040
1041 if (!pConv)
1042 {
1043 ERR("Got a message (%x) on a not known conversation, dropping request\n", iMsg);
1044 return 0;
1045 }
1046 if (pConv->hwndClient != WIN_GetFullHandle( (HWND)wParam ) || pConv->hwndServer != hwndServer)
1047 {
1048 ERR("mismatch between C/S windows and conversation\n");
1049 return 0;
1050 }
1051 if (pConv->instance != pInstance || pConv->instance == NULL)
1052 {
1053 ERR("mismatch in instances\n");
1054 return 0;
1055 }
1056
1057 switch (iMsg)
1058 {
1059 case WM_DDE_INITIATE:
1060 FIXME("WM_DDE_INITIATE message received!\n");
1061 break;
1062
1063 case WM_DDE_REQUEST:
1064 pXAct = WDML_ServerQueueRequest(pConv, lParam);
1065 break;
1066
1067 case WM_DDE_ADVISE:
1068 pXAct = WDML_ServerQueueAdvise(pConv, lParam);
1069 break;
1070
1071 case WM_DDE_UNADVISE:
1072 pXAct = WDML_ServerQueueUnadvise(pConv, lParam);
1073 break;
1074
1075 case WM_DDE_EXECUTE:
1076 pXAct = WDML_ServerQueueExecute(pConv, lParam);
1077 break;
1078
1079 case WM_DDE_POKE:
1080 pXAct = WDML_ServerQueuePoke(pConv, lParam);
1081 break;
1082
1083 case WM_DDE_TERMINATE:
1084 pXAct = WDML_ServerQueueTerminate(pConv, lParam);
1085 break;
1086
1087 case WM_DDE_ACK:
1088 WARN("Shouldn't receive a ACK message (never requests them). Ignoring it\n");
1089 break;
1090
1091 default:
1092 FIXME("Unsupported message %x\n", iMsg);
1093 break;
1094 }
1095
1096 if (pXAct)
1097 {
1098 pXAct->lParam = lParam;
1099
1100 if ((pConv->wStatus & ST_BLOCKED) || WDML_ServerHandle(pConv, pXAct) == WDML_QS_BLOCK)
1101 {
1102 TRACE("Transactions are blocked, add to the queue and exit\n");
1103 WDML_QueueTransaction(pConv, pXAct);
1104 }
1105 else
1106 {
1108 }
1109 }
1110 else
1111 pConv->instance->lastError = DMLERR_MEMORY_ERROR;
1112
1113 return 0;
1114}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define WM_DDE_REQUEST
Definition: dde.h:43
#define WM_DDE_POKE
Definition: dde.h:44
#define WM_DDE_LAST
Definition: dde.h:46
#define WM_DDE_ADVISE
Definition: dde.h:39
#define WM_DDE_EXECUTE
Definition: dde.h:45
#define WM_DDE_INITIATE
Definition: dde.h:37
#define WM_DDE_UNADVISE
Definition: dde.h:40
#define WM_DDE_TERMINATE
Definition: dde.h:38
WDML_INSTANCE * WDML_GetInstanceFromWnd(HWND hWnd) DECLSPEC_HIDDEN
Definition: ddemisc.c:1261
WDML_CONV * WDML_GetConvFromWnd(HWND hWnd) DECLSPEC_HIDDEN
Definition: ddemisc.c:2265
void WDML_FreeTransaction(WDML_INSTANCE *pInstance, WDML_XACT *pXAct, BOOL doFreePmt) DECLSPEC_HIDDEN
Definition: ddemisc.c:1967
@ WDML_QS_BLOCK
Definition: dde_private.h:185
void WDML_QueueTransaction(WDML_CONV *pConv, WDML_XACT *pXAct) DECLSPEC_HIDDEN
Definition: ddemisc.c:1933
#define DMLERR_MEMORY_ERROR
Definition: ddeml.h:254
#define ST_BLOCKED
Definition: ddeml.h:83
#define ST_TERMINATED
Definition: ddeml.h:85
WDML_QUEUE_STATE WDML_ServerHandle(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:968
static WDML_XACT * WDML_ServerQueueAdvise(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:584
static WDML_XACT * WDML_ServerQueueTerminate(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:934
static WDML_XACT * WDML_ServerQueuePoke(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:853
static WDML_XACT * WDML_ServerQueueUnadvise(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:677
static WDML_QUEUE_STATE WDML_ServerHandleTerminate(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:947
static WDML_XACT * WDML_ServerQueueRequest(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:516
static WDML_XACT * WDML_ServerQueueExecute(WDML_CONV *pConv, LPARAM lParam)
Definition: ddeserver.c:737
LPARAM lParam
Definition: dde_private.h:121
#define WIN_GetFullHandle(h)
Definition: user_x.h:108
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LRESULT WINAPI DefWindowProcA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI IsWindowUnicode(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1608

Referenced by WDML_CreateServerConv().

◆ WDML_ServerHandle()

WDML_QUEUE_STATE WDML_ServerHandle ( WDML_CONV pConv,
WDML_XACT pXAct 
)

Definition at line 968 of file ddeserver.c.

969{
971
972 switch (pXAct->ddeMsg)
973 {
974 case WM_DDE_INITIATE:
975 FIXME("WM_DDE_INITIATE shouldn't be there!\n");
976 break;
977 case WM_DDE_REQUEST:
978 qs = WDML_ServerHandleRequest(pConv, pXAct);
979 break;
980
981 case WM_DDE_ADVISE:
982 qs = WDML_ServerHandleAdvise(pConv, pXAct);
983 break;
984
985 case WM_DDE_UNADVISE:
986 qs = WDML_ServerHandleUnadvise(pConv, pXAct);
987 break;
988
989 case WM_DDE_EXECUTE:
990 qs = WDML_ServerHandleExecute(pConv, pXAct);
991 break;
992
993 case WM_DDE_POKE:
994 qs = WDML_ServerHandlePoke(pConv, pXAct);
995 break;
996
997 case WM_DDE_TERMINATE:
998 qs = WDML_ServerHandleTerminate(pConv, pXAct);
999 break;
1000
1001 case WM_DDE_ACK:
1002 WARN("Shouldn't receive a ACK message (never requests them). Ignoring it\n");
1003 break;
1004
1005 default:
1006 FIXME("Unsupported message %d\n", pXAct->ddeMsg);
1007 }
1008 return qs;
1009}
WDML_QUEUE_STATE
Definition: dde_private.h:184
@ WDML_QS_ERROR
Definition: dde_private.h:185
static WDML_QUEUE_STATE WDML_ServerHandlePoke(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:875
static WDML_QUEUE_STATE WDML_ServerHandleUnadvise(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:695
static WDML_QUEUE_STATE WDML_ServerHandleRequest(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:534
static WDML_QUEUE_STATE WDML_ServerHandleExecute(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:802
static WDML_QUEUE_STATE WDML_ServerHandleAdvise(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddeserver.c:610

Referenced by WDML_EnableCallback(), and WDML_ServerConvProc().

◆ WDML_ServerHandleAdvise()

static WDML_QUEUE_STATE WDML_ServerHandleAdvise ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 610 of file ddeserver.c.

611{
612 UINT uType;
613 WDML_LINK* pLink;
614 DDEADVISE* pDdeAdvise;
615 HDDEDATA hDdeData = 0;
616 BOOL fAck = TRUE;
617
618 pDdeAdvise = GlobalLock(pXAct->hMem);
619 uType = XTYP_ADVSTART |
620 (pDdeAdvise->fDeferUpd ? XTYPF_NODATA : 0) |
621 (pDdeAdvise->fAckReq ? XTYPF_ACKREQ : 0);
622
623 if (!(pConv->instance->CBFflags & CBF_FAIL_ADVISES))
624 {
625 hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_ADVSTART, pDdeAdvise->cfFormat,
626 (HCONV)pConv, pConv->hszTopic, pXAct->hszItem, 0, 0, 0);
627 }
628
629 switch ((ULONG_PTR)hDdeData)
630 {
631 case 0:
632 TRACE("No data returned from the Callback\n");
633 fAck = FALSE;
634 break;
635
636 case (ULONG_PTR)CBR_BLOCK:
637 return WDML_QS_BLOCK;
638
639 default:
640 /* billx: first to see if the link is already created. */
641 pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
642 pXAct->hszItem, TRUE, pDdeAdvise->cfFormat);
643
644 if (pLink != NULL)
645 {
646 /* we found a link, and only need to modify it in case it changes */
647 pLink->transactionType = uType;
648 }
649 else
650 {
651 TRACE("Adding Link with hConv %p\n", pConv);
652 WDML_AddLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
653 uType, pXAct->hszItem, pDdeAdvise->cfFormat);
654 }
655 break;
656 }
657
658 GlobalUnlock(pXAct->hMem);
659 if (fAck)
660 {
661 GlobalFree(pXAct->hMem);
662 }
663 pXAct->hMem = 0;
664
665 WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, fAck, pXAct->atom, pXAct->lParam, WM_DDE_ADVISE);
666
667 WDML_DecHSZ(pConv->instance, pXAct->hszItem);
668
669 return WDML_QS_HANDLED;
670}
WDML_LINK * WDML_FindLink(WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, HSZ hszItem, BOOL use_fmt, UINT uFmt) DECLSPEC_HIDDEN
Definition: ddemisc.c:1868
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz) DECLSPEC_HIDDEN
Definition: ddemisc.c:380
void WDML_AddLink(WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, UINT wType, HSZ hszItem, UINT wFmt) DECLSPEC_HIDDEN
Definition: ddemisc.c:1755
BOOL WDML_PostAck(WDML_CONV *pConv, WDML_SIDE side, WORD appRetCode, BOOL fBusy, BOOL fAck, UINT_PTR pmt, LPARAM lParam, UINT oldMsg) DECLSPEC_HIDDEN
Definition: ddemisc.c:2275
@ WDML_QS_HANDLED
Definition: dde_private.h:185
#define XTYP_ADVSTART
Definition: ddeml.h:183
#define XTYPF_ACKREQ
Definition: ddeml.h:172
#define CBF_FAIL_ADVISES
Definition: ddeml.h:105
unsigned int BOOL
Definition: ntddk_ex.h:94
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
Definition: dde.h:65
short cfFormat
Definition: dde.h:67
unsigned short fAckReq
Definition: dde.h:66
unsigned short fDeferUpd
Definition: dde.h:66
HGLOBAL hMem
Definition: dde_private.h:120

Referenced by WDML_ServerHandle().

◆ WDML_ServerHandleExecute()

static WDML_QUEUE_STATE WDML_ServerHandleExecute ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 802 of file ddeserver.c.

803{
804 HDDEDATA hDdeData = DDE_FNOTPROCESSED;
805 BOOL fAck = FALSE, fBusy = FALSE;
806
807 if (!(pConv->instance->CBFflags & CBF_FAIL_EXECUTES))
808 {
809 LPVOID ptr = GlobalLock(pXAct->hMem);
810 DWORD size = GlobalSize(pXAct->hMem);
811
812 if (ptr)
813 {
814 if (pConv->instance->unicode) /* Unicode server, try to map A->W */
815 hDdeData = map_A_to_W( pConv->instance->instanceID, ptr, size );
816 else if (!IsWindowUnicode( pConv->hwndClient )) /* ASCII server and client, try to map W->A */
817 hDdeData = map_W_to_A( pConv->instance->instanceID, ptr, size );
818 else
819 hDdeData = DdeCreateDataHandle(pConv->instance->instanceID, ptr, size, 0, 0, CF_TEXT, 0);
820 GlobalUnlock(pXAct->hMem);
821 }
822 hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_EXECUTE, 0, (HCONV)pConv,
823 pConv->hszTopic, 0, hDdeData, 0L, 0L);
824 }
825
826 switch ((ULONG_PTR)hDdeData)
827 {
828 case (ULONG_PTR)CBR_BLOCK:
829 return WDML_QS_BLOCK;
830
831 case DDE_FACK:
832 fAck = TRUE;
833 break;
834 case DDE_FBUSY:
835 fBusy = TRUE;
836 break;
837 default:
838 FIXME("Unsupported returned value %p\n", hDdeData);
839 /* fall through */
841 break;
842 }
843 WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, fBusy, fAck, (UINT_PTR)pXAct->hMem, 0, 0);
844
845 return WDML_QS_HANDLED;
846}
#define CBF_FAIL_EXECUTES
Definition: ddeml.h:106
#define DDE_FACK
Definition: ddeml.h:216
#define DDE_FNOTPROCESSED
Definition: ddeml.h:223
#define XTYP_EXECUTE
Definition: ddeml.h:185
#define DDE_FBUSY
Definition: ddeml.h:217
static HDDEDATA map_W_to_A(DWORD instance, void *ptr, DWORD size)
Definition: ddeserver.c:778
static HDDEDATA map_A_to_W(DWORD instance, void *ptr, DWORD size)
Definition: ddeserver.c:759
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090

Referenced by WDML_ServerHandle().

◆ WDML_ServerHandlePoke()

static WDML_QUEUE_STATE WDML_ServerHandlePoke ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 875 of file ddeserver.c.

876{
877 DDEPOKE* pDdePoke;
878 HDDEDATA hDdeData;
879 BOOL fBusy = FALSE, fAck = FALSE;
880
881 pDdePoke = GlobalLock(pXAct->hMem);
882 if (!pDdePoke)
883 {
884 return WDML_QS_ERROR;
885 }
886
887 if (!(pConv->instance->CBFflags & CBF_FAIL_POKES))
888 {
889 hDdeData = DdeCreateDataHandle(pConv->instance->instanceID, pDdePoke->Value,
891 0, 0, pDdePoke->cfFormat, 0);
892 if (hDdeData)
893 {
894 HDDEDATA hDdeDataOut;
895
896 hDdeDataOut = WDML_InvokeCallback(pConv->instance, XTYP_POKE, pDdePoke->cfFormat,
897 (HCONV)pConv, pConv->hszTopic, pXAct->hszItem,
898 hDdeData, 0, 0);
899 switch ((ULONG_PTR)hDdeDataOut)
900 {
901 case DDE_FACK:
902 fAck = TRUE;
903 break;
904 case DDE_FBUSY:
905 fBusy = TRUE;
906 break;
907 default:
908 FIXME("Unsupported returned value %p\n", hDdeDataOut);
909 /* fal through */
911 break;
912 }
913 DdeFreeDataHandle(hDdeData);
914 }
915 }
916 GlobalUnlock(pXAct->hMem);
917
918 if (!fAck)
919 {
920 GlobalFree(pXAct->hMem);
921 }
922 WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, fBusy, fAck, pXAct->atom, pXAct->lParam, WM_DDE_POKE);
923
924 WDML_DecHSZ(pConv->instance, pXAct->hszItem);
925
926 return WDML_QS_HANDLED;
927}
#define CBF_FAIL_POKES
Definition: ddeml.h:107
#define XTYP_POKE
Definition: ddeml.h:189
Definition: dde.h:72
short cfFormat
Definition: dde.h:74
BYTE Value[1]
Definition: dde.h:75
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413

Referenced by WDML_ServerHandle().

◆ WDML_ServerHandleRequest()

static WDML_QUEUE_STATE WDML_ServerHandleRequest ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 534 of file ddeserver.c.

535{
536 HDDEDATA hDdeData = 0;
537 BOOL fAck = TRUE;
538
539 if (!(pConv->instance->CBFflags & CBF_FAIL_REQUESTS))
540 {
541
542 hDdeData = WDML_InvokeCallback(pConv->instance, XTYP_REQUEST, pXAct->wFmt, (HCONV)pConv,
543 pConv->hszTopic, pXAct->hszItem, 0, 0, 0);
544 }
545
546 switch ((ULONG_PTR)hDdeData)
547 {
548 case 0:
549 TRACE("No data returned from the Callback\n");
550 fAck = FALSE;
551 break;
552
553 case (ULONG_PTR)CBR_BLOCK:
554 return WDML_QS_BLOCK;
555
556 default:
557 {
558 HGLOBAL hMem = WDML_DataHandle2Global(hDdeData, TRUE, FALSE, FALSE, FALSE);
561 (UINT_PTR)hMem, (UINT_PTR)pXAct->atom)))
562 {
563 pConv->instance->lastError = DMLERR_POSTMSG_FAILED;
564 DdeFreeDataHandle(hDdeData);
565 GlobalFree(hMem);
566 fAck = FALSE;
567 }
568 }
569 break;
570 }
571
572 WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, fAck, pXAct->atom, pXAct->lParam, WM_DDE_REQUEST);
573
574 WDML_DecHSZ(pConv->instance, pXAct->hszItem);
575
576 return WDML_QS_HANDLED;
577}
LPARAM WINAPI ReuseDDElParam(LPARAM, UINT, UINT, UINT_PTR, UINT_PTR)
Definition: ddemisc.c:171
#define CBF_FAIL_REQUESTS
Definition: ddeml.h:108
#define XTYP_REQUEST
Definition: ddeml.h:191

Referenced by WDML_ServerHandle().

◆ WDML_ServerHandleTerminate()

static WDML_QUEUE_STATE WDML_ServerHandleTerminate ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 947 of file ddeserver.c.

948{
949 /* billx: two things to remove: the conv, and associated links.
950 * Respond with another WM_DDE_TERMINATE iMsg.
951 */
952 if (!(pConv->instance->CBFflags & CBF_SKIP_DISCONNECTS))
953 {
954 WDML_InvokeCallback(pConv->instance, XTYP_DISCONNECT, 0, (HCONV)pConv, 0, 0,
955 0, 0, (pConv->wStatus & ST_ISSELF) ? 1 : 0);
956 }
959
960 return WDML_QS_HANDLED;
961}
void WDML_RemoveConv(WDML_CONV *pConv, WDML_SIDE side) DECLSPEC_HIDDEN
Definition: ddemisc.c:2070
#define CBF_SKIP_DISCONNECTS
Definition: ddeml.h:114
#define XTYP_DISCONNECT
Definition: ddeml.h:192
#define ST_ISSELF
Definition: ddeml.h:88

Referenced by WDML_ServerConvProc(), and WDML_ServerHandle().

◆ WDML_ServerHandleUnadvise()

static WDML_QUEUE_STATE WDML_ServerHandleUnadvise ( WDML_CONV pConv,
WDML_XACT pXAct 
)
static

Definition at line 695 of file ddeserver.c.

696{
697 WDML_LINK* pLink;
698
699 if (pXAct->hszItem == NULL || pXAct->wFmt == 0)
700 {
701 ERR("Unsupported yet options (null item or clipboard format)\n");
702 return WDML_QS_ERROR;
703 }
704
705 pLink = WDML_FindLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
706 pXAct->hszItem, TRUE, pXAct->wFmt);
707 if (pLink == NULL)
708 {
709 ERR("Couldn't find link for %p, dropping request\n", pXAct->hszItem);
711 return WDML_QS_ERROR;
712 }
713
714 if (!(pConv->instance->CBFflags & CBF_FAIL_ADVISES))
715 {
716 WDML_InvokeCallback(pConv->instance, XTYP_ADVSTOP, pXAct->wFmt, (HCONV)pConv,
717 pConv->hszTopic, pXAct->hszItem, 0, 0, 0);
718 }
719
720 WDML_RemoveLink(pConv->instance, (HCONV)pConv, WDML_SERVER_SIDE,
721 pXAct->hszItem, pXAct->wFmt);
722
723 /* send back ack */
724 WDML_PostAck(pConv, WDML_SERVER_SIDE, 0, FALSE, TRUE, pXAct->atom,
725 pXAct->lParam, WM_DDE_UNADVISE);
726
727 WDML_DecHSZ(pConv->instance, pXAct->hszItem);
728
729 return WDML_QS_HANDLED;
730}
BOOL WINAPI FreeDDElParam(UINT, LPARAM)
Definition: ddemisc.c:147
void WDML_RemoveLink(WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, HSZ hszItem, UINT wFmt) DECLSPEC_HIDDEN
Definition: ddemisc.c:1780
#define XTYP_ADVSTOP
Definition: ddeml.h:184

Referenced by WDML_ServerHandle().

◆ WDML_ServerNameProc()

static LRESULT CALLBACK WDML_ServerNameProc ( HWND  hwndServer,
UINT  iMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 365 of file ddeserver.c.

366{
367 HWND hwndClient;
368 HSZ hszApp, hszTop;
369 HDDEDATA hDdeData;
371 UINT_PTR uiLo, uiHi;
372
373 switch (iMsg)
374 {
375 case WM_DDE_INITIATE:
376
377 /* wParam -- sending window handle
378 LOWORD(lParam) -- application atom
379 HIWORD(lParam) -- topic atom */
380
381 TRACE("WM_DDE_INITIATE message received!\n");
382 hwndClient = (HWND)wParam;
383
385 if (!pInstance) return 0;
386 TRACE("idInst=%d, threadID=0x%x\n", pInstance->instanceID, GetCurrentThreadId());
387
388 /* don't free DDEParams, since this is a broadcast */
389 UnpackDDElParam(WM_DDE_INITIATE, lParam, &uiLo, &uiHi);
390
391 hszApp = WDML_MakeHszFromAtom(pInstance, uiLo);
392 hszTop = WDML_MakeHszFromAtom(pInstance, uiHi);
393
394 if (!(pInstance->CBFflags & CBF_FAIL_CONNECTIONS))
395 {
396 BOOL self = FALSE;
398 CONVCONTEXT* pcc = NULL;
399 WDML_CONV* pConv;
400 char buf[256];
401
402 if (GetWindowThreadProcessId(hwndClient, NULL) == GetWindowThreadProcessId(hwndServer, NULL) &&
403 WDML_GetInstanceFromWnd(hwndClient) == WDML_GetInstanceFromWnd(hwndServer))
404 {
405 self = TRUE;
406 }
407 /* FIXME: so far, we don't grab distant convcontext, so only check if remote is
408 * handled under DDEML, and if so build a default context
409 */
410 if ((GetClassNameA(hwndClient, buf, sizeof(buf)) &&
412 (GetClassNameW(hwndClient, (LPWSTR)buf, sizeof(buf)/sizeof(WCHAR)) &&
414 {
415 pcc = &cc;
416 memset(pcc, 0, sizeof(*pcc));
417 pcc->cb = sizeof(*pcc);
418 pcc->iCodePage = IsWindowUnicode(hwndClient) ? CP_WINUNICODE : CP_WINANSI;
419 }
420 if ((pInstance->CBFflags & CBF_FAIL_SELFCONNECTIONS) && self)
421 {
422 TRACE("Don't do self connection as requested\n");
423 }
424 else if (hszApp && hszTop)
425 {
427
428 /* check filters for name service */
429 if (!pServer->filterOn || DdeCmpStringHandles(pServer->hszService, hszApp) == 0)
430 {
431 /* pass on to the callback */
433 0, 0, hszTop, hszApp, 0, (ULONG_PTR)pcc, self);
434 if ((ULONG_PTR)hDdeData)
435 {
436 pConv = WDML_CreateServerConv(pInstance, hwndClient, hwndServer,
437 hszApp, hszTop);
438 if (pConv)
439 {
440 if (pcc) pConv->wStatus |= ST_ISLOCAL;
442 hszTop, hszApp, 0, (ULONG_PTR)pcc, self);
443 }
444 }
445 }
446 }
447 else if (pInstance->servers)
448 {
449 /* pass on to the callback */
451 0, 0, hszTop, hszApp, 0, (ULONG_PTR)pcc, self);
452
453 if (hDdeData == CBR_BLOCK)
454 {
455 /* MS doc is not consistent here */
456 FIXME("CBR_BLOCK returned for WILDCONNECT\n");
457 }
458 else if ((ULONG_PTR)hDdeData != 0)
459 {
460 HSZPAIR* hszp;
461
462 hszp = (HSZPAIR*)DdeAccessData(hDdeData, NULL);
463 if (hszp)
464 {
465 int i;
466 for (i = 0; hszp[i].hszSvc && hszp[i].hszTopic; i++)
467 {
468 pConv = WDML_CreateServerConv(pInstance, hwndClient, hwndServer,
469 hszp[i].hszSvc, hszp[i].hszTopic);
470 if (pConv)
471 {
472 if (pcc) pConv->wStatus |= ST_ISLOCAL;
474 hszp[i].hszTopic, hszp[i].hszSvc, 0, (ULONG_PTR)pcc, self);
475 }
476 }
477 DdeUnaccessData(hDdeData);
478 }
479 if (!WDML_IsAppOwned(hDdeData)) DdeFreeDataHandle(hDdeData);
480 }
481 }
482 }
483
484 return 0;
485
486 case WM_DDE_REQUEST:
487 FIXME("WM_DDE_REQUEST message received!\n");
488 return 0;
489 case WM_DDE_ADVISE:
490 FIXME("WM_DDE_ADVISE message received!\n");
491 return 0;
492 case WM_DDE_UNADVISE:
493 FIXME("WM_DDE_UNADVISE message received!\n");
494 return 0;
495 case WM_DDE_EXECUTE:
496 FIXME("WM_DDE_EXECUTE message received!\n");
497 return 0;
498 case WM_DDE_POKE:
499 FIXME("WM_DDE_POKE message received!\n");
500 return 0;
501 case WM_DDE_TERMINATE:
502 FIXME("WM_DDE_TERMINATE message received!\n");
503 return 0;
504 default:
505 break;
506 }
507
508 return DefWindowProcW(hwndServer, iMsg, wParam, lParam);
509}
BOOL WINAPI UnpackDDElParam(UINT, LPARAM, PUINT_PTR, PUINT_PTR)
Definition: ddemisc.c:105
HSZ WDML_MakeHszFromAtom(const WDML_INSTANCE *pInstance, ATOM atom) DECLSPEC_HIDDEN
Definition: ddemisc.c:342
const char WDML_szClientConvClassA[]
Definition: ddeclient.c:31
const WCHAR WDML_szClientConvClassW[]
Definition: ddeclient.c:32
#define XTYP_CONNECT
Definition: ddeml.h:186
#define XTYP_CONNECT_CONFIRM
Definition: ddeml.h:187
#define ST_ISLOCAL
Definition: ddeml.h:82
#define CBF_FAIL_SELFCONNECTIONS
Definition: ddeml.h:103
#define CBF_FAIL_CONNECTIONS
Definition: ddeml.h:104
#define CP_WINANSI
Definition: ddeml.h:32
#define CP_WINUNICODE
Definition: ddeml.h:33
BOOL WINAPI DdeUnaccessData(HDDEDATA)
Definition: ddemisc.c:1447
#define XTYP_WILDCONNECT
Definition: ddeml.h:194
static WDML_CONV * WDML_CreateServerConv(WDML_INSTANCE *pInstance, HWND hwndClient, HWND hwndServerName, HSZ hszApp, HSZ hszTopic)
Definition: ddeserver.c:280
HANDLE HWND
Definition: compat.h:19
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
uint32_t cc
Definition: isohybrid.c:75
int WINAPI lstrcmpiA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:42
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define memset(x, y, z)
Definition: compat.h:39
INT iCodePage
Definition: ddeml.h:310
HSZ hszSvc
Definition: ddeml.h:301
HSZ hszTopic
Definition: ddeml.h:302
DWORD WINAPI GetCurrentThreadId(void)
Definition: thread.c:459
DWORD WINAPI GetWindowThreadProcessId(HWND hWnd, PDWORD lpdwProcessId)
#define GetWindowLongPtrW
Definition: winuser.h:4828
int WINAPI GetClassNameA(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPSTR lpClassName, _In_ int nMaxCount)
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DdeNameService().

◆ WDML_ServerQueueAdvise()

static WDML_XACT * WDML_ServerQueueAdvise ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 584 of file ddeserver.c.

585{
586 UINT_PTR uiLo, uiHi;
587 WDML_XACT* pXAct;
588
589 /* XTYP_ADVSTART transaction:
590 establish link and save link info to InstanceInfoTable */
591
592 if (!UnpackDDElParam(WM_DDE_ADVISE, lParam, &uiLo, &uiHi))
593 return NULL;
594
596 0, WDML_MakeHszFromAtom(pConv->instance, uiHi));
597 if (pXAct)
598 {
599 pXAct->hMem = (HGLOBAL)uiLo;
600 pXAct->atom = uiHi;
601 }
602 return pXAct;
603}
WDML_XACT * WDML_AllocTransaction(WDML_INSTANCE *pInstance, UINT ddeMsg, UINT wFmt, HSZ hszItem) DECLSPEC_HIDDEN
Definition: ddemisc.c:1900
#define HGLOBAL
Definition: ole.h:15

Referenced by WDML_ServerConvProc().

◆ WDML_ServerQueueExecute()

static WDML_XACT * WDML_ServerQueueExecute ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 737 of file ddeserver.c.

738{
739 WDML_XACT* pXAct;
740
741 pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_EXECUTE, 0, 0);
742 if (pXAct)
743 {
744 pXAct->hMem = (HGLOBAL)lParam;
745 }
746 return pXAct;
747}

Referenced by WDML_ServerConvProc().

◆ WDML_ServerQueuePoke()

static WDML_XACT * WDML_ServerQueuePoke ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 853 of file ddeserver.c.

854{
855 UINT_PTR uiLo, uiHi;
856 WDML_XACT* pXAct;
857
858 UnpackDDElParam(WM_DDE_POKE, lParam, &uiLo, &uiHi);
859
861 0, WDML_MakeHszFromAtom(pConv->instance, uiHi));
862 if (pXAct)
863 {
864 pXAct->atom = uiHi;
865 pXAct->hMem = (HGLOBAL)uiLo;
866 }
867 return pXAct;
868}

Referenced by WDML_ServerConvProc().

◆ WDML_ServerQueueRequest()

static WDML_XACT * WDML_ServerQueueRequest ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 516 of file ddeserver.c.

517{
518 UINT_PTR uiLo, uiHi;
519 WDML_XACT* pXAct;
520
521 UnpackDDElParam(WM_DDE_REQUEST, lParam, &uiLo, &uiHi);
522
524 uiLo, WDML_MakeHszFromAtom(pConv->instance, uiHi));
525 if (pXAct) pXAct->atom = uiHi;
526 return pXAct;
527}

Referenced by WDML_ServerConvProc().

◆ WDML_ServerQueueTerminate()

static WDML_XACT * WDML_ServerQueueTerminate ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 934 of file ddeserver.c.

935{
936 WDML_XACT* pXAct;
937
938 pXAct = WDML_AllocTransaction(pConv->instance, WM_DDE_TERMINATE, 0, 0);
939 return pXAct;
940}

Referenced by WDML_ServerConvProc().

◆ WDML_ServerQueueUnadvise()

static WDML_XACT * WDML_ServerQueueUnadvise ( WDML_CONV pConv,
LPARAM  lParam 
)
static

Definition at line 677 of file ddeserver.c.

678{
679 UINT_PTR uiLo, uiHi;
680 WDML_XACT* pXAct;
681
682 UnpackDDElParam(WM_DDE_UNADVISE, lParam, &uiLo, &uiHi);
683
685 uiLo, WDML_MakeHszFromAtom(pConv->instance, uiHi));
686 if (pXAct) pXAct->atom = uiHi;
687 return pXAct;
688}

Referenced by WDML_ServerConvProc().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddeml  )

Variable Documentation

◆ szServerNameClass

const WCHAR szServerNameClass[] = L"DDEMLMom"
static

Definition at line 30 of file ddeserver.c.

Referenced by DdeNameService().

◆ WDML_szServerConvClassA

const char WDML_szServerConvClassA = "DDEMLAnsiServer"

Definition at line 31 of file ddeserver.c.

Referenced by WDML_ClientProc(), and WDML_CreateServerConv().

◆ WDML_szServerConvClassW

const WCHAR WDML_szServerConvClassW = L"DDEMLUnicodeServer"

Definition at line 32 of file ddeserver.c.

Referenced by WDML_ClientProc(), and WDML_CreateServerConv().