Jeff Latimer : user32: Check the instance id on DdeCreateDataHandle and retire a couple of todos.

Alexandre Julliard julliard at winehq.org
Thu Jan 22 08:41:53 CST 2009


Module: wine
Branch: master
Commit: c5bc4b2c9a8ce8aa6e95d3800bf1d9d5021417e7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c5bc4b2c9a8ce8aa6e95d3800bf1d9d5021417e7

Author: Jeff Latimer <lats at yless4u.com.au>
Date:   Thu Jan 22 23:35:27 2009 +1100

user32: Check the instance id on DdeCreateDataHandle and retire a couple of todos.

---

 dlls/user32/dde_misc.c  |   30 +++++++++++++++++++++++++++++-
 dlls/user32/tests/dde.c |   30 ++++++++++++++++++++++--------
 2 files changed, 51 insertions(+), 9 deletions(-)

diff --git a/dlls/user32/dde_misc.c b/dlls/user32/dde_misc.c
index 89a6bb0..2b7fb81 100644
--- a/dlls/user32/dde_misc.c
+++ b/dlls/user32/dde_misc.c
@@ -817,6 +817,25 @@ UINT WINAPI DdeGetLastError(DWORD idInst)
     return error_code;
 }
 
+/******************************************************************
+ *		WDML_SetAllLastError
+ *
+ *
+ */
+static void	WDML_SetAllLastError(DWORD lastError)
+{
+    DWORD		threadID;
+    WDML_INSTANCE*	pInstance;
+    threadID = GetCurrentThreadId();
+    pInstance = WDML_InstanceList;
+    while (pInstance)
+    {
+	if (pInstance->threadID == threadID)
+	    pInstance->lastError = lastError;
+	pInstance = pInstance->next;
+    }
+}
+
 /* ================================================================
  *
  * 			String management
@@ -1267,15 +1286,24 @@ INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
 HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff,
                                     HSZ hszItem, UINT wFmt, UINT afCmd)
 {
-    /* For now, we ignore idInst, hszItem.
+
+    /* Other than check for validity we will ignore for now idInst, hszItem.
      * The purpose of these arguments still need to be investigated.
      */
 
+    WDML_INSTANCE*		pInstance;
     HGLOBAL     		hMem;
     LPBYTE      		pByte;
     DDE_DATAHANDLE_HEAD*	pDdh;
     WCHAR psz[MAX_BUFFER_LEN];
 
+    pInstance = WDML_GetInstance(idInst);
+    if (pInstance == NULL)
+    {
+        WDML_SetAllLastError(DMLERR_INVALIDPARAMETER);
+        return NULL;
+    }
+
     if (!GetAtomNameW(HSZ2ATOM(hszItem), psz, MAX_BUFFER_LEN))
     {
         psz[0] = HSZ2ATOM(hszItem);
diff --git a/dlls/user32/tests/dde.c b/dlls/user32/tests/dde.c
index 1d14df6..eaea63c 100644
--- a/dlls/user32/tests/dde.c
+++ b/dlls/user32/tests/dde.c
@@ -1544,7 +1544,7 @@ static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage)
 static void test_DdeCreateDataHandle(void)
 {
     HDDEDATA hdata;
-    DWORD dde_inst;
+    DWORD dde_inst, dde_inst2;
     DWORD size;
     UINT res, err;
     BOOL ret;
@@ -1552,27 +1552,41 @@ static void test_DdeCreateDataHandle(void)
     LPBYTE ptr;
 
     dde_inst = 0;
+    dde_inst2 = 0;
     res = DdeInitializeA(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
     ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
 
+    res = DdeInitializeA(&dde_inst2, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
+    ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
+
     item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI);
     ok(item != NULL, "Expected non-NULL hsz\n");
+    item = DdeCreateStringHandleA(dde_inst2, "item", CP_WINANSI);
+    ok(item != NULL, "Expected non-NULL hsz\n");
 
     if (0) {
         /* do not test with an invalid instance id: that crashes on win9x */
         hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
     }
 
-    /* 0 instance id */
+    /* 0 instance id
+     * This block tests an invalid instance Id.  The correct behaviour is that if the instance Id
+     * is invalid then the lastError of all instances is set to the error.  There are two instances
+     * created, lastError is cleared, an error is generated and then both instances are checked to
+     * ensure that they both have the same error set
+     */
     DdeGetLastError(dde_inst);
+    DdeGetLastError(dde_inst2);
     hdata = DdeCreateDataHandle(0, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
     err = DdeGetLastError(dde_inst);
-    todo_wine
-    {
-        ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
-        ok(err == DMLERR_INVALIDPARAMETER,
-           "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
-    }
+    ok(hdata == NULL, "Expected NULL, got %p\n", hdata);
+    ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
+    err = DdeGetLastError(dde_inst2);
+    ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
+
+    ret = DdeUninitialize(dde_inst2);
+    ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res);
+
 
     /* NULL pSrc */
     DdeGetLastError(dde_inst);




More information about the wine-cvs mailing list