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

This commit is contained in:
Jeff Latimer 2009-01-22 23:35:27 +11:00 committed by Alexandre Julliard
parent 10dfcfb9a0
commit c5bc4b2c9a
2 changed files with 51 additions and 9 deletions

View File

@ -817,6 +817,25 @@ UINT WINAPI DdeGetLastError(DWORD idInst)
return error_code; 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 * String management
@ -1267,15 +1286,24 @@ INT WINAPI DdeCmpStringHandles(HSZ hsz1, HSZ hsz2)
HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff, HDDEDATA WINAPI DdeCreateDataHandle(DWORD idInst, LPBYTE pSrc, DWORD cb, DWORD cbOff,
HSZ hszItem, UINT wFmt, UINT afCmd) 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. * The purpose of these arguments still need to be investigated.
*/ */
WDML_INSTANCE* pInstance;
HGLOBAL hMem; HGLOBAL hMem;
LPBYTE pByte; LPBYTE pByte;
DDE_DATAHANDLE_HEAD* pDdh; DDE_DATAHANDLE_HEAD* pDdh;
WCHAR psz[MAX_BUFFER_LEN]; 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)) if (!GetAtomNameW(HSZ2ATOM(hszItem), psz, MAX_BUFFER_LEN))
{ {
psz[0] = HSZ2ATOM(hszItem); psz[0] = HSZ2ATOM(hszItem);

View File

@ -1544,7 +1544,7 @@ static void test_DdeCreateStringHandleW(DWORD dde_inst, int codepage)
static void test_DdeCreateDataHandle(void) static void test_DdeCreateDataHandle(void)
{ {
HDDEDATA hdata; HDDEDATA hdata;
DWORD dde_inst; DWORD dde_inst, dde_inst2;
DWORD size; DWORD size;
UINT res, err; UINT res, err;
BOOL ret; BOOL ret;
@ -1552,27 +1552,41 @@ static void test_DdeCreateDataHandle(void)
LPBYTE ptr; LPBYTE ptr;
dde_inst = 0; dde_inst = 0;
dde_inst2 = 0;
res = DdeInitializeA(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0); res = DdeInitializeA(&dde_inst, client_ddeml_callback, APPCMD_CLIENTONLY, 0);
ok(res == DMLERR_NO_ERROR, "Expected DMLERR_NO_ERROR, got %d\n", res); 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); item = DdeCreateStringHandleA(dde_inst, "item", CP_WINANSI);
ok(item != NULL, "Expected non-NULL hsz\n"); 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) { if (0) {
/* do not test with an invalid instance id: that crashes on win9x */ /* do not test with an invalid instance id: that crashes on win9x */
hdata = DdeCreateDataHandle(0xdeadbeef, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0); 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_inst);
DdeGetLastError(dde_inst2);
hdata = DdeCreateDataHandle(0, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0); hdata = DdeCreateDataHandle(0, (LPBYTE)"data", MAX_PATH, 0, item, CF_TEXT, 0);
err = DdeGetLastError(dde_inst); 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); err = DdeGetLastError(dde_inst2);
ok(err == DMLERR_INVALIDPARAMETER, ok(err == DMLERR_INVALIDPARAMETER, "Expected DMLERR_INVALIDPARAMETER, got %d\n", err);
"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 */ /* NULL pSrc */
DdeGetLastError(dde_inst); DdeGetLastError(dde_inst);