Commit 433f72f8 authored by Rein Klazes's avatar Rein Klazes Committed by Alexandre Julliard

In MCI_(Un)MapMsg16To32W with wMsg == MCI_OPEN(_DRIVER) only do

strdupAtoW on those parameters that are flagged to be a string.
parent 4c5f9c09
......@@ -68,8 +68,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(mci);
WINMM_MapType (*pFnMciMapMsg16To32W) (WORD,WORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD) /* = NULL */;
WINMM_MapType (*pFnMciMapMsg16To32W) (WORD,WORD,DWORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD,DWORD) /* = NULL */;
WINMM_MapType (*pFnMciMapMsg32WTo16) (WORD,WORD,DWORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg32WTo16)(WORD,WORD,DWORD,DWORD) /* = NULL */;
......@@ -1595,7 +1595,7 @@ DWORD MCI_SendCommandFrom16(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1,
if (wmd->bIs32 && pFnMciMapMsg16To32W) {
WINMM_MapType res;
switch (res = pFnMciMapMsg16To32W(wmd->wType, wMsg, &dwParam2)) {
switch (res = pFnMciMapMsg16To32W(wmd->wType, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_MSGERROR:
TRACE("Not handled yet (%s)\n", MCI_MessageToString(wMsg));
dwRet = MCIERR_DRIVER_INTERNAL;
......@@ -1608,7 +1608,7 @@ DWORD MCI_SendCommandFrom16(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1,
case WINMM_MAP_OKMEM:
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
if (res == WINMM_MAP_OKMEM)
pFnMciUnMapMsg16To32W(wmd->wType, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(wmd->wType, wMsg, dwParam1, dwParam2);
break;
}
} else {
......@@ -1966,11 +1966,11 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
if (bFrom32) {
dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2);
} else if (pFnMciMapMsg16To32W) {
switch (pFnMciMapMsg16To32W(0, wMsg, &dwParam2)) {
switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -1980,11 +1980,11 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
if (bFrom32) {
dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
} else if (pFnMciMapMsg16To32W) {
switch (pFnMciMapMsg16To32W(0, wMsg, &dwParam2)) {
switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -1994,11 +1994,11 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
if (bFrom32) {
dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2);
} else if (pFnMciMapMsg16To32W) {
switch (pFnMciMapMsg16To32W(0, wMsg, &dwParam2)) {
switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -2008,11 +2008,11 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
if (bFrom32) {
dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
} else if (pFnMciMapMsg16To32W) {
switch (pFnMciMapMsg16To32W(0, wMsg, &dwParam2)) {
switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......@@ -2022,11 +2022,11 @@ DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD dwParam1,
if (bFrom32) {
dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2);
} else if (pFnMciMapMsg16To32W) {
switch (pFnMciMapMsg16To32W(0, wMsg, &dwParam2)) {
switch (pFnMciMapMsg16To32W(0, wMsg, dwParam1, &dwParam2)) {
case WINMM_MAP_OK:
case WINMM_MAP_OKMEM:
dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam2);
pFnMciUnMapMsg16To32W(0, wMsg, dwParam1, dwParam2);
break;
default: break; /* so that gcc does not bark */
}
......
......@@ -2522,7 +2522,7 @@ static WINMM_MapType MCI_UnMapMsg32ATo16(WORD uDevType, WORD wMsg, DWORD dwFlag
/**************************************************************************
* MCI_MapMsg16To32W [internal]
*/
static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD* lParam)
static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam)
{
if (*lParam == 0)
return WINMM_MAP_OK;
......@@ -2632,9 +2632,18 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD* lParam)
mop32w = (LPMCI_OPEN_PARMSW)((char*)mop32w + sizeof(LPMCI_OPEN_PARMS16));
mop32w->dwCallback = mop16->dwCallback;
mop32w->wDeviceID = mop16->wDeviceID;
mop32w->lpstrDeviceType = MCI_strdupAtoW(MapSL(mop16->lpstrDeviceType));
mop32w->lpstrElementName = MCI_strdupAtoW(MapSL(mop16->lpstrElementName));
mop32w->lpstrAlias = MCI_strdupAtoW(MapSL(mop16->lpstrAlias));
if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
mop32w->lpstrDeviceType = MCI_strdupAtoW(MapSL(mop16->lpstrDeviceType));
else
mop32w->lpstrDeviceType = (LPWSTR) mop16->lpstrDeviceType;
if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
mop32w->lpstrElementName = MCI_strdupAtoW(MapSL(mop16->lpstrElementName));
else
mop32w->lpstrElementName = (LPWSTR) mop16->lpstrElementName;
if( ( dwFlags & MCI_OPEN_ALIAS))
mop32w->lpstrAlias = MCI_strdupAtoW(MapSL(mop16->lpstrAlias));
else
mop32w->lpstrAlias = (LPWSTR) mop16->lpstrAlias;
/* copy extended information if any...
* FIXME: this may seg fault if initial structure does not contain them and
* the reads after msip16 fail under LDT limits...
......@@ -2707,7 +2716,7 @@ static WINMM_MapType MCI_MapMsg16To32W(WORD uDevType, WORD wMsg, DWORD* lParam)
/**************************************************************************
* MCI_UnMapMsg16To32W [internal]
*/
static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD lParam)
static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD lParam)
{
switch (wMsg) {
/* case MCI_CAPTURE */
......@@ -2798,9 +2807,12 @@ static WINMM_MapType MCI_UnMapMsg16To32W(WORD uDevType, WORD wMsg, DWORD lParam
LPMCI_OPEN_PARMS16 mop16 = *(LPMCI_OPEN_PARMS16*)((char*)mop32w - sizeof(LPMCI_OPEN_PARMS16));
mop16->wDeviceID = mop32w->wDeviceID;
HeapFree(GetProcessHeap(), 0, mop32w->lpstrDeviceType);
HeapFree(GetProcessHeap(), 0, mop32w->lpstrElementName);
HeapFree(GetProcessHeap(), 0, mop32w->lpstrAlias);
if( ( dwFlags & ( MCI_OPEN_TYPE | MCI_OPEN_TYPE_ID)) == MCI_OPEN_TYPE)
HeapFree(GetProcessHeap(), 0, mop32w->lpstrDeviceType);
if( ( dwFlags & ( MCI_OPEN_ELEMENT | MCI_OPEN_ELEMENT_ID)) == MCI_OPEN_ELEMENT)
HeapFree(GetProcessHeap(), 0, mop32w->lpstrElementName);
if( ( dwFlags & MCI_OPEN_ALIAS))
HeapFree(GetProcessHeap(), 0, mop32w->lpstrAlias);
if (!HeapFree(GetProcessHeap(), 0, (LPVOID)(lParam - sizeof(LPMCI_OPEN_PARMS16))))
FIXME("bad free line=%d\n", __LINE__);
}
......
......@@ -300,8 +300,8 @@ extern WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16);
extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCWSTR,LPCWSTR,LPARAM);
extern LRESULT (*pFnCloseDriver16)(UINT16,LPARAM,LPARAM);
extern LRESULT (*pFnSendMessage16)(UINT16,UINT,LPARAM,LPARAM);
extern WINMM_MapType (*pFnMciMapMsg16To32W)(WORD,WORD,DWORD*);
extern WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD);
extern WINMM_MapType (*pFnMciMapMsg16To32W)(WORD,WORD,DWORD,DWORD*);
extern WINMM_MapType (*pFnMciUnMapMsg16To32W)(WORD,WORD,DWORD,DWORD);
extern WINMM_MapType (*pFnMciMapMsg32WTo16)(WORD,WORD,DWORD,DWORD*);
extern WINMM_MapType (*pFnMciUnMapMsg32WTo16)(WORD,WORD,DWORD,DWORD);
extern LRESULT (*pFnCallMMDrvFunc16)(DWORD /* in fact FARPROC16 */,WORD,WORD,LONG,LONG,LONG);
......
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