ReactOS  0.4.13-dev-443-g10f00f8
ddemisc.c File Reference
#include <user32.h>
#include "dde_private.h"
Include dependency graph for ddemisc.c:

Go to the source code of this file.

Classes

struct  tagWDML_BroadcastPmt
 

Macros

#define ATOM2HSZ(atom)   ((HSZ) (ULONG_PTR)(atom))
 
#define HSZ2ATOM(hsz)   ((ATOM) (ULONG_PTR)(hsz))
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (ddeml)
 
LPARAM WINAPI PackDDElParam (UINT msg, UINT_PTR uiLo, UINT_PTR uiHi)
 
BOOL WINAPI UnpackDDElParam (UINT msg, LPARAM lParam, PUINT_PTR uiLo, PUINT_PTR uiHi)
 
BOOL WINAPI FreeDDElParam (UINT msg, LPARAM lParam)
 
LPARAM WINAPI ReuseDDElParam (LPARAM lParam, UINT msgIn, UINT msgOut, UINT_PTR uiLo, UINT_PTR uiHi)
 
BOOL WINAPI ImpersonateDdeClientWindow (HWND hWndClient, HWND hWndServer)
 
BOOL WINAPI DdeSetQualityOfService (HWND hwndClient, const SECURITY_QUALITY_OF_SERVICE *pqosNew, PSECURITY_QUALITY_OF_SERVICE pqosPrev)
 
UINT WINAPI DdeGetLastError (DWORD idInst)
 
static void WDML_SetAllLastError (DWORD lastError)
 
static HSZNodeWDML_FindNode (WDML_INSTANCE *pInstance, HSZ hsz)
 
ATOM WDML_MakeAtomFromHsz (HSZ hsz)
 
HSZ WDML_MakeHszFromAtom (const WDML_INSTANCE *pInstance, ATOM atom)
 
BOOL WDML_IncHSZ (WDML_INSTANCE *pInstance, HSZ hsz)
 
BOOL WDML_DecHSZ (WDML_INSTANCE *pInstance, HSZ hsz)
 
static void WDML_FreeAllHSZ (WDML_INSTANCE *pInstance)
 
static void WDML_InsertHSZNode (WDML_INSTANCE *pInstance, HSZ hsz)
 
static int WDML_QueryString (WDML_INSTANCE *pInstance, HSZ hsz, LPVOID ptr, DWORD cchMax, int codepage)
 
DWORD WINAPI DdeQueryStringA (DWORD idInst, HSZ hsz, LPSTR psz, DWORD cchMax, INT iCodePage)
 
DWORD WINAPI DdeQueryStringW (DWORD idInst, HSZ hsz, LPWSTR psz, DWORD cchMax, INT iCodePage)
 
static HSZ WDML_CreateString (WDML_INSTANCE *pInstance, LPCVOID ptr, int codepage)
 
HSZ WINAPI DdeCreateStringHandleA (DWORD idInst, LPCSTR psz, INT codepage)
 
HSZ WINAPI DdeCreateStringHandleW (DWORD idInst, LPCWSTR psz, INT codepage)
 
BOOL WINAPI DdeFreeStringHandle (DWORD idInst, HSZ hsz)
 
BOOL WINAPI DdeKeepStringHandle (DWORD idInst, HSZ hsz)
 
INT WINAPI DdeCmpStringHandles (HSZ hsz1, HSZ hsz2)
 
static void WDML_IncrementInstanceId (WDML_INSTANCE *pInstance)
 
static LRESULT CALLBACK WDML_EventProc (HWND hwndEvent, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static UINT WDML_Initialize (LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes, BOOL bUnicode)
 
UINT WINAPI DdeInitializeA (LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes)
 
UINT WINAPI DdeInitializeW (LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes)
 
BOOL WINAPI DdeUninitialize (DWORD idInst)
 
void WDML_NotifyThreadDetach (void)
 
HDDEDATA WDML_InvokeCallback (WDML_INSTANCE *pInstance, UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG_PTR dwData1, ULONG_PTR dwData2)
 
WDML_INSTANCEWDML_GetInstance (DWORD instId)
 
WDML_INSTANCEWDML_GetInstanceFromWnd (HWND hWnd)
 
HDDEDATA WINAPI DdeCreateDataHandle (DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff, HSZ hszItem, UINT wFmt, UINT afCmd)
 
HDDEDATA WINAPI DdeAddData (HDDEDATA hData, LPBYTE pSrc, DWORD cb, DWORD cbOff)
 
DWORD WINAPI DdeGetData (HDDEDATA hData, LPBYTE pDst, DWORD cbMax, DWORD cbOff)
 
LPBYTE WINAPI DdeAccessData (HDDEDATA hData, LPDWORD pcbDataSize)
 
BOOL WINAPI DdeUnaccessData (HDDEDATA hData)
 
BOOL WINAPI DdeFreeDataHandle (HDDEDATA hData)
 
BOOL WDML_IsAppOwned (HDDEDATA hData)
 
HDDEDATA WDML_Global2DataHandle (WDML_CONV *pConv, HGLOBAL hMem, WINE_DDEHEAD *p)
 
HGLOBAL WDML_DataHandle2Global (HDDEDATA hDdeData, BOOL fResponse, BOOL fRelease, BOOL fDeferUpd, BOOL fAckReq)
 
WDML_SERVERWDML_AddServer (WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic)
 
void WDML_RemoveServer (WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic)
 
WDML_SERVERWDML_FindServer (WDML_INSTANCE *pInstance, HSZ hszService, HSZ hszTopic)
 
void WDML_AddLink (WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, UINT wType, HSZ hszItem, UINT wFmt)
 
void WDML_RemoveLink (WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, HSZ hszItem, UINT uFmt)
 
static void WDML_RemoveAllLinks (WDML_INSTANCE *pInstance, WDML_CONV *pConv, WDML_SIDE side)
 
WDML_LINKWDML_FindLink (WDML_INSTANCE *pInstance, HCONV hConv, WDML_SIDE side, HSZ hszItem, BOOL use_fmt, UINT uFmt)
 
WDML_XACTWDML_AllocTransaction (WDML_INSTANCE *pInstance, UINT ddeMsg, UINT wFmt, HSZ hszItem)
 
void WDML_QueueTransaction (WDML_CONV *pConv, WDML_XACT *pXAct)
 
BOOL WDML_UnQueueTransaction (WDML_CONV *pConv, WDML_XACT *pXAct)
 
void WDML_FreeTransaction (WDML_INSTANCE *pInstance, WDML_XACT *pXAct, BOOL doFreePmt)
 
static WDML_XACTWDML_FindTransaction (WDML_CONV *pConv, DWORD tid)
 
WDML_CONVWDML_AddConv (WDML_INSTANCE *pInstance, WDML_SIDE side, HSZ hszService, HSZ hszTopic, HWND hwndClient, HWND hwndServer)
 
WDML_CONVWDML_FindConv (WDML_INSTANCE *pInstance, WDML_SIDE side, HSZ hszService, HSZ hszTopic)
 
void WDML_RemoveConv (WDML_CONV *pRef, WDML_SIDE side)
 
static BOOL WDML_EnableCallback (WDML_CONV *pConv, UINT wCmd)
 
BOOL WINAPI DdeEnableCallback (DWORD idInst, HCONV hConv, UINT wCmd)
 
WDML_CONVWDML_GetConv (HCONV hConv, BOOL checkConnected)
 
WDML_CONVWDML_GetConvFromWnd (HWND hWnd)
 
BOOL WDML_PostAck (WDML_CONV *pConv, WDML_SIDE side, WORD appRetCode, BOOL fBusy, BOOL fAck, UINT_PTR pmt, LPARAM lParam, UINT oldMsg)
 
BOOL WINAPI DdeSetUserHandle (HCONV hConv, DWORD id, DWORD hUser)
 
static BOOL WDML_GetLocalConvInfo (WDML_CONV *pConv, CONVINFO *ci, DWORD id)
 
UINT WINAPI DdeQueryConvInfo (HCONV hConv, DWORD id, PCONVINFO lpConvInfo)
 
static BOOL CALLBACK WDML_BroadcastEnumProc (HWND hWnd, LPARAM lParam)
 
void WDML_BroadcastDDEWindows (LPCWSTR clsName, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static WDML_INSTANCEWDML_InstanceList = NULL
 
static LONG WDML_MaxInstanceID = 0
 
const WCHAR WDML_szEventClass [] = L"DDEMLEvent"
 
static CRITICAL_SECTION WDML_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG critsect_debug
 

Macro Definition Documentation

◆ ATOM2HSZ

#define ATOM2HSZ (   atom)    ((HSZ) (ULONG_PTR)(atom))

Definition at line 33 of file ddemisc.c.

◆ HSZ2ATOM

#define HSZ2ATOM (   hsz)    ((ATOM) (ULONG_PTR)(hsz))

Definition at line 34 of file ddemisc.c.

Function Documentation

◆ DdeAccessData()

LPBYTE WINAPI DdeAccessData ( HDDEDATA  hData,
LPDWORD  pcbDataSize 
)

Definition at line 1422 of file ddemisc.c.

1423 {
1424  HGLOBAL hMem = hData;
1425  DDE_DATAHANDLE_HEAD* pDdh;
1426 
1427  TRACE("(%p,%p)\n", hData, pcbDataSize);
1428 
1429  pDdh = GlobalLock(hMem);
1430  if (pDdh == NULL)
1431  {
1432  ERR("Failed on GlobalLock(%p)\n", hMem);
1433  return 0;
1434  }
1435 
1436  if (pcbDataSize != NULL)
1437  {
1438  *pcbDataSize = GlobalSize(hMem) - sizeof(DDE_DATAHANDLE_HEAD);
1439  }
1440  TRACE("=> %p (%lu) fmt %04x\n", pDdh + 1, GlobalSize(hMem) - sizeof(DDE_DATAHANDLE_HEAD), pDdh->cfFormat);
1441  return (LPBYTE)(pDdh + 1);
1442 }
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
unsigned char * LPBYTE
Definition: typedefs.h:52
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
struct tagDDE_DATAHANDLE_HEAD DDE_DATAHANDLE_HEAD
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by Dde_OnExecute(), DdeAddData(), DdeGetData(), map_A_to_W(), map_W_to_A(), server_ddeml_callback(), test_DdeCreateDataHandle(), test_ddeml_client(), WDML_ClientQueueExecute(), and WDML_ServerNameProc().

◆ DdeAddData()

HDDEDATA WINAPI DdeAddData ( HDDEDATA  hData,
LPBYTE  pSrc,
DWORD  cb,
DWORD  cbOff 
)

Definition at line 1340 of file ddemisc.c.

1341 {
1342  DWORD old_sz, new_sz;
1343  LPBYTE pDst;
1344 
1345  TRACE("(%p,%p,cb %d, cbOff %d)\n", hData, pSrc, cb, cbOff);
1346 
1347  pDst = DdeAccessData(hData, &old_sz);
1348  if (!pDst) return 0;
1349 
1350  new_sz = cb + cbOff;
1351  if (new_sz > old_sz)
1352  {
1353  DdeUnaccessData(hData);
1354  hData = GlobalReAlloc(hData, new_sz + sizeof(DDE_DATAHANDLE_HEAD),
1356  pDst = DdeAccessData(hData, &old_sz);
1357  }
1358 
1359  if (!pDst) return 0;
1360 
1361  memcpy(pDst + cbOff, pSrc, cb);
1362  DdeUnaccessData(hData);
1363  return hData;
1364 }
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
unsigned char * LPBYTE
Definition: typedefs.h:52
LPBYTE WINAPI DdeAccessData(HDDEDATA hData, LPDWORD pcbDataSize)
Definition: ddemisc.c:1422
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD cb
Definition: integrity.c:41
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define GMEM_DDESHARE
Definition: winbase.h:295
BOOL WINAPI DdeUnaccessData(HDDEDATA hData)
Definition: ddemisc.c:1447
#define GMEM_MOVEABLE
Definition: winbase.h:291

◆ DdeCmpStringHandles()

INT WINAPI DdeCmpStringHandles ( HSZ  hsz1,
HSZ  hsz2 
)

Definition at line 685 of file ddemisc.c.

686 {
687  WCHAR psz1[MAX_BUFFER_LEN];
688  WCHAR psz2[MAX_BUFFER_LEN];
689  int ret = 0;
690  int ret1, ret2;
691 
692  ret1 = GetAtomNameW(HSZ2ATOM(hsz1), psz1, MAX_BUFFER_LEN);
693  ret2 = GetAtomNameW(HSZ2ATOM(hsz2), psz2, MAX_BUFFER_LEN);
694 
695  TRACE("(%p<%s> %p<%s>);\n", hsz1, debugstr_w(psz1), hsz2, debugstr_w(psz2));
696 
697  /* Make sure we found both strings. */
698  if (ret1 == 0 && ret2 == 0)
699  {
700  /* If both are not found, return both "zero strings". */
701  ret = 0;
702  }
703  else if (ret1 == 0)
704  {
705  /* If hsz1 is a not found, return hsz1 is "zero string". */
706  ret = -1;
707  }
708  else if (ret2 == 0)
709  {
710  /* If hsz2 is a not found, return hsz2 is "zero string". */
711  ret = 1;
712  }
713  else
714  {
715  /* Compare the two strings we got (case insensitive). */
716  ret = lstrcmpiW(psz1, psz2);
717  /* Since strcmp returns any number smaller than
718  * 0 when the first string is found to be less than
719  * the second one we must make sure we are returning
720  * the proper values.
721  */
722  if (ret < 0)
723  {
724  ret = -1;
725  }
726  else if (ret > 0)
727  {
728  ret = 1;
729  }
730  }
731 
732  return ret;
733 }
#define HSZ2ATOM(hsz)
Definition: ddemisc.c:34
UINT WINAPI GetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:589
#define MAX_BUFFER_LEN
Definition: dde_private.h:34
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
#define debugstr_w
Definition: kernel32.h:32
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
int ret

Referenced by dde_proc(), ddeCb(), DdePostAdvise(), WDML_FindConv(), WDML_FindLink(), WDML_HandleAdviseReply(), WDML_HandlePokeReply(), WDML_HandleRequestReply(), WDML_HandleUnadviseReply(), WDML_RemoveLink(), WDML_RemoveServer(), and WDML_ServerNameProc().

◆ DdeCreateDataHandle()

HDDEDATA WINAPI DdeCreateDataHandle ( DWORD  idInst,
LPBYTE  pSrc,
DWORD  cb,
DWORD  cbOff,
HSZ  hszItem,
UINT  wFmt,
UINT  afCmd 
)

Definition at line 1275 of file ddemisc.c.

1277 {
1278 
1279  /* Other than check for validity we will ignore for now idInst, hszItem.
1280  * The purpose of these arguments still need to be investigated.
1281  */
1282 
1283  WDML_INSTANCE* pInstance;
1284  HGLOBAL hMem;
1285  LPBYTE pByte;
1286  DDE_DATAHANDLE_HEAD* pDdh;
1287  WCHAR psz[MAX_BUFFER_LEN];
1288 
1289  pInstance = WDML_GetInstance(idInst);
1290  if (pInstance == NULL)
1291  {
1293  return NULL;
1294  }
1295 
1296  if (!GetAtomNameW(HSZ2ATOM(hszItem), psz, MAX_BUFFER_LEN))
1297  {
1298  psz[0] = HSZ2ATOM(hszItem);
1299  psz[1] = 0;
1300  }
1301 
1302  TRACE("(%d,%p,cb %d, cbOff %d,%p <%s>,fmt %04x,%x)\n",
1303  idInst, pSrc, cb, cbOff, hszItem, debugstr_w(psz), wFmt, afCmd);
1304 
1305  if (afCmd != 0 && afCmd != HDATA_APPOWNED)
1306  return 0;
1307 
1308  /* we use the first 4 bytes to store the size */
1309  if (!(hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, cb + cbOff + sizeof(DDE_DATAHANDLE_HEAD))))
1310  {
1311  ERR("GlobalAlloc failed\n");
1312  return 0;
1313  }
1314 
1315  pDdh = GlobalLock(hMem);
1316  if (!pDdh)
1317  {
1318  GlobalFree(hMem);
1319  return 0;
1320  }
1321 
1322  pDdh->cfFormat = wFmt;
1323  pDdh->bAppOwned = (afCmd == HDATA_APPOWNED);
1324 
1325  pByte = (LPBYTE)(pDdh + 1);
1326  if (pSrc)
1327  {
1328  memcpy(pByte, pSrc + cbOff, cb);
1329  }
1330  GlobalUnlock(hMem);
1331 
1332  TRACE("=> %p\n", hMem);
1333  return hMem;
1334 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
#define HSZ2ATOM(hsz)
Definition: ddemisc.c:34
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
UINT WINAPI GetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:589
#define MAX_BUFFER_LEN
Definition: dde_private.h:34
unsigned char * LPBYTE
Definition: typedefs.h:52
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
static DWORD cb
Definition: integrity.c:41
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
static void WDML_SetAllLastError(DWORD lastError)
Definition: ddemisc.c:279
#define HDATA_APPOWNED
Definition: ddeml.h:267
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_DDESHARE
Definition: winbase.h:295
#define GMEM_MOVEABLE
Definition: winbase.h:291

Referenced by dde_execute(), map_A_to_W(), map_W_to_A(), server_ddeml_callback(), test_DdeCreateDataHandle(), test_ddeml_client(), WDML_Global2DataHandle(), WDML_ServerHandleExecute(), and WDML_ServerHandlePoke().

◆ DdeCreateStringHandleA()

HSZ WINAPI DdeCreateStringHandleA ( DWORD  idInst,
LPCSTR  psz,
INT  codepage 
)

Definition at line 577 of file ddemisc.c.

578 {
579  HSZ hsz = 0;
580  WDML_INSTANCE* pInstance;
581 
582  TRACE("(%d,%s,%d)\n", idInst, debugstr_a(psz), codepage);
583 
584  pInstance = WDML_GetInstance(idInst);
585  if (pInstance == NULL)
587  else
588  {
589  if (codepage == 0) codepage = CP_WINANSI;
590  hsz = WDML_CreateString(pInstance, psz, codepage);
591  }
592 
593  return hsz;
594 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
static HSZ WDML_CreateString(WDML_INSTANCE *pInstance, LPCVOID ptr, int codepage)
Definition: ddemisc.c:550
int codepage
Definition: win_iconv.c:156
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
static void WDML_SetAllLastError(DWORD lastError)
Definition: ddemisc.c:279
#define CP_WINANSI
Definition: ddeml.h:32

Referenced by dde_request(), doChild(), START_TEST(), test_dde_default_app(), test_DdeCreateDataHandle(), test_ddeml_client(), test_ddeml_server(), test_end_to_end_client(), test_end_to_end_server(), and test_initialisation().

◆ DdeCreateStringHandleW()

HSZ WINAPI DdeCreateStringHandleW ( DWORD  idInst,
LPCWSTR  psz,
INT  codepage 
)

Definition at line 608 of file ddemisc.c.

609 {
610  WDML_INSTANCE* pInstance;
611  HSZ hsz = 0;
612 
613  pInstance = WDML_GetInstance(idInst);
614  if (pInstance == NULL)
616  else
617  {
618  if (codepage == 0) codepage = CP_WINUNICODE;
619  hsz = WDML_CreateString(pInstance, psz, codepage);
620  }
621 
622  return hsz;
623 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
static HSZ WDML_CreateString(WDML_INSTANCE *pInstance, LPCVOID ptr, int codepage)
Definition: ddemisc.c:550
int codepage
Definition: win_iconv.c:156
smooth NULL
Definition: ftsmooth.c:416
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
static void WDML_SetAllLastError(DWORD lastError)
Definition: ddemisc.c:279
#define CP_WINUNICODE
Definition: ddeml.h:33

Referenced by dde_connect(), init_dde(), ShellDDEInit(), test_dde_aw_transaction(), test_DdeCreateDataHandle(), test_DdeCreateStringHandleW(), test_end_to_end_client(), WDML_AddServer(), and WDML_MakeHszFromAtom().

◆ DdeEnableCallback()

BOOL WINAPI DdeEnableCallback ( DWORD  idInst,
HCONV  hConv,
UINT  wCmd 
)

Definition at line 2178 of file ddemisc.c.

2179 {
2180  BOOL ret = FALSE;
2181  WDML_CONV *pConv;
2182 
2183  TRACE("(%d, %p, %04x)\n", idInst, hConv, wCmd);
2184 
2185  if (hConv)
2186  {
2187  pConv = WDML_GetConv(hConv, TRUE);
2188 
2189  if (pConv && pConv->instance->instanceID == idInst)
2190  ret = WDML_EnableCallback(pConv, wCmd);
2191  }
2192  else
2193  {
2194  WDML_INSTANCE *pInstance = WDML_GetInstance(idInst);
2195 
2196  if (!pInstance)
2197  return FALSE;
2198 
2199  TRACE("adding flags %04x to instance %p\n", wCmd, pInstance);
2200  pInstance->wStatus |= wCmd;
2201 
2202  if (wCmd == EC_DISABLE)
2203  {
2204  pInstance->wStatus |= ST_BLOCKED;
2205  TRACE("EC_DISABLE: inst %p status flags %04x\n", pInstance, pInstance->wStatus);
2206  }
2207  else if (wCmd == EC_ENABLEALL)
2208  {
2209  pInstance->wStatus &= ~ST_BLOCKED;
2210  TRACE("EC_ENABLEALL: inst %p status flags %04x\n", pInstance, pInstance->wStatus);
2211  }
2212 
2213  ret = TRUE;
2214 
2215  for (pConv = pInstance->convs[WDML_CLIENT_SIDE]; pConv != NULL; pConv = pConv->next)
2216  {
2217  ret = WDML_EnableCallback(pConv, wCmd);
2218  if (ret && wCmd == EC_QUERYWAITING) break;
2219  }
2220  }
2221 
2222  return ret;
2223 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
static BOOL WDML_EnableCallback(WDML_CONV *pConv, UINT wCmd)
Definition: ddemisc.c:2127
#define TRUE
Definition: types.h:120
struct tagWDML_CONV * next
Definition: dde_private.h:126
#define ST_BLOCKED
Definition: ddeml.h:83
#define EC_QUERYWAITING
Definition: ddeml.h:97
WDML_CONV * convs[2]
Definition: dde_private.h:168
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
WDML_CONV * WDML_GetConv(HCONV hConv, BOOL checkConnected)
Definition: ddemisc.c:2230
int ret
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
#define EC_DISABLE
Definition: ddeml.h:96
#define EC_ENABLEALL
Definition: ddeml.h:94

◆ DdeFreeDataHandle()

BOOL WINAPI DdeFreeDataHandle ( HDDEDATA  hData)

Definition at line 1461 of file ddemisc.c.

1462 {
1463  TRACE("(%p)\n", hData);
1464 
1465  /* 1 is the handle value returned by an asynchronous operation. */
1466  if (hData == (HDDEDATA)1)
1467  return TRUE;
1468 
1469  return GlobalFree(hData) == 0;
1470 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611

Referenced by dde_connect(), ddeCb(), DdePostAdvise(), test_DdeCreateDataHandle(), test_ddeml_client(), WDML_HandleIncomingData(), WDML_ServerHandlePoke(), WDML_ServerHandleRequest(), and WDML_ServerNameProc().

◆ DdeFreeStringHandle()

BOOL WINAPI DdeFreeStringHandle ( DWORD  idInst,
HSZ  hsz 
)

Definition at line 631 of file ddemisc.c.

632 {
633  WDML_INSTANCE* pInstance;
634  BOOL ret = FALSE;
635 
636  TRACE("(%d,%p):\n", idInst, hsz);
637 
638  /* First check instance
639  */
640  pInstance = WDML_GetInstance(idInst);
641  if (pInstance)
642  ret = WDML_DecHSZ(pInstance, hsz);
643 
644  return ret;
645 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int ret

Referenced by doChild(), release_dde(), ShellDDEInit(), START_TEST(), test_dde_aw_transaction(), test_dde_default_app(), test_DdeCreateStringHandleW(), test_ddeml_client(), test_end_to_end_client(), test_initialisation(), and WDML_FreeAllHSZ().

◆ DdeGetData()

DWORD WINAPI DdeGetData ( HDDEDATA  hData,
LPBYTE  pDst,
DWORD  cbMax,
DWORD  cbOff 
)

Definition at line 1379 of file ddemisc.c.

1380 {
1381  DWORD dwSize, dwRet;
1382  LPBYTE pByte;
1383 
1384  TRACE("(%p,%p,%d,%d)\n", hData, pDst, cbMax, cbOff);
1385 
1386  pByte = DdeAccessData(hData, &dwSize);
1387 
1388  if (pByte)
1389  {
1390  if (!pDst)
1391  {
1392  dwRet = dwSize;
1393  }
1394  else if (cbOff + cbMax < dwSize)
1395  {
1396  dwRet = cbMax;
1397  }
1398  else if (cbOff < dwSize)
1399  {
1400  dwRet = dwSize - cbOff;
1401  }
1402  else
1403  {
1404  dwRet = 0;
1405  }
1406  if (pDst && dwRet != 0)
1407  {
1408  memcpy(pDst, pByte + cbOff, dwRet);
1409  }
1410  DdeUnaccessData(hData);
1411  }
1412  else
1413  {
1414  dwRet = 0;
1415  }
1416  return dwRet;
1417 }
unsigned char * LPBYTE
Definition: typedefs.h:52
LPBYTE WINAPI DdeAccessData(HDDEDATA hData, LPDWORD pcbDataSize)
Definition: ddemisc.c:1422
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI DdeUnaccessData(HDDEDATA hData)
Definition: ddemisc.c:1447
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by dde_proc(), dde_request(), ddeCb(), server_ddeml_callback(), and server_end_to_end_callback().

◆ DdeGetLastError()

UINT WINAPI DdeGetLastError ( DWORD  idInst)

Definition at line 253 of file ddemisc.c.

254 {
256  WDML_INSTANCE* pInstance;
257 
258  /* First check instance
259  */
260  pInstance = WDML_GetInstance(idInst);
261  if (pInstance == NULL)
262  {
264  }
265  else
266  {
267  error_code = pInstance->lastError;
268  pInstance->lastError = 0;
269  }
270 
271  return error_code;
272 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
static int error_code[8]
Definition: odbccp32.c:62
smooth NULL
Definition: ftsmooth.c:416
unsigned long DWORD
Definition: ntddk_ex.h:95
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252

Referenced by dde_connect(), dde_execute(), dde_request(), init_dde(), START_TEST(), test_dde_aw_transaction(), test_DdeCreateDataHandle(), test_DdeCreateStringHandle(), test_DdeCreateStringHandleW(), test_ddeml_client(), test_end_to_end_client(), test_initialisation(), and test_request_groups().

◆ DdeInitializeA()

UINT WINAPI DdeInitializeA ( LPDWORD  pidInst,
PFNCALLBACK  pfnCallback,
DWORD  afCmd,
DWORD  ulRes 
)

Definition at line 1075 of file ddemisc.c.

1077 {
1078  return WDML_Initialize(pidInst, pfnCallback, afCmd, ulRes, FALSE);
1079 }
static UINT WDML_Initialize(LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes, BOOL bUnicode)
Definition: ddemisc.c:827

Referenced by dde_connect(), doChild(), START_TEST(), test_dde_aw_transaction(), test_dde_default_app(), test_DdeCreateDataHandle(), test_ddeml_client(), test_ddeml_server(), test_end_to_end_client(), test_end_to_end_server(), and test_initialisation().

◆ DdeInitializeW()

UINT WINAPI DdeInitializeW ( LPDWORD  pidInst,
PFNCALLBACK  pfnCallback,
DWORD  afCmd,
DWORD  ulRes 
)

Definition at line 1095 of file ddemisc.c.

1097 {
1098  return WDML_Initialize(pidInst, pfnCallback, afCmd, ulRes, TRUE);
1099 }
#define TRUE
Definition: types.h:120
static UINT WDML_Initialize(LPDWORD pidInst, PFNCALLBACK pfnCallback, DWORD afCmd, DWORD ulRes, BOOL bUnicode)
Definition: ddemisc.c:827

Referenced by dde_connect(), init_dde(), ShellDDEInit(), START_TEST(), test_dde_aw_transaction(), test_DdeCreateStringHandle(), test_end_to_end_client(), and test_end_to_end_server().

◆ DdeKeepStringHandle()

BOOL WINAPI DdeKeepStringHandle ( DWORD  idInst,
HSZ  hsz 
)

Definition at line 654 of file ddemisc.c.

655 {
656  WDML_INSTANCE* pInstance;
657  BOOL ret = FALSE;
658 
659  TRACE("(%d,%p):\n", idInst, hsz);
660 
661  /* First check instance
662  */
663  pInstance = WDML_GetInstance(idInst);
664  if (pInstance)
665  ret = WDML_IncHSZ(pInstance, hsz);
666 
667  return ret;
668 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:362
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
int ret

◆ DdeQueryConvInfo()

UINT WINAPI DdeQueryConvInfo ( HCONV  hConv,
DWORD  id,
PCONVINFO  lpConvInfo 
)

Definition at line 2426 of file ddemisc.c.

2427 {
2428  UINT ret = lpConvInfo->cb;
2429  CONVINFO ci;
2430  WDML_CONV* pConv;
2431 
2432  TRACE("(%p,%x,%p)\n", hConv, id, lpConvInfo);
2433 
2434  if (!hConv)
2435  {
2436  FIXME("hConv is NULL\n");
2437  return 0;
2438  }
2439 
2440  pConv = WDML_GetConv(hConv, FALSE);
2441  if (pConv != NULL)
2442  {
2443  if (!WDML_GetLocalConvInfo(pConv, &ci, id))
2444  ret = 0;
2445  }
2446  else
2447  {
2448  if ((ULONG_PTR)hConv & 1)
2449  {
2450  pConv = WDML_GetConv((HCONV)((ULONG_PTR)hConv & ~1), FALSE);
2451  if (pConv != NULL)
2452  FIXME("Request on remote conversation information is not implemented yet\n");
2453  }
2454  ret = 0;
2455  }
2456 
2457  if (ret != 0)
2458  {
2459  ci.cb = lpConvInfo->cb;
2460  memcpy(lpConvInfo, &ci, min((size_t)lpConvInfo->cb, sizeof(ci)));
2461  }
2462  return ret;
2463 }
static BOOL WDML_GetLocalConvInfo(WDML_CONV *pConv, CONVINFO *ci, DWORD id)
Definition: ddemisc.c:2349
DWORD cb
Definition: ddeml.h:317
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
WDML_CONV * WDML_GetConv(HCONV hConv, BOOL checkConnected)
Definition: ddemisc.c:2230
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50

Referenced by test_dde_aw_transaction().

◆ DdeQueryStringA()

DWORD WINAPI DdeQueryStringA ( DWORD  idInst,
HSZ  hsz,
LPSTR  psz,
DWORD  cchMax,
INT  iCodePage 
)

Definition at line 501 of file ddemisc.c.

502 {
503  DWORD ret = 0;
504  WDML_INSTANCE* pInstance;
505 
506  TRACE("(%d, %p, %p, %d, %d)\n", idInst, hsz, psz, cchMax, iCodePage);
507 
508  /* First check instance
509  */
510  pInstance = WDML_GetInstance(idInst);
511  if (pInstance != NULL)
512  {
513  if (iCodePage == 0) iCodePage = CP_WINANSI;
514  ret = WDML_QueryString(pInstance, hsz, psz, cchMax, iCodePage);
515  }
516 
517  TRACE("returning %d (%s)\n", ret, debugstr_a(psz));
518  return ret;
519 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT cchMax
int ret
#define CP_WINANSI
Definition: ddeml.h:32
static int WDML_QueryString(WDML_INSTANCE *pInstance, HSZ hsz, LPVOID ptr, DWORD cchMax, int codepage)
Definition: ddemisc.c:461

Referenced by ddeCb(), server_ddeml_callback(), server_end_to_end_callback(), and test_DdeCreateStringHandleW().

◆ DdeQueryStringW()

DWORD WINAPI DdeQueryStringW ( DWORD  idInst,
HSZ  hsz,
LPWSTR  psz,
DWORD  cchMax,
INT  iCodePage 
)

Definition at line 525 of file ddemisc.c.

526 {
527  DWORD ret = 0;
528  WDML_INSTANCE* pInstance;
529 
530  TRACE("(%d, %p, %p, %d, %d)\n", idInst, hsz, psz, cchMax, iCodePage);
531 
532  /* First check instance
533  */
534  pInstance = WDML_GetInstance(idInst);
535  if (pInstance != NULL)
536  {
537  if (iCodePage == 0) iCodePage = CP_WINUNICODE;
538  ret = WDML_QueryString(pInstance, hsz, psz, cchMax, iCodePage);
539  }
540 
541  TRACE("returning %d (%s)\n", ret, debugstr_w(psz));
542  return ret;
543 }
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
UINT cchMax
int ret
static int WDML_QueryString(WDML_INSTANCE *pInstance, HSZ hsz, LPVOID ptr, DWORD cchMax, int codepage)
Definition: ddemisc.c:461
#define CP_WINUNICODE
Definition: ddeml.h:33

Referenced by Dde_OnConnect(), Dde_OnConnectConfirm(), Dde_OnExecute(), Dde_OnRequest(), Dde_OnWildConnect(), test_DdeCreateStringHandleW(), and WDML_AddServer().

◆ DdeSetQualityOfService()

BOOL WINAPI DdeSetQualityOfService ( HWND  hwndClient,
const SECURITY_QUALITY_OF_SERVICE pqosNew,
PSECURITY_QUALITY_OF_SERVICE  pqosPrev 
)

Definition at line 231 of file ddemisc.c.

233 {
234  FIXME("(%p %p %p): stub\n", hwndClient, pqosNew, pqosPrev);
235  return TRUE;
236 }
#define TRUE
Definition: types.h:120
#define FIXME(fmt,...)
Definition: debug.h:110

◆ DdeSetUserHandle()

BOOL WINAPI DdeSetUserHandle ( HCONV  hConv,
DWORD  id,
DWORD  hUser 
)

Definition at line 2314 of file ddemisc.c.

2315 {
2316  WDML_CONV* pConv;
2317 
2318  pConv = WDML_GetConv(hConv, FALSE);
2319  if (pConv == NULL)
2320  return FALSE;
2321 
2322  if (id == QID_SYNC)
2323  {
2324  pConv->hUser = hUser;
2325  }
2326  else
2327  {
2328  WDML_XACT* pXAct;
2329 
2330  pXAct = WDML_FindTransaction(pConv, id);
2331  if (pXAct)
2332  {
2333  pXAct->hUser = hUser;
2334  }
2335  else
2336  {
2337  pConv->instance->lastError = DMLERR_UNFOUND_QUEUE_ID;
2338  return FALSE;
2339  }
2340  }
2341  return TRUE;
2342 }
#define TRUE
Definition: types.h:120
static WDML_XACT * WDML_FindTransaction(WDML_CONV *pConv, DWORD tid)
Definition: ddemisc.c:1984
#define DMLERR_UNFOUND_QUEUE_ID
Definition: ddeml.h:263
smooth NULL
Definition: ftsmooth.c:416
WDML_CONV * WDML_GetConv(HCONV hConv, BOOL checkConnected)
Definition: ddemisc.c:2230
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
#define QID_SYNC
Definition: ddeml.h:40

◆ DdeUnaccessData()

BOOL WINAPI DdeUnaccessData ( HDDEDATA  hData)

Definition at line 1447 of file ddemisc.c.

1448 {
1449  HGLOBAL hMem = hData;
1450 
1451  TRACE("(%p)\n", hData);
1452 
1453  GlobalUnlock(hMem);
1454 
1455  return TRUE;
1456 }
#define TRUE
Definition: types.h:120
#define TRACE(s)
Definition: solgame.cpp:4
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by Dde_OnExecute(), DdeAddData(), DdeGetData(), server_ddeml_callback(), test_DdeCreateDataHandle(), test_ddeml_client(), WDML_ClientQueueExecute(), and WDML_ServerNameProc().

◆ DdeUninitialize()

BOOL WINAPI DdeUninitialize ( DWORD  idInst)

Definition at line 1112 of file ddemisc.c.

1113 {
1114  /* Stage one - check if we have a handle for this instance
1115  */
1116  WDML_INSTANCE* pInstance;
1117  WDML_CONV* pConv;
1118  WDML_CONV* pConvNext;
1119 
1120  TRACE("(%d)\n", idInst);
1121 
1122  /* First check instance
1123  */
1124  pInstance = WDML_GetInstance(idInst);
1125  if (pInstance == NULL)
1126  {
1127  /*
1128  * Needs something here to record NOT_INITIALIZED ready for DdeGetLastError
1129  */
1130  return FALSE;
1131  }
1132 
1133  /* first terminate all conversations client side
1134  * this shall close existing links...
1135  */
1136  for (pConv = pInstance->convs[WDML_CLIENT_SIDE]; pConv != NULL; pConv = pConvNext)
1137  {
1138  pConvNext = pConv->next;
1139  DdeDisconnect((HCONV)pConv);
1140  }
1141  if (pInstance->convs[WDML_CLIENT_SIDE])
1142  FIXME("still pending conversations\n");
1143 
1144  /* then unregister all known service names */
1145  DdeNameService(idInst, 0, 0, DNS_UNREGISTER);
1146 
1147  /* Free the nodes that were not freed by this instance
1148  * and remove the nodes from the list of HSZ nodes.
1149  */
1150  WDML_FreeAllHSZ(pInstance);
1151 
1152  DestroyWindow(pInstance->hwndEvent);
1153 
1154  /* OK now delete the instance handle itself */
1155 
1156  if (WDML_InstanceList == pInstance)
1157  {
1158  /* special case - the first/only entry */
1159  WDML_InstanceList = pInstance->next;
1160  }
1161  else
1162  {
1163  /* general case, remove entry */
1164  WDML_INSTANCE* inst;
1165 
1166  for (inst = WDML_InstanceList; inst->next != pInstance; inst = inst->next);
1167  inst->next = pInstance->next;
1168  }
1169  /* release the heap entry
1170  */
1171  HeapFree(GetProcessHeap(), 0, pInstance);
1172 
1173  return TRUE;
1174 }
#define DNS_UNREGISTER
Definition: ddeml.h:153
WDML_INSTANCE * WDML_GetInstance(DWORD instId)
Definition: ddemisc.c:1230
#define TRUE
Definition: types.h:120
struct tagWDML_CONV * next
Definition: dde_private.h:126
static WDML_INSTANCE * WDML_InstanceList
Definition: ddemisc.c:36
static void WDML_FreeAllHSZ(WDML_INSTANCE *pInstance)
Definition: ddemisc.c:419
BOOL WINAPI DestroyWindow(_In_ HWND)
WDML_CONV * convs[2]
Definition: dde_private.h:168
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI DdeDisconnect(HCONV)
Definition: ddeclient.c:1363
#define GetProcessHeap()
Definition: compat.h:395
HDDEDATA WINAPI DdeNameService(DWORD, HSZ, HSZ, UINT)
Definition: ddeserver.c:154
struct tagWDML_INSTANCE * next
Definition: dde_private.h:154
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by dde_connect(), doChild(), release_dde(), ShellDDEInit(), START_TEST(), test_dde_default_app(), test_DdeCreateDataHandle(), test_DdeCreateStringHandle(), test_ddeml_client(), test_ddeml_server(), test_end_to_end_client(), test_end_to_end_server(), test_initialisation(), and WDML_NotifyThreadDetach().

◆ FreeDDElParam()

BOOL WINAPI FreeDDElParam ( UINT  msg,
LPARAM  lParam 
)

Definition at line 147 of file ddemisc.c.

148 {
149  switch (msg)
150  {
151  case WM_DDE_ACK:
152  case WM_DDE_ADVISE:
153  case WM_DDE_DATA:
154  case WM_DDE_POKE:
155  /* first check if it's a global handle */
156  if (!GlobalHandle( (LPVOID)lParam )) return TRUE;
157  return !GlobalFree( (HGLOBAL)lParam );
158 
159  default:
160  return TRUE;
161  }
162 }
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalHandle(LPCVOID pMem)
Definition: heapmem.c:705
#define WM_DDE_DATA
Definition: dde.h:42
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define WM_DDE_POKE
Definition: dde.h:44
#define msg(x)
Definition: auth_time.c:54
#define WM_DDE_ACK
Definition: dde.h:41
#define WM_DDE_ADVISE
Definition: dde.h:39
LPARAM lParam
Definition: combotst.c:139

Referenced by post_dde_message(), ReuseDDElParam(), test_FreeDDElParam(), test_PackDDElParam(), WDML_HandleAdviseReply(), WDML_HandleExecuteReply(), WDML_HandleIncomingData(), WDML_HandlePokeReply(), WDML_HandleRequestReply(), WDML_HandleUnadviseReply(), WDML_PostAck(), and WDML_ServerHandleUnadvise().

◆ ImpersonateDdeClientWindow()

BOOL WINAPI ImpersonateDdeClientWindow ( HWND  hWndClient,
HWND  hWndServer 
)

Definition at line 221 of file ddemisc.c.

222 {
223  FIXME("(%p %p): stub\n", hWndClient, hWndServer);
224  return FALSE;
225 }
#define FIXME(fmt,...)
Definition: debug.h:110

Referenced by DdeImpersonateClient().

◆ PackDDElParam()

LPARAM WINAPI PackDDElParam ( UINT  msg,
UINT_PTR  uiLo,
UINT_PTR  uiHi 
)

Definition at line 63 of file ddemisc.c.

64 {
65  HGLOBAL hMem;
67 
68  switch (msg)
69  {
70  case WM_DDE_ACK:
71  case WM_DDE_ADVISE:
72  case WM_DDE_DATA:
73  case WM_DDE_POKE:
74  if (!(hMem = GlobalAlloc(GMEM_DDESHARE, sizeof(UINT_PTR) * 2)))
75  {
76  ERR("GlobalAlloc failed\n");
77  return 0;
78  }
79  if (!(params = GlobalLock(hMem)))
80  {
81  ERR("GlobalLock failed (%p)\n", hMem);
82  return 0;
83  }
84  params[0] = uiLo;
85  params[1] = uiHi;
86  GlobalUnlock(hMem);
87  return (LPARAM)hMem;
88 
89  case WM_DDE_EXECUTE:
90  return uiHi;
91 
92  default:
93  return MAKELONG(uiLo, uiHi);
94  }
95 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
GLenum const GLfloat * params
Definition: glext.h:5645
#define WM_DDE_DATA
Definition: dde.h:42
#define MAKELONG(a, b)
Definition: typedefs.h:248
LONG_PTR LPARAM
Definition: windef.h:208
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WM_DDE_POKE
Definition: dde.h:44
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define ERR(fmt,...)
Definition: debug.h:109
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_DDESHARE
Definition: winbase.h:295
#define msg(x)
Definition: auth_time.c:54
#define WM_DDE_ACK
Definition: dde.h:41
#define WM_DDE_ADVISE
Definition: dde.h:39
#define WM_DDE_EXECUTE
Definition: dde.h:45

Referenced by dde_server_wndproc(), dde_server_wndprocA(), dde_server_wndprocW(), DdePostAdvise(), ReuseDDElParam(), test_msg_client(), test_PackDDElParam(), unpack_dde_message(), WDML_ClientQueueAdvise(), WDML_ClientQueuePoke(), WDML_ClientQueueRequest(), WDML_ClientQueueUnadvise(), and WDML_PostAck().

◆ ReuseDDElParam()

LPARAM WINAPI ReuseDDElParam ( LPARAM  lParam,
UINT  msgIn,
UINT  msgOut,
UINT_PTR  uiLo,
UINT_PTR  uiHi 
)

Definition at line 171 of file ddemisc.c.

173 {
174  UINT_PTR *params;
175 
176  switch (msgIn)
177  {
178  case WM_DDE_ACK:
179  case WM_DDE_ADVISE:
180  case WM_DDE_DATA:
181  case WM_DDE_POKE:
182  switch(msgOut)
183  {
184  case WM_DDE_ACK:
185  case WM_DDE_ADVISE:
186  case WM_DDE_DATA:
187  case WM_DDE_POKE:
188  if (!lParam) return 0;
189  if (!(params = GlobalLock( (HGLOBAL)lParam )))
190  {
191  ERR("GlobalLock failed\n");
192  return 0;
193  }
194  params[0] = uiLo;
195  params[1] = uiHi;
196  TRACE("Reusing pack %08lx %08lx\n", uiLo, uiHi);
198  return lParam;
199 
200  case WM_DDE_EXECUTE:
201  FreeDDElParam( msgIn, lParam );
202  return uiHi;
203 
204  default:
205  FreeDDElParam( msgIn, lParam );
206  return MAKELPARAM(uiLo, uiHi);
207  }
208 
209  default:
210  return PackDDElParam( msgOut, uiLo, uiHi );
211  }
212 }
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
GLenum const GLfloat * params
Definition: glext.h:5645
#define WM_DDE_DATA
Definition: dde.h:42
#define TRACE(s)
Definition: solgame.cpp:4
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WM_DDE_POKE
Definition: dde.h:44
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define ERR(fmt,...)
Definition: debug.h:109
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam)
Definition: ddemisc.c:147
LPARAM WINAPI PackDDElParam(UINT msg, UINT_PTR uiLo, UINT_PTR uiHi)
Definition: ddemisc.c:63
#define WM_DDE_ACK
Definition: dde.h:41
#define WM_DDE_ADVISE
Definition: dde.h:39
#define WM_DDE_EXECUTE
Definition: dde.h:45
LPARAM lParam
Definition: combotst.c:139

Referenced by dde_server_wndproc(), dde_server_wndprocA(), dde_server_wndprocW(), WDML_PostAck(), and WDML_ServerHandleRequest().

◆ UnpackDDElParam()

BOOL WINAPI UnpackDDElParam ( UINT  msg,
LPARAM  lParam,
PUINT_PTR  uiLo,
PUINT_PTR  uiHi 
)

Definition at line 105 of file ddemisc.c.

107 {
108  UINT_PTR *params;
109 
110  switch (msg)
111  {
112  case WM_DDE_ACK:
113  case WM_DDE_ADVISE:
114  case WM_DDE_DATA:
115  case WM_DDE_POKE:
116  if (!lParam || !(params = GlobalLock((HGLOBAL)lParam)))
117  {
118  if (uiLo) *uiLo = 0;
119  if (uiHi) *uiHi = 0;
120  return FALSE;
121  }
122  if (uiLo) *uiLo = params[0];
123  if (uiHi) *uiHi = params[1];
125  return TRUE;
126 
127  case WM_DDE_EXECUTE:
128  if (uiLo) *uiLo = 0;
129  if (uiHi) *uiHi = lParam;
130  return TRUE;
131 
132  default:
133  if (uiLo) *uiLo = LOWORD(lParam);
134  if (uiHi) *uiHi = HIWORD(lParam);
135  return TRUE;
136  }
137 }
#define TRUE
Definition: types.h:120
GLenum const GLfloat * params
Definition: glext.h:5645
#define WM_DDE_DATA
Definition: dde.h:42
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WM_DDE_POKE
Definition: dde.h:44
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define msg(x)
Definition: auth_time.c:54
#define WM_DDE_ACK
Definition: dde.h:41
#define HIWORD(l)
Definition: typedefs.h:246
#define WM_DDE_ADVISE
Definition: dde.h:39
#define WM_DDE_EXECUTE
Definition: dde.h:45
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82

Referenced by dde_msg_client_wndproc(), dde_server_wndproc(), dde_server_wndprocA(), dde_server_wndprocW(), hook_dde_client_wndprocA(), hook_dde_client_wndprocW(), post_dde_message(), test_PackDDElParam(), test_UnpackDDElParam(), WDML_HandleAdviseReply(), WDML_HandleExecuteReply(), WDML_HandleIncomingData(), WDML_HandlePokeReply(), WDML_HandleRequestReply(), WDML_HandleUnadviseReply(), WDML_ServerNameProc(), WDML_ServerQueueAdvise(), WDML_ServerQueuePoke(), WDML_ServerQueueRequest(), and WDML_ServerQueueUnadvise().

◆ WDML_AddConv()

WDML_CONV* WDML_AddConv ( WDML_INSTANCE pInstance,
WDML_SIDE  side,
HSZ  hszService,
HSZ  hszTopic,
HWND  hwndClient,
HWND  hwndServer 
)

Definition at line 2008 of file ddemisc.c.

2010 {
2011  WDML_CONV* pConv;
2012 
2013  /* no conversation yet, add it */
2014  pConv = HeapAlloc(GetProcessHeap(), 0, sizeof(WDML_CONV));
2015  if (!pConv) return NULL;
2016 
2017  pConv->instance = pInstance;
2018  WDML_IncHSZ(pInstance, pConv->hszService = hszService);
2019  WDML_IncHSZ(pInstance, pConv->hszTopic = hszTopic);
2020  pConv->magic = WDML_CONV_MAGIC;
2021  pConv->hwndServer = hwndServer;
2022  pConv->hwndClient = hwndClient;
2023  pConv->transactions = NULL;
2024  pConv->hUser = 0;
2025  pConv->wStatus = (side == WDML_CLIENT_SIDE) ? ST_CLIENT : 0L;
2026  pConv->wStatus |= pInstance->wStatus;
2027  /* check if both side of the conversation are of the same instance */
2028  if (GetWindowThreadProcessId(hwndClient, NULL) == GetWindowThreadProcessId(hwndServer, NULL) &&
2029  WDML_GetInstanceFromWnd(hwndClient) == WDML_GetInstanceFromWnd(hwndServer))
2030  {
2031  pConv->wStatus |= ST_ISSELF;
2032  }
2033  pConv->wConvst = XST_NULL;
2034 
2035  pConv->next = pInstance->convs[side];
2036  pInstance->convs[side] = pConv;
2037 
2038  TRACE("pConv->wStatus %04x pInstance(%p)\n", pConv->wStatus, pInstance);
2039 
2040  return pConv;
2041 }
struct tagWDML_CONV * next
Definition: dde_private.h:126
#define ST_CLIENT
Definition: ddeml.h:84
WDML_XACT * transactions
Definition: dde_private.h:135
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:362
WDML_CONV * convs[2]
Definition: dde_private.h:168
#define XST_NULL
Definition: ddeml.h:62
#define WDML_CONV_MAGIC
Definition: dde_private.h:141
DWORD WINAPI GetWindowThreadProcessId(HWND, PDWORD)
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ST_ISSELF
Definition: ddeml.h:88
static const WCHAR L[]
Definition: oid.c:1250
static HSZ hszTopic
Definition: shlexec.c:155
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
WDML_INSTANCE * WDML_GetInstanceFromWnd(HWND hWnd)
Definition: ddemisc.c:1261

Referenced by WDML_ClientProc(), and WDML_CreateServerConv().

◆ WDML_AddLink()

void WDML_AddLink ( WDML_INSTANCE pInstance,
HCONV  hConv,
WDML_SIDE  side,
UINT  wType,
HSZ  hszItem,
UINT  wFmt 
)

Definition at line 1755 of file ddemisc.c.

1757 {
1758  WDML_LINK* pLink;
1759 
1760  pLink = HeapAlloc(GetProcessHeap(), 0, sizeof(WDML_LINK));
1761  if (pLink == NULL)
1762  {
1763  ERR("OOM\n");
1764  return;
1765  }
1766 
1767  pLink->hConv = hConv;
1768  pLink->transactionType = wType;
1769  WDML_IncHSZ(pInstance, pLink->hszItem = hszItem);
1770  pLink->uFmt = wFmt;
1771  pLink->next = pInstance->links[side];
1772  pInstance->links[side] = pLink;
1773 }
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:362
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WDML_LINK * links[2]
Definition: dde_private.h:169
#define ERR(fmt,...)
Definition: debug.h:109

Referenced by WDML_HandleAdviseReply(), and WDML_ServerHandleAdvise().

◆ WDML_AddServer()

WDML_SERVER* WDML_AddServer ( WDML_INSTANCE pInstance,
HSZ  hszService,
HSZ  hszTopic 
)

Definition at line 1638 of file ddemisc.c.

1639 {
1640  static const WCHAR fmtW[] = {'%','s','(','0','x','%','*','x',')',0};
1641  WDML_SERVER* pServer;
1642  WCHAR buf1[256];
1643  WCHAR buf2[256];
1644 
1645  pServer = HeapAlloc(GetProcessHeap(), 0, sizeof(WDML_SERVER));
1646  if (pServer == NULL) return NULL;
1647 
1648  pServer->hszService = hszService;
1649  WDML_IncHSZ(pInstance, hszService);
1650 
1651  DdeQueryStringW(pInstance->instanceID, hszService, buf1, 256, CP_WINUNICODE);
1652  snprintfW(buf2, 256, fmtW, buf1, 2*sizeof(ULONG_PTR), GetCurrentProcessId());
1653  pServer->hszServiceSpec = DdeCreateStringHandleW(pInstance->instanceID, buf2, CP_WINUNICODE);
1654 
1655  pServer->atomService = WDML_MakeAtomFromHsz(pServer->hszService);
1657 
1658  pServer->filterOn = TRUE;
1659 
1660  pServer->next = pInstance->servers;
1661  pInstance->servers = pServer;
1662  return pServer;
1663 }
#define TRUE
Definition: types.h:120
#define snprintfW
Definition: unicode.h:60
ATOM WDML_MakeAtomFromHsz(HSZ hsz)
Definition: ddemisc.c:325
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:362
ATOM atomServiceSpec
Definition: dde_private.h:104
uint32_t ULONG_PTR
Definition: typedefs.h:63
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD WINAPI DdeQueryStringW(DWORD idInst, HSZ hsz, LPWSTR psz, DWORD cchMax, INT iCodePage)
Definition: ddemisc.c:525
#define CP_WINUNICODE
Definition: ddeml.h:33
HSZ WINAPI DdeCreateStringHandleW(DWORD idInst, LPCWSTR psz, INT codepage)
Definition: ddemisc.c:608
WDML_SERVER * servers
Definition: dde_private.h:167
DWORD WINAPI GetCurrentProcessId(VOID)
Definition: proc.c:1188
struct tagWDML_SERVER * next
Definition: dde_private.h:100

Referenced by DdeNameService().

◆ WDML_AllocTransaction()

WDML_XACT* WDML_AllocTransaction ( WDML_INSTANCE pInstance,
UINT  ddeMsg,
UINT  wFmt,
HSZ  hszItem 
)

Definition at line 1900 of file ddemisc.c.

1902 {
1903  WDML_XACT* pXAct;
1904  static WORD tid = 1; /* FIXME: wrap around */
1905 
1906  pXAct = HeapAlloc(GetProcessHeap(), 0, sizeof(WDML_XACT));
1907  if (!pXAct)
1908  {
1909  pInstance->lastError = DMLERR_MEMORY_ERROR;
1910  return NULL;
1911  }
1912 
1913  pXAct->xActID = tid++;
1914  pXAct->ddeMsg = ddeMsg;
1915  pXAct->hDdeData = 0;
1916  pXAct->hUser = 0;
1917  pXAct->next = NULL;
1918  pXAct->wType = 0;
1919  pXAct->wFmt = wFmt;
1920  if ((pXAct->hszItem = hszItem)) WDML_IncHSZ(pInstance, pXAct->hszItem);
1921  pXAct->atom = 0;
1922  pXAct->hMem = 0;
1923  pXAct->lParam = 0;
1924 
1925  return pXAct;
1926 }
HDDEDATA hDdeData
Definition: dde_private.h:113
HGLOBAL hMem
Definition: dde_private.h:120
#define DMLERR_MEMORY_ERROR
Definition: ddeml.h:254
BOOL WDML_IncHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:362
LPARAM lParam
Definition: dde_private.h:121
struct tagWDML_XACT * next
Definition: dde_private.h:110
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned short WORD
Definition: ntddk_ex.h:93
static TfClientId tid

Referenced by WDML_ClientQueueAdvise(), WDML_ClientQueueExecute(), WDML_ClientQueuePoke(), WDML_ClientQueueRequest(), WDML_ClientQueueTerminate(), WDML_ClientQueueUnadvise(), WDML_ServerQueueAdvise(), WDML_ServerQueueExecute(), WDML_ServerQueuePoke(), WDML_ServerQueueRequest(), WDML_ServerQueueTerminate(), and WDML_ServerQueueUnadvise().

◆ WDML_BroadcastDDEWindows()

void WDML_BroadcastDDEWindows ( LPCWSTR  clsName,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 2502 of file ddemisc.c.

2503 {
2504  struct tagWDML_BroadcastPmt s;
2505 
2506  s.clsName = clsName;
2507  s.uMsg = uMsg;
2508  s.wParam = wParam;
2509  s.lParam = lParam;
2511 }
static BOOL CALLBACK WDML_BroadcastEnumProc(HWND hWnd, LPARAM lParam)
Definition: ddemisc.c:2484
WPARAM wParam
Definition: combotst.c:138
LONG_PTR LPARAM
Definition: windef.h:208
BOOL WINAPI EnumWindows(_In_ WNDENUMPROC, _In_ LPARAM)
GLdouble s
Definition: gl.h:2039
LPARAM lParam
Definition: combotst.c:139

Referenced by DdeNameService(), and WDML_RemoveServer().

◆ WDML_BroadcastEnumProc()

static BOOL CALLBACK WDML_BroadcastEnumProc ( HWND  hWnd,
LPARAM  lParam 
)
static

Definition at line 2484 of file ddemisc.c.

2485 {
2487  WCHAR buffer[128];
2488 
2489  if (GetClassNameW(hWnd, buffer, 128) > 0 &&
2490  lstrcmpiW(buffer, s->clsName) == 0)
2491  {
2492  PostMessageW(hWnd, s->uMsg, s->wParam, s->lParam);
2493  }
2494  return TRUE;
2495 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
GLuint buffer
Definition: glext.h:5915
int WINAPI lstrcmpiW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:194
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
__wchar_t WCHAR
Definition: xmlstorage.h:180
GLdouble s
Definition: gl.h:2039
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139

Referenced by WDML_BroadcastDDEWindows().

◆ WDML_CreateString()

static HSZ WDML_CreateString ( WDML_INSTANCE pInstance,
LPCVOID  ptr,
int  codepage 
)
static

Definition at line 550 of file ddemisc.c.

551 {
552  HSZ hsz;
553 
554  switch (codepage)
555  {
556  case CP_WINANSI:
557  hsz = ATOM2HSZ(AddAtomA(ptr));
558  TRACE("added atom %s with HSZ %p,\n", debugstr_a(ptr), hsz);
559  break;
560  case CP_WINUNICODE:
561  hsz = ATOM2HSZ(AddAtomW(ptr));
562  TRACE("added atom %s with HSZ %p,\n", debugstr_w(ptr), hsz);
563  break;
564  default:
565  ERR("Unknown code page %d\n", codepage);
566  return 0;
567  }
568  WDML_InsertHSZNode(pInstance, hsz);
569  return hsz;
570 }
#define ATOM2HSZ(atom)
Definition: ddemisc.c:33
static void WDML_InsertHSZNode(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:434
#define debugstr_w
Definition: kernel32.h:32
static PVOID ptr
Definition: dispmode.c:27
int codepage
Definition: win_iconv.c:156
ATOM WINAPI AddAtomW(LPCWSTR lpString)
Definition: atom.c:536
#define TRACE(s)
Definition: solgame.cpp:4
#define debugstr_a
Definition: kernel32.h:31
ATOM WINAPI AddAtomA(LPCSTR lpString)
Definition: atom.c:526
#define ERR(fmt,...)
Definition: debug.h:109
#define CP_WINANSI
Definition: ddeml.h:32
#define CP_WINUNICODE
Definition: ddeml.h:33

Referenced by DdeCreateStringHandleA(), and DdeCreateStringHandleW().

◆ WDML_DataHandle2Global()

HGLOBAL WDML_DataHandle2Global ( HDDEDATA  hDdeData,
BOOL  fResponse,
BOOL  fRelease,
BOOL  fDeferUpd,
BOOL  fAckReq 
)

Definition at line 1563 of file ddemisc.c.

1565 {
1566  DDE_DATAHANDLE_HEAD* pDdh;
1567  DWORD dwSize;
1568  HGLOBAL hMem = 0;
1569 
1570  dwSize = GlobalSize(hDdeData) - sizeof(DDE_DATAHANDLE_HEAD);
1571  pDdh = GlobalLock(hDdeData);
1572  if (dwSize && pDdh)
1573  {
1574  WINE_DDEHEAD* wdh = NULL;
1575 
1576  switch (pDdh->cfFormat)
1577  {
1578  default:
1579  FIXME("Unsupported format (%04x) for data %p, passing raw information\n",
1580  pDdh->cfFormat, hDdeData);
1581  /* fall through */
1582  case 0:
1583  case CF_TEXT:
1585  if (hMem && (wdh = GlobalLock(hMem)))
1586  {
1587  memcpy(wdh + 1, pDdh + 1, dwSize);
1588  }
1589  break;
1590  case CF_BITMAP:
1591  if (dwSize >= sizeof(HBITMAP))
1592  {
1593  BITMAP bmp;
1594  DWORD count;
1595  HBITMAP hbmp = *(HBITMAP*)(pDdh + 1);
1596 
1597  if (GetObjectW(hbmp, sizeof(bmp), &bmp))
1598  {
1599  count = bmp.bmWidthBytes * bmp.bmHeight;
1601  sizeof(WINE_DDEHEAD) + sizeof(bmp) + count);
1602  if (hMem && (wdh = GlobalLock(hMem)))
1603  {
1604  memcpy(wdh + 1, &bmp, sizeof(bmp));
1605  GetBitmapBits(hbmp, count, ((char*)(wdh + 1)) + sizeof(bmp));
1606  }
1607  }
1608  }
1609  break;
1610  }
1611  if (wdh)
1612  {
1613  wdh->unused = 0;
1614  wdh->fResponse = fResponse;
1615  wdh->fRelease = fRelease;
1616  wdh->fDeferUpd = fDeferUpd;
1617  wdh->fAckReq = fAckReq;
1618  wdh->cfFormat = pDdh->cfFormat;
1619  GlobalUnlock(hMem);
1620  }
1621  GlobalUnlock(hDdeData);
1622  }
1623 
1624  return hMem;
1625 }
unsigned short fResponse
Definition: dde_private.h:83
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
unsigned short fAckReq
Definition: dde_private.h:83
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned short fRelease
Definition: dde_private.h:83
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
#define FIXME(fmt,...)
Definition: debug.h:110
#define CF_BITMAP
Definition: constants.h:397
smooth NULL
Definition: ftsmooth.c:416
#define CF_TEXT
Definition: constants.h:396
HBITMAP hbmp
unsigned short fDeferUpd
Definition: dde_private.h:83
LONG WINAPI GetBitmapBits(_In_ HBITMAP hbit, _In_ LONG cb, _Out_writes_bytes_(cb) LPVOID lpvBits)
unsigned long DWORD
Definition: ntddk_ex.h:95
BITMAP bmp
Definition: alphablend.c:62
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
unsigned short unused
Definition: dde_private.h:83
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
struct tagDDE_DATAHANDLE_HEAD DDE_DATAHANDLE_HEAD
int WINAPI GetObjectW(_In_ HANDLE h, _In_ int c, _Out_writes_bytes_opt_(c) LPVOID pv)
Definition: bl.h:1331
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define GMEM_DDESHARE
Definition: winbase.h:295
short cfFormat
Definition: dde_private.h:88
static HBITMAP
Definition: button.c:44
#define GMEM_MOVEABLE
Definition: winbase.h:291
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54

Referenced by DdePostAdvise(), and WDML_ServerHandleRequest().

◆ WDML_DecHSZ()

BOOL WDML_DecHSZ ( WDML_INSTANCE pInstance,
HSZ  hsz 
)

Definition at line 380 of file ddemisc.c.

381 {
382  HSZNode* pPrev = NULL;
383  HSZNode* pCurrent;
384 
385  for (pCurrent = pInstance->nodeList; pCurrent != NULL; pCurrent = (pPrev = pCurrent)->next)
386  {
387  /* If we found the node we were looking for and its ref count is one,
388  * we can remove it
389  */
390  if (pCurrent->hsz == hsz)
391  {
392  if (--pCurrent->refCount == 0)
393  {
394  if (pCurrent == pInstance->nodeList)
395  {
396  pInstance->nodeList = pCurrent->next;
397  }
398  else
399  {
400  pPrev->next = pCurrent->next;
401  }
402  HeapFree(GetProcessHeap(), 0, pCurrent);
403  DeleteAtom(HSZ2ATOM(hsz));
404  }
405  return TRUE;
406  }
407  }
408  WARN("HSZ %p not found\n", hsz);
409 
410  return FALSE;
411 }
#define HSZ2ATOM(hsz)
Definition: ddemisc.c:34
struct tagHSZNode * next
Definition: dde_private.h:93
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
ATOM WINAPI DeleteAtom(ATOM nAtom)
Definition: atom.c:546
smooth NULL
Definition: ftsmooth.c:416
HSZNode * nodeList
Definition: dde_private.h:160
#define GetProcessHeap()
Definition: compat.h:395
unsigned refCount
Definition: dde_private.h:95
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DdeFreeStringHandle(), WDML_EventProc(), WDML_FreeTransaction(), WDML_HandleIncomingData(), WDML_RemoveAllLinks(), WDML_RemoveConv(), WDML_RemoveLink(), WDML_RemoveServer(), WDML_ServerHandleAdvise(), WDML_ServerHandlePoke(), WDML_ServerHandleRequest(), and WDML_ServerHandleUnadvise().

◆ WDML_EnableCallback()

static BOOL WDML_EnableCallback ( WDML_CONV pConv,
UINT  wCmd 
)
static

Definition at line 2127 of file ddemisc.c.

2128 {
2129  if (wCmd == EC_DISABLE)
2130  {
2131  pConv->wStatus |= ST_BLOCKED;
2132  TRACE("EC_DISABLE: conv %p status flags %04x\n", pConv, pConv->wStatus);
2133  return TRUE;
2134  }
2135 
2136  if (wCmd == EC_QUERYWAITING)
2137  return pConv->transactions != NULL;
2138 
2139  if (wCmd != EC_ENABLEALL && wCmd != EC_ENABLEONE)
2140  {
2141  FIXME("Unknown command code %04x\n", wCmd);
2142  return FALSE;
2143  }
2144 
2145  if (wCmd == EC_ENABLEALL)
2146  {
2147  pConv->wStatus &= ~ST_BLOCKED;
2148  TRACE("EC_ENABLEALL: conv %p status flags %04x\n", pConv, pConv->wStatus);
2149  }
2150 
2151  while (pConv->transactions)
2152  {
2153  WDML_XACT *pXAct = pConv->transactions;
2154 
2155  if (pConv->wStatus & ST_CLIENT)
2156  {
2157  /* transaction should be in the queue until handled */
2158  WDML_ClientHandle(pConv, pXAct, 0, NULL);
2159  WDML_UnQueueTransaction(pConv, pXAct);
2160  }
2161  else
2162  {
2163  /* transaction should be removed from the queue before handling */
2164  WDML_UnQueueTransaction(pConv, pXAct);
2165  WDML_ServerHandle(pConv, pXAct);
2166  }
2167 
2168  WDML_FreeTransaction(pConv->instance, pXAct, TRUE);
2169 
2170  if (wCmd == EC_ENABLEONE) break;
2171  }
2172  return TRUE;
2173 }
BOOL WDML_UnQueueTransaction(WDML_CONV *pConv, WDML_XACT *pXAct)
Definition: ddemisc.c:1947
#define TRUE
Definition: types.h:120
#define ST_CLIENT
Definition: ddeml.h:84
#define ST_BLOCKED
Definition: ddeml.h:83
WDML_XACT * transactions
Definition: dde_private.h:135
#define EC_QUERYWAITING
Definition: ddeml.h:97
HDDEDATA WDML_ClientHandle(WDML_CONV *pConv, WDML_XACT *pXAct, DWORD dwTimeout, LPDWORD pdwResult) DECLSPEC_HIDDEN
Definition: ddeclient.c:1090
#define EC_ENABLEONE
Definition: ddeml.h:95
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
WDML_QUEUE_STATE WDML_ServerHandle(WDML_CONV *pConv, WDML_XACT *pXAct) DECLSPEC_HIDDEN
Definition: ddeserver.c:968
#define TRACE(s)
Definition: solgame.cpp:4
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
#define EC_DISABLE
Definition: ddeml.h:96
void WDML_FreeTransaction(WDML_INSTANCE *pInstance, WDML_XACT *pXAct, BOOL doFreePmt)
Definition: ddemisc.c:1967
#define EC_ENABLEALL
Definition: ddeml.h:94

Referenced by DdeEnableCallback().

◆ WDML_EventProc()

static LRESULT CALLBACK WDML_EventProc ( HWND  hwndEvent,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 759 of file ddemisc.c.

760 {
761  WDML_INSTANCE* pInstance;
762  HSZ hsz1, hsz2;
763 
764  switch (uMsg)
765  {
766  case WM_WDML_REGISTER:
767  pInstance = WDML_GetInstanceFromWnd(hwndEvent);
768  /* try calling the Callback */
769  if (pInstance && !(pInstance->CBFflags & CBF_SKIP_REGISTRATIONS))
770  {
771  hsz1 = WDML_MakeHszFromAtom(pInstance, wParam);
772  hsz2 = WDML_MakeHszFromAtom(pInstance, lParam);
773  WDML_InvokeCallback(pInstance, XTYP_REGISTER, 0, 0, hsz1, hsz2, 0, 0, 0);
774  WDML_DecHSZ(pInstance, hsz1);
775  WDML_DecHSZ(pInstance, hsz2);
776  }
777  break;
778 
779  case WM_WDML_UNREGISTER:
780  pInstance = WDML_GetInstanceFromWnd(hwndEvent);
781  if (pInstance && !(pInstance->CBFflags & CBF_SKIP_UNREGISTRATIONS))
782  {
783  hsz1 = WDML_MakeHszFromAtom(pInstance, wParam);
784  hsz2 = WDML_MakeHszFromAtom(pInstance, lParam);
785  WDML_InvokeCallback(pInstance, XTYP_UNREGISTER, 0, 0, hsz1, hsz2, 0, 0, 0);
786  WDML_DecHSZ(pInstance, hsz1);
787  WDML_DecHSZ(pInstance, hsz2);
788  }
789  break;
790 
792  pInstance = WDML_GetInstanceFromWnd(hwndEvent);
793  if (pInstance && !(pInstance->CBFflags & CBF_SKIP_CONNECT_CONFIRMS))
794  {
795  WDML_CONV* pConv;
796  /* confirm connection...
797  * lookup for this conv handle
798  */
801  for (pConv = pInstance->convs[WDML_SERVER_SIDE]; pConv != NULL; pConv = pConv->next)
802  {
803  if (pConv->hwndClient == client && pConv->hwndServer == server)
804  break;
805  }
806  if (pConv)
807  {
808  pConv->wStatus |= ST_ISLOCAL;
809 
810  WDML_InvokeCallback(pInstance, XTYP_CONNECT_CONFIRM, 0, (HCONV)pConv,
811  pConv->hszTopic, pConv->hszService, 0, 0,
812  (pConv->wStatus & ST_ISSELF) ? 1 : 0);
813  }
814  }
815  break;
816  default:
817  return DefWindowProcW(hwndEvent, uMsg, wParam, lParam);
818  }
819  return 0;
820 }
#define ST_ISLOCAL
Definition: ddeml.h:82
struct tagWDML_CONV * next
Definition: dde_private.h:126
static rfbScreenInfoPtr server
Definition: vnc.c:74
#define CBF_SKIP_UNREGISTRATIONS
Definition: ddeml.h:113
#define XTYP_CONNECT_CONFIRM
Definition: ddeml.h:187
HSZ WDML_MakeHszFromAtom(const WDML_INSTANCE *pInstance, ATOM atom)
Definition: ddemisc.c:342
WPARAM wParam
Definition: combotst.c:138
WDML_CONV * convs[2]
Definition: dde_private.h:168
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define CBF_SKIP_REGISTRATIONS
Definition: ddeml.h:112
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
smooth NULL
Definition: ftsmooth.c:416
#define XTYP_REGISTER
Definition: ddeml.h:190
static FILE * client
Definition: client.c:41
#define ST_ISSELF
Definition: ddeml.h:88
#define CBF_SKIP_CONNECT_CONFIRMS
Definition: ddeml.h:111
#define WM_WDML_REGISTER
Definition: dde_private.h:248
HDDEDATA WDML_InvokeCallback(WDML_INSTANCE *pInstance, UINT uType, UINT uFmt, HCONV hConv, HSZ hsz1, HSZ hsz2, HDDEDATA hdata, ULONG_PTR dwData1, ULONG_PTR dwData2)
Definition: ddemisc.c:1206
LPARAM lParam
Definition: combotst.c:139
#define WIN_GetFullHandle(h)
Definition: user_x.h:108
#define WM_WDML_CONNECT_CONFIRM
Definition: dde_private.h:250
WDML_INSTANCE * WDML_GetInstanceFromWnd(HWND hWnd)
Definition: ddemisc.c:1261
#define XTYP_UNREGISTER
Definition: ddeml.h:193
#define WM_WDML_UNREGISTER
Definition: dde_private.h:249

Referenced by WDML_Initialize().

◆ WDML_FindConv()

WDML_CONV* WDML_FindConv ( WDML_INSTANCE pInstance,
WDML_SIDE  side,
HSZ  hszService,
HSZ  hszTopic 
)

Definition at line 2048 of file ddemisc.c.

2050 {
2051  WDML_CONV* pCurrent;
2052 
2053  for (pCurrent = pInstance->convs[side]; pCurrent != NULL; pCurrent = pCurrent->next)
2054  {
2055  if (DdeCmpStringHandles(pCurrent->hszService, hszService) == 0 &&
2056  DdeCmpStringHandles(pCurrent->hszTopic, hszTopic) == 0)
2057  {
2058  return pCurrent;
2059  }
2060 
2061  }
2062  return NULL;
2063 }
struct tagWDML_CONV * next
Definition: dde_private.h:126
WDML_CONV * convs[2]
Definition: dde_private.h:168
smooth NULL
Definition: ftsmooth.c:416
static HSZ hszTopic
Definition: shlexec.c:155
INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
Definition: ddemisc.c:685

Referenced by DdeConnect().

◆ WDML_FindLink()

WDML_LINK* WDML_FindLink ( WDML_INSTANCE pInstance,
HCONV  hConv,
WDML_SIDE  side,
HSZ  hszItem,
BOOL  use_fmt,
UINT  uFmt 
)

Definition at line 1868 of file ddemisc.c.

1870 {
1871  WDML_LINK* pCurrent;
1872 
1873  for (pCurrent = pInstance->links[side]; pCurrent != NULL; pCurrent = pCurrent->next)
1874  {
1875  /* we don't need to check for transaction type as it can be altered */
1876 
1877  if (pCurrent->hConv == hConv &&
1878  DdeCmpStringHandles(pCurrent->hszItem, hszItem) == 0 &&
1879  (!use_fmt || pCurrent->uFmt == uFmt))
1880  {
1881  break;
1882  }
1883 
1884  }
1885 
1886  return pCurrent;
1887 }
smooth NULL
Definition: ftsmooth.c:416
WDML_LINK * links[2]
Definition: dde_private.h:169
INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
Definition: ddemisc.c:685

Referenced by WDML_HandleAdviseReply(), WDML_HandleIncomingData(), WDML_ServerHandleAdvise(), and WDML_ServerHandleUnadvise().

◆ WDML_FindNode()

static HSZNode* WDML_FindNode ( WDML_INSTANCE pInstance,
HSZ  hsz 
)
static

Definition at line 305 of file ddemisc.c.

306 {
307  HSZNode* pNode;
308 
309  if (pInstance == NULL) return NULL;
310 
311  for (pNode = pInstance->nodeList; pNode != NULL; pNode = pNode->next)
312  {
313  if (pNode->hsz == hsz) break;
314  }
315  if (!pNode) WARN("HSZ %p not found\n", hsz);
316  return pNode;
317 }
struct tagHSZNode * next
Definition: dde_private.h:93
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
HSZNode * nodeList
Definition: dde_private.h:160

Referenced by WDML_IncHSZ().

◆ WDML_FindServer()

WDML_SERVER* WDML_FindServer ( WDML_INSTANCE pInstance,
HSZ  hszService,
HSZ  hszTopic 
)

Definition at line 1729 of file ddemisc.c.

1730 {
1731  WDML_SERVER* pServer;
1732 
1733  for (pServer = pInstance->servers; pServer != NULL; pServer = pServer->next)
1734  {
1735  if (hszService == pServer->hszService)
1736  {
1737  return pServer;
1738  }
1739  }
1740  TRACE("Service name missing\n");
1741  return NULL;
1742 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
WDML_SERVER * servers
Definition: dde_private.h:167
struct tagWDML_SERVER * next
Definition: dde_private.h:100

Referenced by DdeNameService().

◆ WDML_FindTransaction()

static WDML_XACT* WDML_FindTransaction ( WDML_CONV pConv,
DWORD  tid 
)
static

Definition at line 1984 of file ddemisc.c.

1985 {
1986  WDML_XACT* pXAct;
1987 
1988  tid = HIWORD(tid);
1989  for (pXAct = pConv->transactions; pXAct; pXAct = pXAct->next)
1990  {
1991  if (pXAct->xActID == tid)
1992  break;
1993  }
1994  return pXAct;
1995 }
WDML_XACT * transactions
Definition: dde_private.h:135
struct tagWDML_XACT * next
Definition: dde_private.h:110
#define HIWORD(l)
Definition: typedefs.h:246
static TfClientId tid

Referenced by DdeSetUserHandle(), and WDML_GetLocalConvInfo().

◆ WDML_FreeAllHSZ()

static void WDML_FreeAllHSZ ( WDML_INSTANCE pInstance)
static

Definition at line 419 of file ddemisc.c.

420 {
421  /* Free any strings created in this instance.
422  */
423  while (pInstance->nodeList != NULL)
424  {
425  DdeFreeStringHandle(pInstance->instanceID, pInstance->nodeList->hsz);
426  }
427 }
smooth NULL
Definition: ftsmooth.c:416
HSZNode * nodeList
Definition: dde_private.h:160
BOOL WINAPI DdeFreeStringHandle(DWORD idInst, HSZ hsz)
Definition: ddemisc.c:631

Referenced by DdeUninitialize().

◆ WDML_FreeTransaction()

void WDML_FreeTransaction ( WDML_INSTANCE pInstance,
WDML_XACT pXAct,
BOOL  doFreePmt 
)

Definition at line 1967 of file ddemisc.c.

1968 {
1969  /* free pmt(s) in pXAct too. check against one for not deleting TRUE return values */
1970  if (doFreePmt && (ULONG_PTR)pXAct->hMem > 1)
1971  {
1972  GlobalFree(pXAct->hMem);
1973  }
1974  if (pXAct->hszItem) WDML_DecHSZ(pInstance, pXAct->hszItem);
1975 
1976  HeapFree(GetProcessHeap(), 0, pXAct);
1977 }
HGLOBAL hMem
Definition: dde_private.h:120
uint32_t ULONG_PTR
Definition: typedefs.h:63
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
#define GetProcessHeap()
Definition: compat.h:395
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DdeAbandonTransaction(), DdeClientTransaction(), DdeDisconnect(), WDML_EnableCallback(), WDML_RemoveConv(), and WDML_ServerConvProc().

◆ WDML_GetConv()

WDML_CONV* WDML_GetConv ( HCONV  hConv,
BOOL  checkConnected 
)

Definition at line 2230 of file ddemisc.c.

2231 {
2232  WDML_CONV* pConv = (WDML_CONV*)hConv;
2233 
2234  /* FIXME: should do better checking */
2235  if (pConv == NULL || pConv->magic != WDML_CONV_MAGIC) return NULL;
2236 
2237  if (!pConv->instance)
2238  {
2239  WARN("wrong thread ID, no instance\n");
2240  return NULL;
2241  }
2242 
2243  if (pConv->instance->threadID != GetCurrentThreadId())
2244  {
2245  WARN("wrong thread ID\n");
2246  pConv->instance->lastError = DMLERR_INVALIDPARAMETER; /* FIXME: check */
2247  return NULL;
2248  }
2249 
2250  if (checkConnected && !(pConv->wStatus & ST_CONNECTED))
2251  {
2252  WARN("found conv but ain't connected\n");
2253  pConv->instance->lastError = DMLERR_NO_CONV_ESTABLISHED;
2254  return NULL;
2255  }
2256 
2257  return pConv;
2258 }
#define WARN(fmt,...)
Definition: debug.h:111
#define ST_CONNECTED
Definition: ddeml.h:80
#define WDML_CONV_MAGIC
Definition: dde_private.h:141
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
#define DMLERR_NO_CONV_ESTABLISHED
Definition: ddeml.h:256

Referenced by DdeAbandonTransaction(), DdeClientTransaction(), DdeDisconnect(), DdeEnableCallback(), DdeImpersonateClient(), DdePostAdvise(), DdeQueryConvInfo(), DdeReconnect(), DdeSetUserHandle(), and WDML_SyncWaitTransactionReply().

◆ WDML_GetConvFromWnd()

WDML_CONV* WDML_GetConvFromWnd ( HWND  hWnd)

Definition at line 2265 of file ddemisc.c.

2266 {
2268 }
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define GWL_WDML_CONVERSATION
Definition: dde_private.h:260

Referenced by DdeConnect(), DdeReconnect(), WDML_ClientProc(), and WDML_ServerConvProc().

◆ WDML_GetInstance()

WDML_INSTANCE* WDML_GetInstance ( DWORD  instId)

Definition at line 1230 of file ddemisc.c.

1231 {
1232  WDML_INSTANCE* pInstance;
1233 
1235 
1236  for (pInstance = WDML_InstanceList; pInstance != NULL; pInstance = pInstance->next)
1237  {
1238  if (pInstance->instanceID == instId)
1239  {
1240  if (GetCurrentThreadId() != pInstance->threadID)
1241  {
1242  FIXME("Tried to get instance from wrong thread\n");
1243  continue;
1244  }
1245  break;
1246  }
1247  }
1248 
1250 
1251  if (!pInstance)
1252  WARN("Instance entry missing for id %04x\n", instId);
1253  return pInstance;
1254 }
static CRITICAL_SECTION WDML_CritSect
Definition: ddemisc.c:41
static WDML_INSTANCE * WDML_InstanceList
Definition: ddemisc.c:36
#define WARN(fmt,...)
Definition: debug.h:111
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
struct tagWDML_INSTANCE * next
Definition: dde_private.h:154
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

Referenced by DdeAbandonTransaction(), DdeConnect(), DdeCreateDataHandle(), DdeCreateStringHandleA(), DdeCreateStringHandleW(), DdeEnableCallback(), DdeFreeStringHandle(), DdeGetLastError(), DdeKeepStringHandle(), DdeNameService(), DdePostAdvise(), DdeQueryStringA(), DdeQueryStringW(), and DdeUninitialize().

◆ WDML_GetInstanceFromWnd()

WDML_INSTANCE* WDML_GetInstanceFromWnd ( HWND  hWnd)

Definition at line 1261 of file ddemisc.c.

1262 {
1264 }
HWND hWnd
Definition: settings.c:17
#define GetWindowLongPtrW
Definition: winuser.h:4698
#define GWL_WDML_INSTANCE
Definition: dde_private.h:259

Referenced by WDML_AddConv(), WDML_ClientProc(), WDML_EventProc(), WDML_ServerConvProc(), and WDML_ServerNameProc().

◆ WDML_GetLocalConvInfo()

static BOOL WDML_GetLocalConvInfo ( WDML_CONV pConv,
CONVINFO ci,
DWORD  id 
)
static

Definition at line 2349 of file ddemisc.c.

2350 {
2351  BOOL ret = TRUE;
2352  WDML_LINK* pLink;
2353  WDML_SIDE side;
2354 
2355  ci->hConvPartner = (pConv->wStatus & ST_ISLOCAL) ? (HCONV)((ULONG_PTR)pConv | 1) : 0;
2356  ci->hszSvcPartner = pConv->hszService;
2357  ci->hszServiceReq = pConv->hszService; /* FIXME: they shouldn't be the same, should they ? */
2358  ci->hszTopic = pConv->hszTopic;
2359  ci->wStatus = pConv->wStatus;
2360 
2361  side = (pConv->wStatus & ST_CLIENT) ? WDML_CLIENT_SIDE : WDML_SERVER_SIDE;
2362 
2363  for (pLink = pConv->instance->links[side]; pLink != NULL; pLink = pLink->next)
2364  {
2365  if (pLink->hConv == (HCONV)pConv)
2366  {
2367  ci->wStatus |= ST_ADVISE;
2368  break;
2369  }
2370  }
2371 
2372  /* FIXME: non handled status flags:
2373  ST_BLOCKED
2374  ST_BLOCKNEXT
2375  ST_INLIST
2376  */
2377 
2378  ci->wConvst = pConv->wConvst; /* FIXME */
2379 
2380  ci->wLastError = 0; /* FIXME: note it's not the instance last error */
2381  ci->hConvList = 0;
2382  ci->ConvCtxt = pConv->convContext;
2383  if (ci->wStatus & ST_CLIENT)
2384  {
2385  ci->hwnd = pConv->hwndClient;
2386  ci->hwndPartner = pConv->hwndServer;
2387  }
2388  else
2389  {
2390  ci->hwnd = pConv->hwndServer;
2391  ci->hwndPartner = pConv->hwndClient;
2392  }
2393  if (id == QID_SYNC)
2394  {
2395  ci->hUser = pConv->hUser;
2396  ci->hszItem = 0;
2397  ci->wFmt = 0;
2398  ci->wType = 0;
2399  }
2400  else
2401  {
2402  WDML_XACT* pXAct;
2403 
2404  pXAct = WDML_FindTransaction(pConv, id);
2405  if (pXAct)
2406  {
2407  ci->hUser = pXAct->hUser;
2408  ci->hszItem = pXAct->hszItem;
2409  ci->wFmt = pXAct->wFmt;
2410  ci->wType = pXAct->wType;
2411  }
2412  else
2413  {
2414  ret = 0;
2415  pConv->instance->lastError = DMLERR_UNFOUND_QUEUE_ID;
2416  }
2417  }
2418  return ret;
2419 }
#define ST_ISLOCAL
Definition: ddeml.h:82
#define TRUE
Definition: types.h:120
#define ST_CLIENT
Definition: ddeml.h:84
static WDML_XACT * WDML_FindTransaction(WDML_CONV *pConv, DWORD tid)
Definition: ddemisc.c:1984
CONVCONTEXT ConvCtxt
Definition: ddeml.h:330
UINT wLastError
Definition: ddeml.h:328
HWND hwnd
Definition: ddeml.h:331
#define DMLERR_UNFOUND_QUEUE_ID
Definition: ddeml.h:263
HSZ hszServiceReq
Definition: ddeml.h:321
HSZ hszTopic
Definition: ddeml.h:322
unsigned int BOOL
Definition: ntddk_ex.h:94
HCONVLIST hConvList
Definition: ddeml.h:329
enum tagWDML_SIDE WDML_SIDE
smooth NULL
Definition: ftsmooth.c:416
UINT wConvst
Definition: ddeml.h:327
UINT wStatus
Definition: ddeml.h:326
HCONV hConvPartner
Definition: ddeml.h:319
CONVCONTEXT convContext
Definition: dde_private.h:132
int ret
HSZ hszItem
Definition: ddeml.h:323
#define ST_ADVISE
Definition: ddeml.h:81
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
DWORD hUser
Definition: ddeml.h:318
#define QID_SYNC
Definition: ddeml.h:40
UINT wType
Definition: ddeml.h:325
HWND hwndPartner
Definition: ddeml.h:332
HSZ hszSvcPartner
Definition: ddeml.h:320
#define ULONG_PTR
Definition: config.h:101
UINT wFmt
Definition: ddeml.h:324

Referenced by DdeQueryConvInfo().

◆ WDML_Global2DataHandle()

HDDEDATA WDML_Global2DataHandle ( WDML_CONV pConv,
HGLOBAL  hMem,
WINE_DDEHEAD p 
)

Definition at line 1504 of file ddemisc.c.

1505 {
1506  DDEDATA* pDd;
1507  HDDEDATA ret = 0;
1508  DWORD size;
1509 
1510  if (hMem)
1511  {
1512  pDd = GlobalLock(hMem);
1513  size = GlobalSize(hMem) - sizeof(WINE_DDEHEAD);
1514  if (pDd)
1515  {
1516  if (p) memcpy(p, pDd, sizeof(WINE_DDEHEAD));
1517  switch (pDd->cfFormat)
1518  {
1519  default:
1520  FIXME("Unsupported format (%04x) for data %p, passing raw information\n",
1521  pDd->cfFormat, hMem);
1522  /* fall through */
1523  case 0:
1524  case CF_TEXT:
1525  ret = DdeCreateDataHandle(pConv->instance->instanceID, pDd->Value, size, 0, 0, pDd->cfFormat, 0);
1526  break;
1527  case CF_BITMAP:
1528  if (size >= sizeof(BITMAP))
1529  {
1530  BITMAP* bmp = (BITMAP*)pDd->Value;
1531  int count = bmp->bmWidthBytes * bmp->bmHeight * bmp->bmPlanes;
1532  if (size >= sizeof(BITMAP) + count)
1533  {
1534  HBITMAP hbmp;
1535 
1536  if ((hbmp = CreateBitmap(bmp->bmWidth, bmp->bmHeight,
1537  bmp->bmPlanes, bmp->bmBitsPixel,
1538  pDd->Value + sizeof(BITMAP))))
1539  {
1540  ret = DdeCreateDataHandle(pConv->instance->instanceID, (LPBYTE)&hbmp, sizeof(hbmp),
1541  0, 0, CF_BITMAP, 0);
1542  }
1543  else ERR("Can't create bmp\n");
1544  }
1545  else
1546  {
1547  ERR("Wrong count: %u / %d\n", size, count);
1548  }
1549  } else ERR("No bitmap header\n");
1550  break;
1551  }
1552  GlobalUnlock(hMem);
1553  }
1554  }
1555  return ret;
1556 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
short cfFormat
Definition: dde.h:59
SIZE_T NTAPI GlobalSize(HGLOBAL hMem)
Definition: heapmem.c:1090
unsigned char * LPBYTE
Definition: typedefs.h:52
#define FIXME(fmt,...)
Definition: debug.h:110
#define CF_BITMAP
Definition: constants.h:397
#define CF_TEXT
Definition: constants.h:396
Definition: dde.h:56
HBITMAP hbmp
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
unsigned long DWORD
Definition: ntddk_ex.h:95
BITMAP bmp
Definition: alphablend.c:62
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:109
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
Definition: bl.h:1331
HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff, HSZ hszItem, UINT wFmt, UINT afCmd)
Definition: ddemisc.c:1275
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static HBITMAP
Definition: button.c:44
GLfloat GLfloat p
Definition: glext.h:8902
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)
BYTE Value[1]
Definition: dde.h:60

Referenced by WDML_HandleIncomingData(), and WDML_HandleRequestReply().

◆ WDML_IncHSZ()

BOOL WDML_IncHSZ ( WDML_INSTANCE pInstance,
HSZ  hsz 
)

Definition at line 362 of file ddemisc.c.

363 {
364  HSZNode* pNode;
365 
366  pNode = WDML_FindNode(pInstance, hsz);
367  if (!pNode) return FALSE;
368 
369  pNode->refCount++;
370  return TRUE;
371 }
#define TRUE
Definition: types.h:120
unsigned refCount
Definition: dde_private.h:95
static HSZNode * WDML_FindNode(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:305

Referenced by DdeKeepStringHandle(), DdeNameService(), WDML_AddConv(), WDML_AddLink(), WDML_AddServer(), and WDML_AllocTransaction().

◆ WDML_IncrementInstanceId()

static void WDML_IncrementInstanceId ( WDML_INSTANCE pInstance)
static

Definition at line 746 of file ddemisc.c.

747 {
749 
750  pInstance->instanceID = id;
751  TRACE("New instance id %d allocated\n", id);
752 }
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
static LONG WDML_MaxInstanceID
Definition: ddemisc.c:37
#define InterlockedIncrement
Definition: armddk.h:53
GLenum GLuint id
Definition: glext.h:5579

Referenced by WDML_Initialize().

◆ WDML_Initialize()

static UINT WDML_Initialize ( LPDWORD  pidInst,
PFNCALLBACK  pfnCallback,
DWORD  afCmd,
DWORD  ulRes,
BOOL  bUnicode 
)
static

Definition at line 827 of file ddemisc.c.

829 {
830  WDML_INSTANCE* pInstance;
831  WDML_INSTANCE* reference_inst;
832  UINT ret;
833  WNDCLASSEXW wndclass;
834 
835  TRACE("(%p,%p,0x%x,%d,0x%x)\n",
836  pidInst, pfnCallback, afCmd, ulRes, bUnicode);
837 
838  if (ulRes)
839  {
840  ERR("Reserved value not zero? What does this mean?\n");
841  /* trap this and no more until we know more */
842  return DMLERR_NO_ERROR;
843  }
844 
845  /* grab enough heap for one control struct - not really necessary for re-initialise
846  * but allows us to use same validation routines */
847  pInstance = HeapAlloc(GetProcessHeap(), 0, sizeof(WDML_INSTANCE));
848  if (pInstance == NULL)
849  {
850  /* catastrophe !! warn user & abort */
851  ERR("Instance create failed - out of memory\n");
852  return DMLERR_SYS_ERROR;
853  }
854  pInstance->next = NULL;
855  pInstance->monitor = (afCmd | APPCLASS_MONITOR);
856 
857  /* messy bit, spec implies that 'Client Only' can be set in 2 different ways, catch 1 here */
858 
859  pInstance->clientOnly = afCmd & APPCMD_CLIENTONLY;
860  pInstance->instanceID = *pidInst; /* May need to add calling proc Id */
861  pInstance->threadID = GetCurrentThreadId();
862  pInstance->callback = *pfnCallback;
863  pInstance->unicode = bUnicode;
864  pInstance->nodeList = NULL; /* node will be added later */
865  pInstance->monitorFlags = afCmd & MF_MASK;
866  pInstance->wStatus = 0;
867  pInstance->lastError = DMLERR_NO_ERROR;
868  pInstance->servers = NULL;
869  pInstance->convs[0] = NULL;
870  pInstance->convs[1] = NULL;
871  pInstance->links[0] = NULL;
872  pInstance->links[1] = NULL;
873 
874  /* isolate CBF flags in one go, expect this will go the way of all attempts to be clever !! */
875 
876  pInstance->CBFflags = afCmd^((afCmd&MF_MASK)|((afCmd&APPCMD_MASK)|(afCmd&APPCLASS_MASK)));
877 
878  if (!pInstance->clientOnly)
879  {
880  /* Check for other way of setting Client-only !! */
881  pInstance->clientOnly =
883  }
884 
885  TRACE("instance created - checking validity\n");
886 
887  if (*pidInst == 0)
888  {
889  /* Initialisation of new Instance Identifier */
890  TRACE("new instance, callback %p flags %X\n",pfnCallback,afCmd);
891 
893 
894  if (WDML_InstanceList == NULL)
895  {
896  /* can't be another instance in this case, assign to the base pointer */
897  WDML_InstanceList = pInstance;
898 
899  /* since first must force filter of XTYP_CONNECT and XTYP_WILDCONNECT for
900  * present
901  * ------------------------------- NOTE NOTE NOTE --------------------------
902  *
903  * the manual is not clear if this condition
904  * applies to the first call to DdeInitialize from an application, or the
905  * first call for a given callback !!!
906  */
907 
908  pInstance->CBFflags = pInstance->CBFflags|APPCMD_FILTERINITS;
909  TRACE("First application instance detected OK\n");
910  /* allocate new instance ID */
911  WDML_IncrementInstanceId(pInstance);
912  }
913  else
914  {
915  /* really need to chain the new one in to the latest here, but after checking conditions
916  * such as trying to start a conversation from an application trying to monitor */
917  reference_inst = WDML_InstanceList;
918  TRACE("Subsequent application instance - starting checks\n");
919  while (reference_inst->next != NULL)
920  {
921  /*
922  * This set of tests will work if application uses same instance Id
923  * at application level once allocated - which is what manual implies
924  * should happen. If someone tries to be
925  * clever (lazy ?) it will fail to pick up that later calls are for
926  * the same application - should we trust them ?
927  */
928  if (pInstance->instanceID == reference_inst->instanceID)
929  {
930  /* Check 1 - must be same Client-only state */
931 
932  if (pInstance->clientOnly != reference_inst->clientOnly)
933  {
935  goto theError;
936  }
937 
938  /* Check 2 - cannot use 'Monitor' with any non-monitor modes */
939 
940  if (pInstance->monitor != reference_inst->monitor)
941  {
943  goto theError;
944  }
945 
946  /* Check 3 - must supply different callback address */
947 
948  if (pInstance->callback == reference_inst->callback)
949  {
951  goto theError;
952  }
953  }
954  reference_inst = reference_inst->next;
955  }
956  /* All cleared, add to chain */
957 
958  TRACE("Application Instance checks finished\n");
959  WDML_IncrementInstanceId(pInstance);
960  reference_inst->next = pInstance;
961  }
963 
964  *pidInst = pInstance->instanceID;
965 
966  /* for deadlock issues, windows must always be created when outside the critical section */
967  wndclass.cbSize = sizeof(wndclass);
968  wndclass.style = 0;
969  wndclass.lpfnWndProc = WDML_EventProc;
970  wndclass.cbClsExtra = 0;
971  wndclass.cbWndExtra = sizeof(ULONG_PTR);
972  wndclass.hInstance = 0;
973  wndclass.hIcon = 0;
974  wndclass.hCursor = 0;
975  wndclass.hbrBackground = 0;
976  wndclass.lpszMenuName = NULL;
977  wndclass.lpszClassName = WDML_szEventClass;
978  wndclass.hIconSm = 0;
979 
980  RegisterClassExW(&wndclass);
981 
983  WS_POPUP, 0, 0, 0, 0,
984  0, 0, 0, 0);
985 
986  SetWindowLongPtrW(pInstance->hwndEvent, GWL_WDML_INSTANCE, (ULONG_PTR)pInstance);
987 
988  TRACE("New application instance processing finished OK\n");
989  }
990  else
991  {
992  /* Reinitialisation situation --- FIX */
993  TRACE("reinitialisation of (%p,%p,0x%x,%d): stub\n", pidInst, pfnCallback, afCmd, ulRes);
994 
996 
997  if (WDML_InstanceList == NULL)
998  {
1000  goto theError;
1001  }
1002  /* can't reinitialise if we have initialised nothing !! */
1003  reference_inst = WDML_InstanceList;
1004  /* must first check if we have been given a valid instance to re-initialise !! how do we do that ? */
1005  /*
1006  * MS allows initialisation without specifying a callback, should we allow addition of the
1007  * callback by a later call to initialise ? - if so this lot will have to change
1008  */
1009  while (reference_inst->next != NULL)
1010  {
1011  if (*pidInst == reference_inst->instanceID && pfnCallback == reference_inst->callback)
1012  {
1013  /* Check 1 - cannot change client-only mode if set via APPCMD_CLIENTONLY */
1014 
1015  if (reference_inst->clientOnly)
1016  {
1017  if ((reference_inst->CBFflags & CBF_FAIL_ALLSVRXACTIONS) != CBF_FAIL_ALLSVRXACTIONS)
1018  {
1019  /* i.e. Was set to Client-only and through APPCMD_CLIENTONLY */
1020 
1021  if (!(afCmd & APPCMD_CLIENTONLY))
1022  {
1024  goto theError;
1025  }
1026  }
1027  }
1028  /* Check 2 - cannot change monitor modes */
1029 
1030  if (pInstance->monitor != reference_inst->monitor)
1031  {
1033  goto theError;
1034  }
1035 
1036  /* Check 3 - trying to set Client-only via APPCMD when not set so previously */
1037 
1038  if ((afCmd&APPCMD_CLIENTONLY) && !reference_inst->clientOnly)
1039  {
1041  goto theError;
1042  }
1043  break;
1044  }
1045  reference_inst = reference_inst->next;
1046  }
1047  if (reference_inst->next == NULL)
1048  {
1050  goto theError;
1051  }
1052  /* All checked - change relevant flags */
1053 
1054  reference_inst->CBFflags = pInstance->CBFflags;
1055  reference_inst->clientOnly = pInstance->clientOnly;
1056  reference_inst->monitorFlags = pInstance->monitorFlags;
1057 
1058  HeapFree(GetProcessHeap(), 0, pInstance); /* finished - release heap space used as work store */
1059 
1061  }
1062 
1063  return DMLERR_NO_ERROR;
1064  theError:
1065  HeapFree(GetProcessHeap(), 0, pInstance);
1067  return ret;
1068 }
#define APPCLASS_MONITOR
Definition: ddeml.h:131
static CRITICAL_SECTION WDML_CritSect
Definition: ddemisc.c:41
int cbWndExtra
Definition: winuser.h:3173
static WDML_INSTANCE * WDML_InstanceList
Definition: ddemisc.c:36
HICON hIcon
Definition: winuser.h:3175
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
#define APPCLASS_MASK
Definition: ddeml.h:132
#define CreateWindowW(a, b, c, d, e, f, g, h, i, j, k)
Definition: winuser.h:4185
static LRESULT CALLBACK WDML_EventProc(HWND hwndEvent, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ddemisc.c:759
#define MF_MASK
Definition: ddeml.h:146
WDML_CONV * convs[2]
Definition: dde_private.h:168
uint32_t ULONG_PTR
Definition: typedefs.h:63
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
LPCWSTR lpszMenuName
Definition: winuser.h:3178
#define DMLERR_NO_ERROR
Definition: ddeml.h:242
smooth NULL
Definition: ftsmooth.c:416
HSZNode * nodeList
Definition: dde_private.h:160
#define APPCMD_FILTERINITS
Definition: ddeml.h:123
int cbClsExtra
Definition: winuser.h:3172
#define DMLERR_SYS_ERROR
Definition: ddeml.h:261
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
LPCWSTR lpszClassName
Definition: winuser.h:3179
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define APPCMD_CLIENTONLY
Definition: ddeml.h:122
HBRUSH hbrBackground
Definition: winuser.h:3177
UINT cbSize
Definition: winuser.h:3169
HINSTANCE hInstance
Definition: winuser.h:3174
#define GWL_WDML_INSTANCE
Definition: dde_private.h:259
int ret
HCURSOR hCursor
Definition: winuser.h:3176
#define DMLERR_DLL_USAGE
Definition: ddeml.h:250
UINT style
Definition: winuser.h:3170
WDML_LINK * links[2]
Definition: dde_private.h:169
WNDPROC lpfnWndProc
Definition: winuser.h:3171
const WCHAR WDML_szEventClass[]
Definition: ddemisc.c:38
#define ERR(fmt,...)
Definition: debug.h:109
#define CBF_FAIL_ALLSVRXACTIONS
Definition: ddeml.h:109
#define DMLERR_INVALIDPARAMETER
Definition: ddeml.h:252
#define WS_POPUP
Definition: pedump.c:616
unsigned int UINT
Definition: ndis.h:50
PFNCALLBACK callback
Definition: dde_private.h:161
HICON hIconSm
Definition: winuser.h:3180
struct tagWDML_INSTANCE * next
Definition: dde_private.h:154
#define ULONG_PTR
Definition: config.h:101
#define SetWindowLongPtrW
Definition: winuser.h:5215
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
WDML_SERVER * servers
Definition: dde_private.h:167
#define HeapFree(x, y, z)
Definition: compat.h:394
#define APPCMD_MASK
Definition: ddeml.h:124
static void WDML_IncrementInstanceId(WDML_INSTANCE *pInstance)
Definition: ddemisc.c:746

Referenced by DdeInitializeA(), and DdeInitializeW().

◆ WDML_InsertHSZNode()

static void WDML_InsertHSZNode ( WDML_INSTANCE pInstance,
HSZ  hsz 
)
static

Definition at line 434 of file ddemisc.c.

435 {
436  if (hsz != 0)
437  {
438  HSZNode* pNew = NULL;
439  /* Create a new node for this HSZ.
440  */
441  pNew = HeapAlloc(GetProcessHeap(), 0, sizeof(HSZNode));
442  if (pNew != NULL)
443  {
444  pNew->hsz = hsz;
445  pNew->next = pInstance->nodeList;
446  pNew->refCount = 1;
447  pInstance->nodeList = pNew;
448  }
449  else
450  {
451  ERR("Primary HSZ Node allocation failed - out of memory\n");
452  }
453  }
454 }
struct tagHSZNode * next
Definition: dde_private.h:93
smooth NULL
Definition: ftsmooth.c:416
HSZNode * nodeList
Definition: dde_private.h:160
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ERR(fmt,...)
Definition: debug.h:109
unsigned refCount
Definition: dde_private.h:95

Referenced by WDML_CreateString().

◆ WDML_InvokeCallback()

HDDEDATA WDML_InvokeCallback ( WDML_INSTANCE pInstance,
UINT  uType,
UINT  uFmt,
HCONV  hConv,
HSZ  hsz1,
HSZ  hsz2,
HDDEDATA  hdata,
ULONG_PTR  dwData1,
ULONG_PTR  dwData2 
)

Definition at line 1206 of file ddemisc.c.

1209 {
1210  HDDEDATA ret;
1211 
1212  if (pInstance == NULL)
1213  return NULL;
1214 
1215  TRACE("invoking CB[%p] (%x %x %p %p %p %p %lx %lx)\n",
1216  pInstance->callback, uType, uFmt,
1217  hConv, hsz1, hsz2, hdata, dwData1, dwData2);
1218  ret = pInstance->callback(uType, uFmt, hConv, hsz1, hsz2, hdata, dwData1, dwData2);
1219  TRACE("done => %p\n", ret);
1220  return ret;
1221 }
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
int ret
PFNCALLBACK callback
Definition: dde_private.h:161

Referenced by DdePostAdvise(), WDML_EventProc(), WDML_HandleIncomingData(), WDML_HandleReply(), WDML_HandleTerminateReply(), WDML_ServerHandleAdvise(), WDML_ServerHandleExecute(), WDML_ServerHandlePoke(), WDML_ServerHandleRequest(), WDML_ServerHandleTerminate(), WDML_ServerHandleUnadvise(), and WDML_ServerNameProc().

◆ WDML_IsAppOwned()

BOOL WDML_IsAppOwned ( HDDEDATA  hData)

Definition at line 1477 of file ddemisc.c.

1478 {
1479  DDE_DATAHANDLE_HEAD* pDdh;
1480  BOOL ret = FALSE;
1481 
1482  pDdh = GlobalLock(hData);
1483  if (pDdh != NULL)
1484  {
1485  ret = pDdh->bAppOwned;
1486  GlobalUnlock(hData);
1487  }
1488  return ret;
1489 }
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190

Referenced by DdePostAdvise(), and WDML_ServerNameProc().

◆ WDML_MakeAtomFromHsz()

ATOM WDML_MakeAtomFromHsz ( HSZ  hsz)

Definition at line 325 of file ddemisc.c.

326 {
327  WCHAR nameBuffer[MAX_BUFFER_LEN];
328 
329  if (GetAtomNameW(HSZ2ATOM(hsz), nameBuffer, MAX_BUFFER_LEN))
330  return GlobalAddAtomW(nameBuffer);
331  WARN("HSZ %p not found\n", hsz);
332  return 0;
333 }
#define HSZ2ATOM(hsz)
Definition: ddemisc.c:34
#define WARN(fmt,...)
Definition: debug.h:111
UINT WINAPI GetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:589
#define MAX_BUFFER_LEN
Definition: dde_private.h:34
__wchar_t WCHAR
Definition: xmlstorage.h:180
ATOM WINAPI GlobalAddAtomW(LPCWSTR lpString)
Definition: atom.c:444

Referenced by DdeConnect(), DdePostAdvise(), DdeReconnect(), WDML_AddServer(), WDML_ClientQueueAdvise(), WDML_ClientQueuePoke(), WDML_ClientQueueRequest(), WDML_ClientQueueUnadvise(), and WDML_CreateServerConv().

◆ WDML_MakeHszFromAtom()

HSZ WDML_MakeHszFromAtom ( const WDML_INSTANCE pInstance,
ATOM  atom 
)

Definition at line 342 of file ddemisc.c.

343 {
344  WCHAR nameBuffer[MAX_BUFFER_LEN];
345 
346  if (!atom) return NULL;
347 
348  if (GlobalGetAtomNameW(atom, nameBuffer, MAX_BUFFER_LEN))
349  {
350  TRACE("%x => %s\n", atom, debugstr_w(nameBuffer));
351  return DdeCreateStringHandleW(pInstance->instanceID, nameBuffer, CP_WINUNICODE);
352  }
353  WARN("ATOM 0x%x not found\n", atom);
354  return 0;
355 }
#define WARN(fmt,...)
Definition: debug.h:111
#define MAX_BUFFER_LEN
Definition: dde_private.h:34
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GlobalGetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:496
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_WINUNICODE
Definition: ddeml.h:33
HSZ WINAPI DdeCreateStringHandleW(DWORD idInst, LPCWSTR psz, INT codepage)
Definition: ddemisc.c:608

Referenced by WDML_ClientProc(), WDML_EventProc(), WDML_HandleAdviseReply(), WDML_HandleIncomingData(), WDML_HandlePokeReply(), WDML_HandleRequestReply(), WDML_HandleUnadviseReply(), WDML_ServerNameProc(), WDML_ServerQueueAdvise(), WDML_ServerQueuePoke(), WDML_ServerQueueRequest(), and WDML_ServerQueueUnadvise().

◆ WDML_NotifyThreadDetach()

void WDML_NotifyThreadDetach ( void  )

Definition at line 1181 of file ddemisc.c.

1182 {
1183  WDML_INSTANCE* pInstance;
1186 
1188  for (pInstance = WDML_InstanceList; pInstance != NULL; pInstance = next)
1189  {
1190  next = pInstance->next;
1191  if (pInstance->threadID == tid)
1192  {
1194  DdeUninitialize(pInstance->instanceID);
1196  }
1197  }
1199 }
static CRITICAL_SECTION WDML_CritSect
Definition: ddemisc.c:41
static WDML_INSTANCE * WDML_InstanceList
Definition: ddemisc.c:36
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
BOOL WINAPI DdeUninitialize(DWORD idInst)
Definition: ddemisc.c:1112
smooth NULL
Definition: ftsmooth.c:416
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
unsigned long DWORD
Definition: ntddk_ex.h:95
static unsigned __int64 next
Definition: rand_nt.c:6
struct tagWDML_INSTANCE * next
Definition: dde_private.h:154
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
static TfClientId tid

◆ WDML_PostAck()

BOOL WDML_PostAck ( WDML_CONV pConv,
WDML_SIDE  side,
WORD  appRetCode,
BOOL  fBusy,
BOOL  fAck,
UINT_PTR  pmt,
LPARAM  lParam,
UINT  oldMsg 
)

Definition at line 2275 of file ddemisc.c.

2277 {
2278  DDEACK ddeAck;
2279  HWND from, to;
2280 
2281  if (side == WDML_SERVER_SIDE)
2282  {
2283  from = pConv->hwndServer;
2284  to = pConv->hwndClient;
2285  }
2286  else
2287  {
2288  to = pConv->hwndServer;
2289  from = pConv->hwndClient;
2290  }
2291 
2292  ddeAck.bAppReturnCode = appRetCode;
2293  ddeAck.reserved = 0;
2294  ddeAck.fBusy = fBusy;
2295  ddeAck.fAck = fAck;
2296 
2297  TRACE("Posting a %s ack\n", ddeAck.fAck ? "positive" : "negative");
2298 
2299  lParam = (lParam) ? ReuseDDElParam(lParam, oldMsg, WM_DDE_ACK, *(WORD*)&ddeAck, pmt) :
2300  PackDDElParam(WM_DDE_ACK, *(WORD*)&ddeAck, pmt);
2301  if (!PostMessageW(to, WM_DDE_ACK, (WPARAM)from, lParam))
2302  {
2303  pConv->wStatus &= ~ST_CONNECTED;
2304  pConv->instance->lastError = DMLERR_POSTMSG_FAILED;
2306  return FALSE;
2307  }
2308  return TRUE;
2309 }
#define TRUE
Definition: types.h:120
unsigned short bAppReturnCode
Definition: dde.h:52
#define ST_CONNECTED
Definition: ddeml.h:80
UINT_PTR WPARAM
Definition: windef.h:207
#define DMLERR_POSTMSG_FAILED
Definition: ddeml.h:258
LPARAM WINAPI ReuseDDElParam(LPARAM lParam, UINT msgIn, UINT msgOut, UINT_PTR uiLo, UINT_PTR uiHi)
Definition: ddemisc.c:171
Definition: dde.h:50
unsigned short fAck
Definition: dde.h:52
unsigned short reserved
Definition: dde.h:52
#define TRACE(s)
Definition: solgame.cpp:4
unsigned short WORD
Definition: ntddk_ex.h:93
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
unsigned short fBusy
Definition: dde.h:52
BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam)
Definition: ddemisc.c:147
LPARAM WINAPI PackDDElParam(UINT msg, UINT_PTR uiLo, UINT_PTR uiHi)
Definition: ddemisc.c:63
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WM_DDE_ACK
Definition: dde.h:41
CardRegion * from
Definition: spigame.cpp:19
LPARAM lParam
Definition: combotst.c:139

Referenced by WDML_HandleIncomingData(), WDML_ServerHandleAdvise(), WDML_ServerHandleExecute(), WDML_ServerHandlePoke(), WDML_ServerHandleRequest(), and WDML_ServerHandleUnadvise().

◆ WDML_QueryString()

static int WDML_QueryString ( WDML_INSTANCE pInstance,
HSZ  hsz,
LPVOID  ptr,
DWORD  cchMax,
int  codepage 
)
static

Definition at line 461 of file ddemisc.c.

463 {
464  WCHAR pString[MAX_BUFFER_LEN];
465  int ret;
466  /* If psz is null, we have to return only the length
467  * of the string.
468  */
469  if (ptr == NULL)
470  {
471  ptr = pString;
473  }
474 
475  /* if there is no input windows returns a NULL string */
476  if (hsz == NULL)
477  {
478  CHAR *t_ptr = ptr;
479  *t_ptr = '\0';
480  return 1;
481  }
482 
483  switch (codepage)
484  {
485  case CP_WINANSI:
486  ret = GetAtomNameA(HSZ2ATOM(hsz), ptr, cchMax);
487  break;
488  case CP_WINUNICODE:
489  ret = GetAtomNameW(HSZ2ATOM(hsz), ptr, cchMax);
490  break;
491  default:
492  ERR("Unknown code page %d\n", codepage);
493  ret = 0;
494  }
495  return ret;
496 }
UINT WINAPI GetAtomNameA(ATOM nAtom, LPSTR lpBuffer, int nSize)
Definition: atom.c:577
#define HSZ2ATOM(hsz)
Definition: ddemisc.c:34
char CHAR
Definition: xmlstorage.h:175
UINT WINAPI GetAtomNameW(ATOM nAtom, LPWSTR lpBuffer, int nSize)
Definition: atom.c:589
#define MAX_BUFFER_LEN
Definition: dde_private.h:34
static PVOID ptr
Definition: dispmode.c:27
int codepage
Definition: win_iconv.c:156
smooth NULL
Definition: ftsmooth.c:416
__wchar_t WCHAR
Definition: xmlstorage.h:180
UINT cchMax
int ret
#define ERR(fmt,...)
Definition: debug.h:109
#define CP_WINANSI
Definition: ddeml.h:32
#define CP_WINUNICODE
Definition: ddeml.h:33

Referenced by DdeQueryStringA(), and DdeQueryStringW().

◆ WDML_QueueTransaction()

void WDML_QueueTransaction ( WDML_CONV pConv,
WDML_XACT pXAct 
)

Definition at line 1933 of file ddemisc.c.

1934 {
1935  WDML_XACT** pt;
1936 
1937  /* advance to last in queue */
1938  for (pt = &pConv->transactions; *pt != NULL; pt = &(*pt)->next);
1939  *pt = pXAct;
1940 }
#define pt(x, y)
Definition: drawing.c:79
WDML_XACT * transactions
Definition: dde_private.h:135
smooth NULL
Definition: ftsmooth.c:416
struct define * next
Definition: wpp.c:35

Referenced by DdeClientTransaction(), and WDML_ServerConvProc().

◆ WDML_RemoveAllLinks()

static void WDML_RemoveAllLinks ( WDML_INSTANCE pInstance,
WDML_CONV pConv,
WDML_SIDE  side 
)
static

Definition at line 1822 of file ddemisc.c.

1823 {
1824  WDML_LINK* pPrev = NULL;
1825  WDML_LINK* pCurrent = NULL;
1826  WDML_LINK* pNext = NULL;
1827 
1828  pCurrent = pInstance->links[side];
1829 
1830  while (pCurrent != NULL)
1831  {
1832  if (pCurrent->hConv == (HCONV)pConv)
1833  {
1834  if (pCurrent == pInstance->links[side])
1835  {
1836  pInstance->links[side] = pCurrent->next;
1837  pNext = pCurrent->next;
1838  }
1839  else
1840  {
1841  pPrev->next = pCurrent->next;
1842  pNext = pCurrent->next;
1843  }
1844 
1845  WDML_DecHSZ(pInstance, pCurrent->hszItem);
1846 
1847  HeapFree(GetProcessHeap(), 0, pCurrent);
1848  pCurrent = NULL;
1849  }
1850 
1851  if (pCurrent)
1852  {
1853  pPrev = pCurrent;
1854  pCurrent = pCurrent->next;
1855  }
1856  else
1857  {
1858  pCurrent = pNext;
1859  }
1860  }
1861 }
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
WDML_LINK * links[2]
Definition: dde_private.h:169
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by WDML_RemoveConv().

◆ WDML_RemoveConv()

void WDML_RemoveConv ( WDML_CONV pRef,
WDML_SIDE  side 
)

Definition at line 2070 of file ddemisc.c.

2071 {
2072  WDML_CONV* pPrev = NULL;
2073  WDML_CONV* pCurrent;
2074  WDML_XACT* pXAct;
2075  WDML_XACT* pXActNext;
2076  HWND hWnd;
2077 
2078  if (!pRef)
2079  return;
2080 
2081  /* remove any pending transaction */
2082  for (pXAct = pRef->transactions; pXAct != NULL; pXAct = pXActNext)
2083  {
2084  pXActNext = pXAct->next;
2085  WDML_FreeTransaction(pRef->instance, pXAct, TRUE);
2086  }
2087 
2088  WDML_RemoveAllLinks(pRef->instance, pRef, side);
2089 
2090  /* FIXME: should we keep the window around ? it seems so (at least on client side
2091  * to let QueryConvInfo work after conv termination, but also to implement
2092  * DdeReconnect...
2093  */
2094  /* destroy conversation window, but first remove pConv from hWnd.
2095  * this would help the wndProc do appropriate handling upon a WM_DESTROY message
2096  */
2097  hWnd = (side == WDML_CLIENT_SIDE) ? pRef->hwndClient : pRef->hwndServer;
2099 
2100  DestroyWindow((side == WDML_CLIENT_SIDE) ? pRef->hwndClient : pRef->hwndServer);
2101 
2102  WDML_DecHSZ(pRef->instance, pRef->hszService);
2103  WDML_DecHSZ(pRef->instance, pRef->hszTopic);
2104 
2105  for (pCurrent = pRef->instance->convs[side]; pCurrent != NULL; pCurrent = (pPrev = pCurrent)->next)
2106  {
2107  if (pCurrent == pRef)
2108  {
2109  if (pCurrent == pRef->instance->convs[side])
2110  {
2111  pRef->instance->convs[side] = pCurrent->next;
2112  }
2113  else
2114  {
2115  pPrev->next = pCurrent->next;
2116  }
2117  pCurrent->magic = 0;
2118  HeapFree(GetProcessHeap(), 0, pCurrent);
2119  break;
2120  }
2121  }
2122 }
#define TRUE
Definition: types.h:120
struct tagWDML_CONV * next
Definition: dde_private.h:126
WDML_XACT * transactions
Definition: dde_private.h:135
HWND hWnd
Definition: settings.c:17
BOOL WINAPI DestroyWindow(_In_ HWND)
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
struct tagWDML_XACT * next
Definition: dde_private.h:110
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
#define GWL_WDML_CONVERSATION
Definition: dde_private.h:260
struct tagWDML_INSTANCE * instance
Definition: dde_private.h:127
void WDML_FreeTransaction(WDML_INSTANCE *pInstance, WDML_XACT *pXAct, BOOL doFreePmt)
Definition: ddemisc.c:1967
#define SetWindowLongPtrW
Definition: winuser.h:5215
static void WDML_RemoveAllLinks(WDML_INSTANCE *pInstance, WDML_CONV *pConv, WDML_SIDE side)
Definition: ddemisc.c:1822
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by DdeDisconnect(), WDML_HandleTerminateReply(), WDML_RemoveServer(), and WDML_ServerHandleTerminate().

◆ WDML_RemoveLink()

void WDML_RemoveLink ( WDML_INSTANCE pInstance,
HCONV  hConv,
WDML_SIDE  side,
HSZ  hszItem,
UINT  uFmt 
)

Definition at line 1780 of file ddemisc.c.

1782 {
1783  WDML_LINK* pPrev = NULL;
1784  WDML_LINK* pCurrent = NULL;
1785 
1786  pCurrent = pInstance->links[side];
1787 
1788  while (pCurrent != NULL)
1789  {
1790  if (pCurrent->hConv == hConv &&
1791  DdeCmpStringHandles(pCurrent->hszItem, hszItem) == 0 &&
1792  pCurrent->uFmt == uFmt)
1793  {
1794  if (pCurrent == pInstance->links[side])
1795  {
1796  pInstance->links[side] = pCurrent->next;
1797  }
1798  else
1799  {
1800  pPrev->next = pCurrent->next;
1801  }
1802 
1803  WDML_DecHSZ(pInstance, pCurrent->hszItem);
1804  HeapFree(GetProcessHeap(), 0, pCurrent);
1805  break;
1806  }
1807 
1808  pPrev = pCurrent;
1809  pCurrent = pCurrent->next;
1810  }
1811 }
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
WDML_LINK * links[2]
Definition: dde_private.h:169
INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
Definition: ddemisc.c:685
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by WDML_HandleUnadviseReply(), and WDML_ServerHandleUnadvise().

◆ WDML_RemoveServer()

void WDML_RemoveServer ( WDML_INSTANCE pInstance,
HSZ  hszService,
HSZ  hszTopic 
)

Definition at line 1670 of file ddemisc.c.

1671 {
1672  WDML_SERVER* pPrev = NULL;
1673  WDML_SERVER* pServer = NULL;
1674  WDML_CONV* pConv;
1675  WDML_CONV* pConvNext;
1676 
1677  pServer = pInstance->servers;
1678 
1679  while (pServer != NULL)
1680  {
1681  if (DdeCmpStringHandles(pServer->hszService, hszService) == 0)
1682  {
1684  pServer->atomService, pServer->atomServiceSpec);
1685  /* terminate all conversations for given topic */
1686  for (pConv = pInstance->convs[WDML_SERVER_SIDE]; pConv != NULL; pConv = pConvNext)
1687  {
1688  pConvNext = pConv->next;
1689  if (DdeCmpStringHandles(pConv->hszService, hszService) == 0)
1690  {
1691  HWND client = pConv->hwndClient, server = pConv->hwndServer;
1693  /* don't care about return code (whether client window is present or not) */
1695  }
1696  }
1697  if (pServer == pInstance->servers)
1698  {
1699  pInstance->servers = pServer->next;
1700  }
1701  else
1702  {
1703  pPrev->next = pServer->next;
1704  }
1705 
1706  DestroyWindow(pServer->hwndServer);
1707  WDML_DecHSZ(pInstance, pServer->hszServiceSpec);
1708  WDML_DecHSZ(pInstance, pServer->hszService);
1709 
1710  GlobalDeleteAtom(pServer->atomService);
1712 
1713  HeapFree(GetProcessHeap(), 0, pServer);
1714  break;
1715  }
1716 
1717  pPrev = pServer;
1718  pServer = pServer->next;
1719  }
1720 }
ATOM WINAPI GlobalDeleteAtom(ATOM nAtom)
Definition: atom.c:454
struct tagWDML_CONV * next
Definition: dde_private.h:126
static rfbScreenInfoPtr server
Definition: vnc.c:74
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI DestroyWindow(_In_ HWND)
ATOM atomServiceSpec
Definition: dde_private.h:104
WDML_CONV * convs[2]
Definition: dde_private.h:168
BOOL WDML_DecHSZ(WDML_INSTANCE *pInstance, HSZ hsz)
Definition: ddemisc.c:380
#define WM_DDE_TERMINATE
Definition: dde.h:38
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
static FILE * client
Definition: client.c:41
const WCHAR WDML_szEventClass[]
Definition: ddemisc.c:38
void WDML_RemoveConv(WDML_CONV *pRef, WDML_SIDE side)
Definition: ddemisc.c:2070
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
void WDML_BroadcastDDEWindows(LPCWSTR clsName, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: ddemisc.c:2502
INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
Definition: ddemisc.c:685
WDML_SERVER * servers
Definition: dde_private.h:167
#define HeapFree(x, y, z)
Definition: compat.h:394
struct tagWDML_SERVER * next
Definition: dde_private.h:100
#define WM_WDML_UNREGISTER
Definition: dde_private.h:249

Referenced by DdeNameService().

◆ WDML_SetAllLastError()

static void WDML_SetAllLastError ( DWORD  lastError)
static

Definition at line 279 of file ddemisc.c.

280 {
281  DWORD threadID;
282  WDML_INSTANCE* pInstance;
283  threadID = GetCurrentThreadId();
284  pInstance = WDML_InstanceList;
285  while (pInstance)
286  {
287  if (pInstance->threadID == threadID)
288  pInstance->lastError = lastError;
289  pInstance = pInstance->next;
290  }
291 }
static WDML_INSTANCE * WDML_InstanceList
Definition: ddemisc.c:36
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:420
unsigned long DWORD
Definition: ntddk_ex.h:95
struct tagWDML_INSTANCE * next
Definition: dde_private.h:154

Referenced by DdeCreateDataHandle(), DdeCreateStringHandleA(), and DdeCreateStringHandleW().

◆ WDML_UnQueueTransaction()

BOOL WDML_UnQueueTransaction ( WDML_CONV pConv,
WDML_XACT pXAct 
)

Definition at line 1947 of file ddemisc.c.

1948 {
1949  WDML_XACT** pt;
1950 
1951  for (pt = &pConv->transactions; *pt; pt = &(*pt)->next)
1952  {
1953  if (*pt == pXAct)
1954  {
1955  *pt = pXAct->next;
1956  return TRUE;
1957  }
1958  }
1959  return FALSE;
1960 }
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
WDML_XACT * transactions
Definition: dde_private.h:135
struct tagWDML_XACT * next
Definition: dde_private.h:110
struct define * next
Definition: wpp.c:35

Referenced by DdeAbandonTransaction(), DdeClientTransaction(), and WDML_EnableCallback().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( ddeml  )

Variable Documentation

◆ critsect_debug

CRITICAL_SECTION_DEBUG critsect_debug
static
Initial value:
=
{
0, 0, &WDML_CritSect,
0, 0, { (DWORD_PTR)(__FILE__ ": WDML_CritSect") }
}
static CRITICAL_SECTION WDML_CritSect
Definition: ddemisc.c:41
#define DWORD_PTR
Definition: treelist.c:76
static CRITICAL_SECTION_DEBUG critsect_debug
Definition: ddemisc.c:42
LIST_ENTRY ProcessLocksList
Definition: winbase.h:848

Definition at line 42 of file ddemisc.c.

◆ WDML_CritSect

static CRITICAL_SECTION WDML_CritSect = { &critsect_debug, -1, 0, 0, 0, 0 }
static

Definition at line 41 of file ddemisc.c.

Referenced by WDML_GetInstance(), WDML_Initialize(), and WDML_NotifyThreadDetach().

◆ WDML_InstanceList

WDML_INSTANCE* WDML_InstanceList = NULL
static

◆ WDML_MaxInstanceID

LONG WDML_MaxInstanceID = 0
static

Definition at line 37 of file ddemisc.c.

Referenced by WDML_IncrementInstanceId().

◆ WDML_szEventClass

const WCHAR WDML_szEventClass[] = L"DDEMLEvent"

Definition at line 38 of file ddemisc.c.

Referenced by DdeNameService(), WDML_Initialize(), and WDML_RemoveServer().