Commit 740ba2ca authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed pack/unpack routines for WM_DDE_EXECUTE.

parent 3d2df9d9
...@@ -50,32 +50,6 @@ CRITICAL_SECTION WDML_CritSect = CRITICAL_SECTION_INIT("WDML_CritSect"); ...@@ -50,32 +50,6 @@ CRITICAL_SECTION WDML_CritSect = CRITICAL_SECTION_INIT("WDML_CritSect");
* *
* ================================================================ */ * ================================================================ */
static BOOL DDE_RequirePacking(UINT msg)
{
BOOL ret;
switch (msg)
{
case WM_DDE_ACK:
case WM_DDE_ADVISE:
case WM_DDE_DATA:
case WM_DDE_POKE:
ret = TRUE;
break;
case WM_DDE_EXECUTE: /* strange, NT 2000 (at least) really uses packing here... */
case WM_DDE_INITIATE:
case WM_DDE_REQUEST: /* assuming clipboard formats are 16 bit */
case WM_DDE_TERMINATE:
case WM_DDE_UNADVISE: /* assuming clipboard formats are 16 bit */
ret = FALSE;
break;
default:
TRACE("Unknown message %04x\n", msg);
ret = FALSE;
break;
}
return ret;
}
/***************************************************************** /*****************************************************************
* PackDDElParam (USER32.@) * PackDDElParam (USER32.@)
...@@ -85,31 +59,36 @@ static BOOL DDE_RequirePacking(UINT msg) ...@@ -85,31 +59,36 @@ static BOOL DDE_RequirePacking(UINT msg)
*/ */
LPARAM WINAPI PackDDElParam(UINT msg, UINT uiLo, UINT uiHi) LPARAM WINAPI PackDDElParam(UINT msg, UINT uiLo, UINT uiHi)
{ {
HGLOBAL hMem; HGLOBAL hMem;
UINT* params; UINT* params;
if (!DDE_RequirePacking(msg))
return MAKELONG(uiLo, uiHi);
if (!(hMem = GlobalAlloc(GMEM_MOVEABLE | GMEM_DDESHARE, sizeof(UINT) * 2))) switch (msg)
{ {
ERR("GlobalAlloc failed\n"); case WM_DDE_ACK:
return 0; case WM_DDE_ADVISE:
} case WM_DDE_DATA:
case WM_DDE_POKE:
params = GlobalLock(hMem); if (!(hMem = GlobalAlloc(GMEM_DDESHARE, sizeof(UINT) * 2)))
if (params == NULL) {
{ ERR("GlobalAlloc failed\n");
ERR("GlobalLock failed (%x)\n", hMem); return 0;
return 0; }
} if (!(params = GlobalLock(hMem)))
{
params[0] = uiLo; ERR("GlobalLock failed (%x)\n", hMem);
params[1] = uiHi; return 0;
}
GlobalUnlock(hMem); params[0] = uiLo;
params[1] = uiHi;
GlobalUnlock(hMem);
return (LPARAM)hMem;
case WM_DDE_EXECUTE:
return uiHi;
return (LPARAM)hMem; default:
return MAKELONG(uiLo, uiHi);
}
} }
...@@ -123,37 +102,35 @@ LPARAM WINAPI PackDDElParam(UINT msg, UINT uiLo, UINT uiHi) ...@@ -123,37 +102,35 @@ LPARAM WINAPI PackDDElParam(UINT msg, UINT uiLo, UINT uiHi)
BOOL WINAPI UnpackDDElParam(UINT msg, LPARAM lParam, BOOL WINAPI UnpackDDElParam(UINT msg, LPARAM lParam,
PUINT uiLo, PUINT uiHi) PUINT uiLo, PUINT uiHi)
{ {
HGLOBAL hMem; UINT *params;
UINT *params;
if (!DDE_RequirePacking(msg)) switch (msg)
{ {
*uiLo = LOWORD(lParam); case WM_DDE_ACK:
*uiHi = HIWORD(lParam); case WM_DDE_ADVISE:
case WM_DDE_DATA:
case WM_DDE_POKE:
if (!lParam) return FALSE;
if (!(params = GlobalLock( (HGLOBAL)lParam )))
{
ERR("GlobalLock failed (%lx)\n", lParam);
return FALSE;
}
if (uiLo) *uiLo = params[0];
if (uiHi) *uiHi = params[1];
GlobalUnlock( (HGLOBAL)lParam );
return TRUE;
return TRUE; case WM_DDE_EXECUTE:
} if (uiLo) *uiLo = 0;
if (uiHi) *uiHi = lParam;
if (lParam == 0) return TRUE;
{
return FALSE;
}
hMem = (HGLOBAL)lParam;
params = GlobalLock(hMem);
if (params == NULL)
{
ERR("GlobalLock failed (%x)\n", hMem);
return FALSE;
}
*uiLo = params[0];
*uiHi = params[1];
GlobalUnlock(hMem); default:
if (uiLo) *uiLo = LOWORD(lParam);
return TRUE; if (uiHi) *uiHi = HIWORD(lParam);
return TRUE;
}
} }
...@@ -166,16 +143,19 @@ BOOL WINAPI UnpackDDElParam(UINT msg, LPARAM lParam, ...@@ -166,16 +143,19 @@ BOOL WINAPI UnpackDDElParam(UINT msg, LPARAM lParam,
*/ */
BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam) BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam)
{ {
HGLOBAL hMem = (HGLOBAL)lParam; switch (msg)
{
if (!DDE_RequirePacking(msg)) case WM_DDE_ACK:
return TRUE; case WM_DDE_ADVISE:
case WM_DDE_DATA:
case WM_DDE_POKE:
/* first check if it's a global handle */
if (!GlobalHandle( (LPVOID)lParam )) return TRUE;
return !GlobalFree( (HGLOBAL)lParam );
if (lParam == 0) default:
{ return TRUE;
return FALSE;
} }
return GlobalFree(hMem) == (HGLOBAL)NULL;
} }
...@@ -188,45 +168,44 @@ BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam) ...@@ -188,45 +168,44 @@ BOOL WINAPI FreeDDElParam(UINT msg, LPARAM lParam)
LPARAM WINAPI ReuseDDElParam(LPARAM lParam, UINT msgIn, UINT msgOut, LPARAM WINAPI ReuseDDElParam(LPARAM lParam, UINT msgIn, UINT msgOut,
UINT uiLo, UINT uiHi) UINT uiLo, UINT uiHi)
{ {
HGLOBAL hMem; UINT* params;
UINT* params;
BOOL in, out;
in = DDE_RequirePacking(msgIn);
out = DDE_RequirePacking(msgOut);
if (!in)
{
return PackDDElParam(msgOut, uiLo, uiHi);
}
if (lParam == 0)
{
return FALSE;
}
if (!out) switch (msgIn)
{ {
FreeDDElParam(msgIn, lParam); case WM_DDE_ACK:
return MAKELONG(uiLo, uiHi); case WM_DDE_ADVISE:
} case WM_DDE_DATA:
case WM_DDE_POKE:
switch(msgOut)
{
case WM_DDE_ACK:
case WM_DDE_ADVISE:
case WM_DDE_DATA:
case WM_DDE_POKE:
if (!lParam) return 0;
if (!(params = GlobalLock( (HGLOBAL)lParam )))
{
ERR("GlobalLock failed\n");
return 0;
}
params[0] = uiLo;
params[1] = uiHi;
TRACE("Reusing pack %08x %08x\n", uiLo, uiHi);
GlobalLock( (HGLOBAL)lParam );
return lParam;
hMem = (HGLOBAL)lParam; case WM_DDE_EXECUTE:
FreeDDElParam( msgIn, lParam );
params = GlobalLock(hMem); return uiHi;
if (params == NULL)
{
ERR("GlobalLock failed\n");
return 0;
}
params[0] = uiLo;
params[1] = uiHi;
TRACE("Reusing pack %08x %08x\n", uiLo, uiHi); default:
FreeDDElParam( msgIn, lParam );
return MAKELONG(uiLo, uiHi);
}
GlobalLock(hMem); default:
return lParam; return PackDDElParam( msgOut, uiLo, uiHi );
}
} }
/***************************************************************** /*****************************************************************
...@@ -2047,6 +2026,13 @@ UINT WINAPI DdeQueryConvInfo(HCONV hConv, DWORD id, LPCONVINFO lpConvInfo) ...@@ -2047,6 +2026,13 @@ UINT WINAPI DdeQueryConvInfo(HCONV hConv, DWORD id, LPCONVINFO lpConvInfo)
CONVINFO ci; CONVINFO ci;
WDML_CONV* pConv; WDML_CONV* pConv;
if (!hConv)
{
FIXME("hConv is NULL\n");
return 0;
}
EnterCriticalSection(&WDML_CritSect); EnterCriticalSection(&WDML_CritSect);
pConv = WDML_GetConv(hConv, FALSE); pConv = WDML_GetConv(hConv, FALSE);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment