1999-03-15 16:42:26 +01:00
|
|
|
/*
|
|
|
|
* MCI internal functions
|
|
|
|
*
|
|
|
|
* Copyright 1998/1999 Eric Pouech
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-03-15 16:42:26 +01:00
|
|
|
*/
|
|
|
|
|
2004-04-05 22:16:11 +02:00
|
|
|
/* TODO:
|
|
|
|
* - implement WINMM (32bit) multitasking and use it in all MCI drivers
|
|
|
|
* instead of the home grown one
|
|
|
|
* - 16bit mmTaskXXX functions are currently broken because the 16
|
|
|
|
* loader does not support binary command lines => provide Wine's
|
|
|
|
* own mmtask.tsk not using binary command line.
|
|
|
|
* - correctly handle the MCI_ALL_DEVICE_ID in functions.
|
|
|
|
* - finish mapping 16 <=> 32 of MCI structures and commands
|
|
|
|
* - implement auto-open feature (ie, when a string command is issued
|
|
|
|
* for a not yet opened device, MCI automatically opens it)
|
|
|
|
* - use a default registry setting to replace the [mci] section in
|
|
|
|
* configuration file (layout of info in registry should be compatible
|
|
|
|
* with all Windows' version - which use different layouts of course)
|
2005-02-09 23:26:25 +01:00
|
|
|
* - implement automatic open
|
|
|
|
* + only works on string interface, on regular devices (don't work on all
|
|
|
|
* nor custom devices)
|
|
|
|
* - command table handling isn't thread safe
|
|
|
|
*/
|
|
|
|
|
2002-06-04 02:50:11 +02:00
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
#include <stdlib.h>
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1999-03-15 16:42:26 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "windef.h"
|
1999-03-15 16:42:26 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "mmsystem.h"
|
1999-03-15 16:42:26 +01:00
|
|
|
#include "winuser.h"
|
2002-10-29 22:53:44 +01:00
|
|
|
#include "winnls.h"
|
2003-10-15 22:49:29 +02:00
|
|
|
#include "winreg.h"
|
2005-02-09 23:26:25 +01:00
|
|
|
#include "wownt32.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
|
|
|
|
#include "digitalv.h"
|
1999-09-05 18:44:38 +02:00
|
|
|
#include "winemm.h"
|
2001-07-18 23:04:23 +02:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2005-02-09 23:26:25 +01:00
|
|
|
#include "wine/unicode.h"
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(mci);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/* First MCI valid device ID (0 means error) */
|
|
|
|
#define MCI_MAGIC 0x0001
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2004-06-30 20:12:20 +02:00
|
|
|
/* MCI settings */
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR wszHklmMci [] = {'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\','W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\','M','C','I',0};
|
|
|
|
static const WCHAR wszNull [] = {0};
|
|
|
|
static const WCHAR wszAll [] = {'A','L','L',0};
|
|
|
|
static const WCHAR wszMci [] = {'M','C','I',0};
|
|
|
|
static const WCHAR wszOpen [] = {'o','p','e','n',0};
|
|
|
|
static const WCHAR wszSystemIni[] = {'s','y','s','t','e','m','.','i','n','i',0};
|
2004-06-30 20:12:20 +02:00
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
static WINE_MCIDRIVER *MciDrivers;
|
|
|
|
|
2009-01-31 14:02:34 +01:00
|
|
|
static UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data);
|
2009-10-20 21:54:52 +02:00
|
|
|
static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType);
|
2009-01-31 14:02:34 +01:00
|
|
|
|
2001-07-24 23:45:22 +02:00
|
|
|
/* dup a string and uppercase it */
|
2007-03-23 16:10:05 +01:00
|
|
|
static inline LPWSTR str_dup_upper( LPCWSTR str )
|
2001-07-24 23:45:22 +02:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
INT len = (strlenW(str) + 1) * sizeof(WCHAR);
|
|
|
|
LPWSTR p = HeapAlloc( GetProcessHeap(), 0, len );
|
2001-07-24 23:45:22 +02:00
|
|
|
if (p)
|
|
|
|
{
|
|
|
|
memcpy( p, str, len );
|
2005-02-09 23:26:25 +01:00
|
|
|
CharUpperW( p );
|
2001-07-24 23:45:22 +02:00
|
|
|
}
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetDriver [internal]
|
|
|
|
*/
|
2009-11-14 14:40:04 +01:00
|
|
|
static LPWINE_MCIDRIVER MCI_GetDriver(UINT wDevID)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd = 0;
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
|
1999-09-22 18:43:18 +02:00
|
|
|
if (wmd->wDeviceID == wDevID)
|
|
|
|
break;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
1999-07-24 12:41:28 +02:00
|
|
|
return wmd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetDriverFromString [internal]
|
|
|
|
*/
|
2009-01-31 14:02:34 +01:00
|
|
|
static UINT MCI_GetDriverFromString(LPCWSTR lpstrName)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
UINT ret = 0;
|
|
|
|
|
|
|
|
if (!lpstrName)
|
|
|
|
return 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!strcmpiW(lpstrName, wszAll))
|
1999-07-24 12:41:28 +02:00
|
|
|
return MCI_ALL_DEVICE_ID;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
|
2010-09-01 17:50:43 +02:00
|
|
|
if (wmd->lpstrAlias && strcmpiW(wmd->lpstrAlias, lpstrName) == 0) {
|
1999-09-22 18:43:18 +02:00
|
|
|
ret = wmd->wDeviceID;
|
|
|
|
break;
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_MessageToString [internal]
|
|
|
|
*/
|
2010-08-31 11:52:57 +02:00
|
|
|
static const char* MCI_MessageToString(UINT wMsg)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
#define CASE(s) case (s): return #s
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
switch (wMsg) {
|
2005-02-09 23:26:25 +01:00
|
|
|
CASE(DRV_LOAD);
|
|
|
|
CASE(DRV_ENABLE);
|
|
|
|
CASE(DRV_OPEN);
|
|
|
|
CASE(DRV_CLOSE);
|
|
|
|
CASE(DRV_DISABLE);
|
|
|
|
CASE(DRV_FREE);
|
|
|
|
CASE(DRV_CONFIGURE);
|
|
|
|
CASE(DRV_QUERYCONFIGURE);
|
|
|
|
CASE(DRV_INSTALL);
|
|
|
|
CASE(DRV_REMOVE);
|
|
|
|
CASE(DRV_EXITSESSION);
|
|
|
|
CASE(DRV_EXITAPPLICATION);
|
|
|
|
CASE(DRV_POWER);
|
1999-07-24 12:41:28 +02:00
|
|
|
CASE(MCI_BREAK);
|
|
|
|
CASE(MCI_CLOSE);
|
|
|
|
CASE(MCI_CLOSE_DRIVER);
|
|
|
|
CASE(MCI_COPY);
|
|
|
|
CASE(MCI_CUE);
|
|
|
|
CASE(MCI_CUT);
|
|
|
|
CASE(MCI_DELETE);
|
|
|
|
CASE(MCI_ESCAPE);
|
|
|
|
CASE(MCI_FREEZE);
|
|
|
|
CASE(MCI_PAUSE);
|
|
|
|
CASE(MCI_PLAY);
|
|
|
|
CASE(MCI_GETDEVCAPS);
|
|
|
|
CASE(MCI_INFO);
|
|
|
|
CASE(MCI_LOAD);
|
|
|
|
CASE(MCI_OPEN);
|
|
|
|
CASE(MCI_OPEN_DRIVER);
|
|
|
|
CASE(MCI_PASTE);
|
|
|
|
CASE(MCI_PUT);
|
|
|
|
CASE(MCI_REALIZE);
|
|
|
|
CASE(MCI_RECORD);
|
|
|
|
CASE(MCI_RESUME);
|
|
|
|
CASE(MCI_SAVE);
|
|
|
|
CASE(MCI_SEEK);
|
|
|
|
CASE(MCI_SET);
|
2010-03-28 21:54:50 +02:00
|
|
|
CASE(MCI_SOUND);
|
1999-07-24 12:41:28 +02:00
|
|
|
CASE(MCI_SPIN);
|
|
|
|
CASE(MCI_STATUS);
|
|
|
|
CASE(MCI_STEP);
|
|
|
|
CASE(MCI_STOP);
|
|
|
|
CASE(MCI_SYSINFO);
|
|
|
|
CASE(MCI_UNFREEZE);
|
|
|
|
CASE(MCI_UPDATE);
|
|
|
|
CASE(MCI_WHERE);
|
|
|
|
CASE(MCI_WINDOW);
|
|
|
|
/* constants for digital video */
|
|
|
|
CASE(MCI_CAPTURE);
|
|
|
|
CASE(MCI_MONITOR);
|
|
|
|
CASE(MCI_RESERVE);
|
|
|
|
CASE(MCI_SETAUDIO);
|
|
|
|
CASE(MCI_SIGNAL);
|
|
|
|
CASE(MCI_SETVIDEO);
|
|
|
|
CASE(MCI_QUALITY);
|
|
|
|
CASE(MCI_LIST);
|
|
|
|
CASE(MCI_UNDO);
|
|
|
|
CASE(MCI_CONFIGURE);
|
|
|
|
CASE(MCI_RESTORE);
|
|
|
|
#undef CASE
|
|
|
|
default:
|
2009-11-30 10:22:08 +01:00
|
|
|
return wine_dbg_sprintf("MCI_<<%04X>>", wMsg);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-31 11:52:57 +02:00
|
|
|
static LPWSTR MCI_strdupAtoW( LPCSTR str )
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
LPWSTR ret;
|
|
|
|
INT len;
|
|
|
|
|
|
|
|
if (!str) return NULL;
|
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
|
|
|
|
ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
if (ret) MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int MCI_MapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR *dwParam2)
|
|
|
|
{
|
|
|
|
if (msg < DRV_RESERVED) return 0;
|
|
|
|
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case MCI_CLOSE:
|
|
|
|
case MCI_CONFIGURE:
|
|
|
|
case MCI_PLAY:
|
|
|
|
case MCI_SEEK:
|
|
|
|
case MCI_STOP:
|
|
|
|
case MCI_PAUSE:
|
|
|
|
case MCI_GETDEVCAPS:
|
|
|
|
case MCI_SPIN:
|
|
|
|
case MCI_SET:
|
|
|
|
case MCI_STEP:
|
|
|
|
case MCI_RECORD:
|
|
|
|
case MCI_BREAK:
|
|
|
|
case MCI_STATUS:
|
|
|
|
case MCI_CUE:
|
|
|
|
case MCI_REALIZE:
|
|
|
|
case MCI_PUT:
|
|
|
|
case MCI_WHERE:
|
|
|
|
case MCI_FREEZE:
|
|
|
|
case MCI_UNFREEZE:
|
|
|
|
case MCI_CUT:
|
|
|
|
case MCI_COPY:
|
|
|
|
case MCI_PASTE:
|
|
|
|
case MCI_UPDATE:
|
|
|
|
case MCI_RESUME:
|
|
|
|
case MCI_DELETE:
|
2005-02-26 18:41:11 +01:00
|
|
|
case MCI_MONITOR:
|
|
|
|
case MCI_SIGNAL:
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_UNDO:
|
2005-02-09 23:26:25 +01:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
case MCI_OPEN:
|
2010-03-28 20:01:15 +02:00
|
|
|
{ /* MCI_ANIM_OPEN_PARMS is the largest known MCI_OPEN_PARMS
|
|
|
|
* structure, larger than MCI_WAVE_OPEN_PARMS */
|
|
|
|
MCI_ANIM_OPEN_PARMSA *mci_openA = (MCI_ANIM_OPEN_PARMSA*)*dwParam2;
|
|
|
|
MCI_ANIM_OPEN_PARMSW *mci_openW;
|
2005-02-09 23:26:25 +01:00
|
|
|
DWORD_PTR *ptr;
|
|
|
|
|
2010-03-28 20:01:15 +02:00
|
|
|
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD_PTR) + sizeof(*mci_openW));
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!ptr) return -1;
|
|
|
|
|
|
|
|
*ptr++ = *dwParam2; /* save the previous pointer */
|
|
|
|
*dwParam2 = (DWORD_PTR)ptr;
|
2010-03-28 20:01:15 +02:00
|
|
|
mci_openW = (MCI_ANIM_OPEN_PARMSW *)ptr;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_openW->dwCallback = mci_openA->dwCallback;
|
|
|
|
|
|
|
|
if (dwParam1 & MCI_OPEN_TYPE)
|
|
|
|
{
|
|
|
|
if (dwParam1 & MCI_OPEN_TYPE_ID)
|
2006-11-22 17:14:45 +01:00
|
|
|
mci_openW->lpstrDeviceType = (LPCWSTR)mci_openA->lpstrDeviceType;
|
2005-02-09 23:26:25 +01:00
|
|
|
else
|
|
|
|
mci_openW->lpstrDeviceType = MCI_strdupAtoW(mci_openA->lpstrDeviceType);
|
|
|
|
}
|
|
|
|
if (dwParam1 & MCI_OPEN_ELEMENT)
|
|
|
|
{
|
|
|
|
if (dwParam1 & MCI_OPEN_ELEMENT_ID)
|
2006-11-22 17:14:45 +01:00
|
|
|
mci_openW->lpstrElementName = (LPCWSTR)mci_openA->lpstrElementName;
|
2005-02-09 23:26:25 +01:00
|
|
|
else
|
|
|
|
mci_openW->lpstrElementName = MCI_strdupAtoW(mci_openA->lpstrElementName);
|
|
|
|
}
|
|
|
|
if (dwParam1 & MCI_OPEN_ALIAS)
|
|
|
|
mci_openW->lpstrAlias = MCI_strdupAtoW(mci_openA->lpstrAlias);
|
2010-03-28 20:01:15 +02:00
|
|
|
/* We don't know how many DWORD follow, as
|
|
|
|
* the structure depends on the device. */
|
|
|
|
if (HIWORD(dwParam1))
|
|
|
|
memcpy(&mci_openW->dwStyle, &mci_openA->dwStyle, sizeof(MCI_ANIM_OPEN_PARMSW) - sizeof(MCI_OPEN_PARMSW));
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case MCI_WINDOW:
|
|
|
|
if (dwParam1 & MCI_ANIM_WINDOW_TEXT)
|
|
|
|
{
|
|
|
|
MCI_ANIM_WINDOW_PARMSA *mci_windowA = (MCI_ANIM_WINDOW_PARMSA *)*dwParam2;
|
|
|
|
MCI_ANIM_WINDOW_PARMSW *mci_windowW;
|
|
|
|
|
|
|
|
mci_windowW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_windowW));
|
|
|
|
if (!mci_windowW) return -1;
|
|
|
|
|
|
|
|
*dwParam2 = (DWORD_PTR)mci_windowW;
|
|
|
|
|
|
|
|
mci_windowW->lpstrText = MCI_strdupAtoW(mci_windowA->lpstrText);
|
|
|
|
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_windowW->dwCallback = mci_windowA->dwCallback;
|
|
|
|
if (dwParam1 & MCI_ANIM_WINDOW_HWND)
|
|
|
|
mci_windowW->hWnd = mci_windowA->hWnd;
|
|
|
|
if (dwParam1 & MCI_ANIM_WINDOW_STATE)
|
|
|
|
mci_windowW->nCmdShow = mci_windowA->nCmdShow;
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case MCI_SYSINFO:
|
2010-03-28 20:01:15 +02:00
|
|
|
if (dwParam1 & (MCI_SYSINFO_INSTALLNAME | MCI_SYSINFO_NAME))
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
MCI_SYSINFO_PARMSA *mci_sysinfoA = (MCI_SYSINFO_PARMSA *)*dwParam2;
|
|
|
|
MCI_SYSINFO_PARMSW *mci_sysinfoW;
|
|
|
|
DWORD_PTR *ptr;
|
|
|
|
|
|
|
|
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_sysinfoW) + sizeof(DWORD_PTR));
|
|
|
|
if (!ptr) return -1;
|
|
|
|
|
|
|
|
*ptr++ = *dwParam2; /* save the previous pointer */
|
|
|
|
*dwParam2 = (DWORD_PTR)ptr;
|
|
|
|
mci_sysinfoW = (MCI_SYSINFO_PARMSW *)ptr;
|
|
|
|
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_sysinfoW->dwCallback = mci_sysinfoA->dwCallback;
|
|
|
|
|
2010-04-09 05:45:07 +02:00
|
|
|
/* Size is measured in numbers of characters, despite what MSDN says. */
|
2005-02-09 23:26:25 +01:00
|
|
|
mci_sysinfoW->dwRetSize = mci_sysinfoA->dwRetSize;
|
2010-04-09 05:45:07 +02:00
|
|
|
mci_sysinfoW->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mci_sysinfoW->dwRetSize * sizeof(WCHAR));
|
2005-02-09 23:26:25 +01:00
|
|
|
mci_sysinfoW->dwNumber = mci_sysinfoA->dwNumber;
|
|
|
|
mci_sysinfoW->wDeviceType = mci_sysinfoA->wDeviceType;
|
|
|
|
return 1;
|
|
|
|
}
|
2010-03-28 20:01:15 +02:00
|
|
|
return 0;
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_INFO:
|
|
|
|
{
|
2011-05-18 15:08:11 +02:00
|
|
|
MCI_DGV_INFO_PARMSA *mci_infoA = (MCI_DGV_INFO_PARMSA *)*dwParam2;
|
|
|
|
MCI_DGV_INFO_PARMSW *mci_infoW;
|
2005-02-09 23:26:25 +01:00
|
|
|
DWORD_PTR *ptr;
|
|
|
|
|
|
|
|
ptr = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_infoW) + sizeof(DWORD_PTR));
|
|
|
|
if (!ptr) return -1;
|
|
|
|
|
|
|
|
*ptr++ = *dwParam2; /* save the previous pointer */
|
|
|
|
*dwParam2 = (DWORD_PTR)ptr;
|
2011-05-18 15:08:11 +02:00
|
|
|
mci_infoW = (MCI_DGV_INFO_PARMSW *)ptr;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_infoW->dwCallback = mci_infoA->dwCallback;
|
|
|
|
|
2010-03-28 20:01:15 +02:00
|
|
|
/* Size is measured in numbers of characters. */
|
2010-04-09 05:45:07 +02:00
|
|
|
mci_infoW->dwRetSize = mci_infoA->dwRetSize;
|
2010-03-28 20:01:15 +02:00
|
|
|
mci_infoW->lpstrReturn = HeapAlloc(GetProcessHeap(), 0, mci_infoW->dwRetSize * sizeof(WCHAR));
|
2011-05-18 15:08:11 +02:00
|
|
|
if (dwParam1 & MCI_DGV_INFO_ITEM)
|
|
|
|
mci_infoW->dwItem = mci_infoA->dwItem;
|
2005-02-09 23:26:25 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
case MCI_SAVE:
|
|
|
|
case MCI_LOAD:
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_CAPTURE:
|
|
|
|
case MCI_RESTORE:
|
|
|
|
{ /* All these commands have the same layout: callback + string + optional rect */
|
|
|
|
MCI_OVLY_LOAD_PARMSA *mci_loadA = (MCI_OVLY_LOAD_PARMSA *)*dwParam2;
|
|
|
|
MCI_OVLY_LOAD_PARMSW *mci_loadW;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
mci_loadW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_loadW));
|
|
|
|
if (!mci_loadW) return -1;
|
|
|
|
|
|
|
|
*dwParam2 = (DWORD_PTR)mci_loadW;
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_loadW->dwCallback = mci_loadA->dwCallback;
|
|
|
|
mci_loadW->lpfilename = MCI_strdupAtoW(mci_loadA->lpfilename);
|
2010-03-28 20:01:15 +02:00
|
|
|
if ((MCI_SAVE == msg && dwParam1 & MCI_DGV_RECT) ||
|
|
|
|
(MCI_LOAD == msg && dwParam1 & MCI_OVLY_RECT) ||
|
|
|
|
(MCI_CAPTURE == msg && dwParam1 & MCI_DGV_CAPTURE_AT) ||
|
|
|
|
(MCI_RESTORE == msg && dwParam1 & MCI_DGV_RESTORE_AT))
|
|
|
|
mci_loadW->rc = mci_loadA->rc;
|
2005-02-09 23:26:25 +01:00
|
|
|
return 1;
|
|
|
|
}
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_SOUND:
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_ESCAPE:
|
2010-03-28 20:01:15 +02:00
|
|
|
{ /* All these commands have the same layout: callback + string */
|
2005-02-09 23:26:25 +01:00
|
|
|
MCI_VD_ESCAPE_PARMSA *mci_vd_escapeA = (MCI_VD_ESCAPE_PARMSA *)*dwParam2;
|
|
|
|
MCI_VD_ESCAPE_PARMSW *mci_vd_escapeW;
|
|
|
|
|
|
|
|
mci_vd_escapeW = HeapAlloc(GetProcessHeap(), 0, sizeof(*mci_vd_escapeW));
|
|
|
|
if (!mci_vd_escapeW) return -1;
|
|
|
|
|
|
|
|
*dwParam2 = (DWORD_PTR)mci_vd_escapeW;
|
|
|
|
if (dwParam1 & MCI_NOTIFY)
|
|
|
|
mci_vd_escapeW->dwCallback = mci_vd_escapeA->dwCallback;
|
|
|
|
mci_vd_escapeW->lpstrCommand = MCI_strdupAtoW(mci_vd_escapeA->lpstrCommand);
|
|
|
|
return 1;
|
|
|
|
}
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_SETAUDIO:
|
|
|
|
case MCI_SETVIDEO:
|
|
|
|
if (!(dwParam1 & (MCI_DGV_SETVIDEO_QUALITY | MCI_DGV_SETVIDEO_ALG
|
|
|
|
| MCI_DGV_SETAUDIO_QUALITY | MCI_DGV_SETAUDIO_ALG)))
|
|
|
|
return 0;
|
|
|
|
/* fall through to default */
|
|
|
|
case MCI_RESERVE:
|
|
|
|
case MCI_QUALITY:
|
|
|
|
case MCI_LIST:
|
2005-02-09 23:26:25 +01:00
|
|
|
default:
|
|
|
|
FIXME("Message %s needs translation\n", MCI_MessageToString(msg));
|
2010-03-28 20:01:15 +02:00
|
|
|
return 0; /* pass through untouched */
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-28 20:01:15 +02:00
|
|
|
static void MCI_UnmapMsgAtoW(UINT msg, DWORD_PTR dwParam1, DWORD_PTR dwParam2,
|
2005-02-09 23:26:25 +01:00
|
|
|
DWORD result)
|
|
|
|
{
|
|
|
|
switch (msg)
|
|
|
|
{
|
|
|
|
case MCI_OPEN:
|
|
|
|
{
|
|
|
|
DWORD_PTR *ptr = (DWORD_PTR *)dwParam2 - 1;
|
|
|
|
MCI_OPEN_PARMSA *mci_openA = (MCI_OPEN_PARMSA *)*ptr;
|
2010-03-28 20:01:15 +02:00
|
|
|
MCI_OPEN_PARMSW *mci_openW = (MCI_OPEN_PARMSW *)dwParam2;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
mci_openA->wDeviceID = mci_openW->wDeviceID;
|
|
|
|
|
|
|
|
if (dwParam1 & MCI_OPEN_TYPE)
|
|
|
|
{
|
|
|
|
if (!(dwParam1 & MCI_OPEN_TYPE_ID))
|
2005-08-18 12:53:58 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrDeviceType);
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
if (dwParam1 & MCI_OPEN_ELEMENT)
|
|
|
|
{
|
|
|
|
if (!(dwParam1 & MCI_OPEN_ELEMENT_ID))
|
2005-08-18 12:53:58 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrElementName);
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
if (dwParam1 & MCI_OPEN_ALIAS)
|
2005-08-18 12:53:58 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, (LPWSTR)mci_openW->lpstrAlias);
|
2005-02-09 23:26:25 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_WINDOW:
|
|
|
|
if (dwParam1 & MCI_ANIM_WINDOW_TEXT)
|
|
|
|
{
|
|
|
|
MCI_ANIM_WINDOW_PARMSW *mci_windowW = (MCI_ANIM_WINDOW_PARMSW *)dwParam2;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)mci_windowW->lpstrText);
|
|
|
|
HeapFree(GetProcessHeap(), 0, mci_windowW);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MCI_SYSINFO:
|
2010-03-28 20:01:15 +02:00
|
|
|
if (dwParam1 & (MCI_SYSINFO_INSTALLNAME | MCI_SYSINFO_NAME))
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
DWORD_PTR *ptr = (DWORD_PTR *)dwParam2 - 1;
|
|
|
|
MCI_SYSINFO_PARMSA *mci_sysinfoA = (MCI_SYSINFO_PARMSA *)*ptr;
|
2010-03-28 20:01:15 +02:00
|
|
|
MCI_SYSINFO_PARMSW *mci_sysinfoW = (MCI_SYSINFO_PARMSW *)dwParam2;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
2010-03-28 20:01:15 +02:00
|
|
|
WideCharToMultiByte(CP_ACP, 0,
|
2011-02-20 18:55:12 +01:00
|
|
|
mci_sysinfoW->lpstrReturn, -1,
|
2010-03-28 20:01:15 +02:00
|
|
|
mci_sysinfoA->lpstrReturn, mci_sysinfoA->dwRetSize,
|
|
|
|
NULL, NULL);
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, mci_sysinfoW->lpstrReturn);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_INFO:
|
|
|
|
{
|
|
|
|
DWORD_PTR *ptr = (DWORD_PTR *)dwParam2 - 1;
|
|
|
|
MCI_INFO_PARMSA *mci_infoA = (MCI_INFO_PARMSA *)*ptr;
|
2010-03-28 20:01:15 +02:00
|
|
|
MCI_INFO_PARMSW *mci_infoW = (MCI_INFO_PARMSW *)dwParam2;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
WideCharToMultiByte(CP_ACP, 0,
|
2011-02-20 18:55:12 +01:00
|
|
|
mci_infoW->lpstrReturn, -1,
|
2005-02-09 23:26:25 +01:00
|
|
|
mci_infoA->lpstrReturn, mci_infoA->dwRetSize,
|
|
|
|
NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, mci_infoW->lpstrReturn);
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_SAVE:
|
|
|
|
case MCI_LOAD:
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_CAPTURE:
|
|
|
|
case MCI_RESTORE:
|
|
|
|
{ /* All these commands have the same layout: callback + string + optional rect */
|
|
|
|
MCI_OVLY_LOAD_PARMSW *mci_loadW = (MCI_OVLY_LOAD_PARMSW *)dwParam2;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)mci_loadW->lpfilename);
|
|
|
|
HeapFree(GetProcessHeap(), 0, mci_loadW);
|
|
|
|
}
|
|
|
|
break;
|
2010-03-28 20:01:15 +02:00
|
|
|
case MCI_SOUND:
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_ESCAPE:
|
2010-03-28 20:01:15 +02:00
|
|
|
{ /* All these commands have the same layout: callback + string */
|
2005-02-09 23:26:25 +01:00
|
|
|
MCI_VD_ESCAPE_PARMSW *mci_vd_escapeW = (MCI_VD_ESCAPE_PARMSW *)dwParam2;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, (void*)mci_vd_escapeW->lpstrCommand);
|
|
|
|
HeapFree(GetProcessHeap(), 0, mci_vd_escapeW);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Message %s needs unmapping\n", MCI_MessageToString(msg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetDevTypeFromFileName [internal]
|
|
|
|
*/
|
2005-11-29 11:24:55 +01:00
|
|
|
static DWORD MCI_GetDevTypeFromFileName(LPCWSTR fileName, LPWSTR buf, UINT len)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
LPCWSTR tmp;
|
2003-10-15 22:49:29 +02:00
|
|
|
HKEY hKey;
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR keyW[] = {'S','O','F','T','W','A','R','E','\\','M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'M','C','I',' ','E','x','t','e','n','s','i','o','n','s',0};
|
|
|
|
if ((tmp = strrchrW(fileName, '.'))) {
|
|
|
|
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, keyW,
|
2003-10-15 22:49:29 +02:00
|
|
|
0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
|
|
|
|
DWORD dwLen = len;
|
2005-02-09 23:26:25 +01:00
|
|
|
LONG lRet = RegQueryValueExW( hKey, tmp + 1, 0, 0, (void*)buf, &dwLen );
|
2003-10-15 22:49:29 +02:00
|
|
|
RegCloseKey( hKey );
|
|
|
|
if (lRet == ERROR_SUCCESS) return 0;
|
|
|
|
}
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("No ...\\MCI Extensions entry for %s found.\n", debugstr_w(tmp));
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
return MCIERR_EXTENSION_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2010-09-03 06:33:52 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetDevTypeFromResource [internal]
|
|
|
|
*/
|
|
|
|
static UINT MCI_GetDevTypeFromResource(LPCWSTR lpstrName)
|
|
|
|
{
|
|
|
|
WCHAR buf[32];
|
|
|
|
UINT uDevType;
|
|
|
|
for (uDevType = MCI_DEVTYPE_FIRST; uDevType <= MCI_DEVTYPE_LAST; uDevType++) {
|
|
|
|
if (LoadStringW(hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
|
|
|
|
/* FIXME: ignore digits suffix */
|
|
|
|
if (!strcmpiW(buf, lpstrName))
|
|
|
|
return uDevType;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
#define MAX_MCICMDTABLE 20
|
|
|
|
#define MCI_COMMAND_TABLE_NOT_LOADED 0xFFFE
|
|
|
|
|
|
|
|
typedef struct tagWINE_MCICMDTABLE {
|
1999-09-22 18:43:18 +02:00
|
|
|
UINT uDevType;
|
2009-10-20 21:54:52 +02:00
|
|
|
HGLOBAL hMem;
|
2005-02-09 23:26:25 +01:00
|
|
|
const BYTE* lpTable;
|
1999-09-22 18:43:18 +02:00
|
|
|
UINT nVerbs; /* number of verbs in command table */
|
2005-02-09 23:26:25 +01:00
|
|
|
LPCWSTR* aVerbs; /* array of verbs to speed up the verb look up process */
|
1999-07-24 12:41:28 +02:00
|
|
|
} WINE_MCICMDTABLE, *LPWINE_MCICMDTABLE;
|
2003-04-30 19:28:45 +02:00
|
|
|
|
|
|
|
static WINE_MCICMDTABLE S_MciCmdTable[MAX_MCICMDTABLE];
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_IsCommandTableValid [internal]
|
|
|
|
*/
|
|
|
|
static BOOL MCI_IsCommandTableValid(UINT uTbl)
|
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
const BYTE* lmem;
|
|
|
|
LPCWSTR str;
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD flg;
|
|
|
|
WORD eid;
|
|
|
|
int idx = 0;
|
|
|
|
BOOL inCst = FALSE;
|
|
|
|
|
2003-04-30 19:28:45 +02:00
|
|
|
TRACE("Dumping cmdTbl=%d [lpTable=%p devType=%d]\n",
|
|
|
|
uTbl, S_MciCmdTable[uTbl].lpTable, S_MciCmdTable[uTbl].uDevType);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2003-04-30 19:28:45 +02:00
|
|
|
if (uTbl >= MAX_MCICMDTABLE || !S_MciCmdTable[uTbl].lpTable)
|
1999-07-24 12:41:28 +02:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
lmem = S_MciCmdTable[uTbl].lpTable;
|
|
|
|
do {
|
2005-02-09 23:26:25 +01:00
|
|
|
str = (LPCWSTR)lmem;
|
|
|
|
lmem += (strlenW(str) + 1) * sizeof(WCHAR);
|
|
|
|
flg = *(const DWORD*)lmem;
|
|
|
|
eid = *(const WORD*)(lmem + sizeof(DWORD));
|
|
|
|
lmem += sizeof(DWORD) + sizeof(WORD);
|
|
|
|
idx ++;
|
|
|
|
/* TRACE("cmd=%s %08lx %04x\n", debugstr_w(str), flg, eid); */
|
|
|
|
switch (eid) {
|
|
|
|
case MCI_COMMAND_HEAD: if (!*str || !flg) return FALSE; idx = 0; break; /* check unicity of str in table */
|
|
|
|
case MCI_STRING: if (inCst) return FALSE; break;
|
2010-03-24 19:58:38 +01:00
|
|
|
case MCI_HWND: /* Occurs inside MCI_CONSTANT as in "window handle default" */
|
|
|
|
case MCI_HPAL:
|
|
|
|
case MCI_HDC:
|
2005-02-09 23:26:25 +01:00
|
|
|
case MCI_INTEGER: if (!*str) return FALSE; break;
|
|
|
|
case MCI_END_COMMAND: if (*str || flg || idx == 0) return FALSE; idx = 0; break;
|
|
|
|
case MCI_RETURN: if (*str || idx != 1) return FALSE; break;
|
|
|
|
case MCI_FLAG: if (!*str) return FALSE; break;
|
|
|
|
case MCI_END_COMMAND_LIST: if (*str || flg) return FALSE; idx = 0; break;
|
|
|
|
case MCI_RECT: if (!*str || inCst) return FALSE; break;
|
|
|
|
case MCI_CONSTANT: if (inCst) return FALSE; inCst = TRUE; break;
|
|
|
|
case MCI_END_CONSTANT: if (*str || flg || !inCst) return FALSE; inCst = FALSE; break;
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
} while (eid != MCI_END_COMMAND_LIST);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_DumpCommandTable [internal]
|
|
|
|
*/
|
|
|
|
static BOOL MCI_DumpCommandTable(UINT uTbl)
|
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
const BYTE* lmem;
|
|
|
|
LPCWSTR str;
|
1999-07-24 12:41:28 +02:00
|
|
|
WORD eid;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if (!MCI_IsCommandTableValid(uTbl)) {
|
|
|
|
ERR("Ooops: %d is not valid\n", uTbl);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
lmem = S_MciCmdTable[uTbl].lpTable;
|
|
|
|
do {
|
|
|
|
do {
|
2011-02-18 04:03:01 +01:00
|
|
|
/* DWORD flg; */
|
2005-02-09 23:26:25 +01:00
|
|
|
str = (LPCWSTR)lmem;
|
|
|
|
lmem += (strlenW(str) + 1) * sizeof(WCHAR);
|
2011-02-18 04:03:01 +01:00
|
|
|
/* flg = *(const DWORD*)lmem; */
|
2004-11-30 22:38:57 +01:00
|
|
|
eid = *(const WORD*)(lmem + sizeof(DWORD));
|
2005-02-09 23:26:25 +01:00
|
|
|
/* TRACE("cmd=%s %08lx %04x\n", debugstr_w(str), flg, eid); */
|
1999-07-24 12:41:28 +02:00
|
|
|
lmem += sizeof(DWORD) + sizeof(WORD);
|
|
|
|
} while (eid != MCI_END_COMMAND && eid != MCI_END_COMMAND_LIST);
|
2005-02-09 23:26:25 +01:00
|
|
|
/* EPP TRACE(" => end of command%s\n", (eid == MCI_END_COMMAND_LIST) ? " list" : ""); */
|
1999-07-24 12:41:28 +02:00
|
|
|
} while (eid != MCI_END_COMMAND_LIST);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetCommandTable [internal]
|
|
|
|
*/
|
2002-10-25 21:00:12 +02:00
|
|
|
static UINT MCI_GetCommandTable(UINT uDevType)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
UINT uTbl;
|
2005-02-09 23:26:25 +01:00
|
|
|
WCHAR buf[32];
|
|
|
|
LPCWSTR str = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/* first look up existing for existing devType */
|
|
|
|
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
2003-04-30 19:28:45 +02:00
|
|
|
if (S_MciCmdTable[uTbl].lpTable && S_MciCmdTable[uTbl].uDevType == uDevType)
|
2002-06-01 01:06:46 +02:00
|
|
|
return uTbl;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* well try to load id */
|
|
|
|
if (uDevType >= MCI_DEVTYPE_FIRST && uDevType <= MCI_DEVTYPE_LAST) {
|
2007-06-07 17:50:28 +02:00
|
|
|
if (LoadStringW(hWinMM32Instance, uDevType, buf, sizeof(buf) / sizeof(WCHAR))) {
|
1999-07-24 12:41:28 +02:00
|
|
|
str = buf;
|
|
|
|
}
|
|
|
|
} else if (uDevType == 0) {
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR wszCore[] = {'C','O','R','E',0};
|
|
|
|
str = wszCore;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
uTbl = MCI_NO_COMMAND_TABLE;
|
|
|
|
if (str) {
|
2007-06-07 17:50:28 +02:00
|
|
|
HRSRC hRsrc = FindResourceW(hWinMM32Instance, str, (LPCWSTR)RT_RCDATA);
|
1999-07-24 12:41:28 +02:00
|
|
|
HANDLE hMem = 0;
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
if (hRsrc) hMem = LoadResource(hWinMM32Instance, hRsrc);
|
1999-07-24 12:41:28 +02:00
|
|
|
if (hMem) {
|
2009-10-20 21:54:52 +02:00
|
|
|
uTbl = MCI_SetCommandTable(hMem, uDevType);
|
1999-07-24 12:41:28 +02:00
|
|
|
} else {
|
2002-10-31 02:02:41 +01:00
|
|
|
WARN("No command table found in resource %p[%s]\n",
|
2007-06-07 17:50:28 +02:00
|
|
|
hWinMM32Instance, debugstr_w(str));
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
TRACE("=> %d\n", uTbl);
|
|
|
|
return uTbl;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_SetCommandTable [internal]
|
|
|
|
*/
|
2009-10-20 21:54:52 +02:00
|
|
|
static UINT MCI_SetCommandTable(HGLOBAL hMem, UINT uDevType)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
1999-07-24 12:41:28 +02:00
|
|
|
int uTbl;
|
|
|
|
static BOOL bInitDone = FALSE;
|
|
|
|
|
|
|
|
/* <HACK>
|
|
|
|
* The CORE command table must be loaded first, so that MCI_GetCommandTable()
|
|
|
|
* can be called with 0 as a uDevType to retrieve it.
|
|
|
|
* </HACK>
|
|
|
|
*/
|
|
|
|
if (!bInitDone) {
|
|
|
|
bInitDone = TRUE;
|
2002-10-25 21:00:12 +02:00
|
|
|
MCI_GetCommandTable(0);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2009-10-20 21:54:52 +02:00
|
|
|
TRACE("(%p, %u)\n", hMem, uDevType);
|
1999-07-24 12:41:28 +02:00
|
|
|
for (uTbl = 0; uTbl < MAX_MCICMDTABLE; uTbl++) {
|
2003-04-30 19:28:45 +02:00
|
|
|
if (!S_MciCmdTable[uTbl].lpTable) {
|
2005-02-09 23:26:25 +01:00
|
|
|
const BYTE* lmem;
|
|
|
|
LPCWSTR str;
|
1999-09-22 18:43:18 +02:00
|
|
|
WORD eid;
|
|
|
|
WORD count;
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
S_MciCmdTable[uTbl].uDevType = uDevType;
|
2009-10-20 21:54:52 +02:00
|
|
|
S_MciCmdTable[uTbl].lpTable = LockResource(hMem);
|
|
|
|
S_MciCmdTable[uTbl].hMem = hMem;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (TRACE_ON(mci)) {
|
|
|
|
MCI_DumpCommandTable(uTbl);
|
|
|
|
}
|
1999-09-22 18:43:18 +02:00
|
|
|
|
|
|
|
/* create the verbs table */
|
|
|
|
/* get # of entries */
|
|
|
|
lmem = S_MciCmdTable[uTbl].lpTable;
|
|
|
|
count = 0;
|
|
|
|
do {
|
2005-02-09 23:26:25 +01:00
|
|
|
str = (LPCWSTR)lmem;
|
|
|
|
lmem += (strlenW(str) + 1) * sizeof(WCHAR);
|
2004-11-30 22:38:57 +01:00
|
|
|
eid = *(const WORD*)(lmem + sizeof(DWORD));
|
1999-09-22 18:43:18 +02:00
|
|
|
lmem += sizeof(DWORD) + sizeof(WORD);
|
|
|
|
if (eid == MCI_COMMAND_HEAD)
|
|
|
|
count++;
|
|
|
|
} while (eid != MCI_END_COMMAND_LIST);
|
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
S_MciCmdTable[uTbl].aVerbs = HeapAlloc(GetProcessHeap(), 0, count * sizeof(LPCWSTR));
|
1999-09-22 18:43:18 +02:00
|
|
|
S_MciCmdTable[uTbl].nVerbs = count;
|
|
|
|
|
|
|
|
lmem = S_MciCmdTable[uTbl].lpTable;
|
|
|
|
count = 0;
|
|
|
|
do {
|
2005-02-09 23:26:25 +01:00
|
|
|
str = (LPCWSTR)lmem;
|
|
|
|
lmem += (strlenW(str) + 1) * sizeof(WCHAR);
|
2004-11-30 22:38:57 +01:00
|
|
|
eid = *(const WORD*)(lmem + sizeof(DWORD));
|
1999-09-22 18:43:18 +02:00
|
|
|
lmem += sizeof(DWORD) + sizeof(WORD);
|
|
|
|
if (eid == MCI_COMMAND_HEAD)
|
|
|
|
S_MciCmdTable[uTbl].aVerbs[count++] = str;
|
|
|
|
} while (eid != MCI_END_COMMAND_LIST);
|
|
|
|
/* assert(count == S_MciCmdTable[uTbl].nVerbs); */
|
1999-07-24 12:41:28 +02:00
|
|
|
return uTbl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return MCI_NO_COMMAND_TABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_UnLoadMciDriver [internal]
|
|
|
|
*/
|
2002-10-25 21:00:12 +02:00
|
|
|
static BOOL MCI_UnLoadMciDriver(LPWINE_MCIDRIVER wmd)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
1999-09-22 18:43:18 +02:00
|
|
|
LPWINE_MCIDRIVER* tmp;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (!wmd)
|
|
|
|
return TRUE;
|
|
|
|
|
2000-12-13 03:07:40 +01:00
|
|
|
CloseDriver(wmd->hDriver, 0, 0);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (wmd->dwPrivate != 0)
|
|
|
|
WARN("Unloading mci driver with non nul dwPrivate field\n");
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (tmp = &MciDrivers; *tmp; tmp = &(*tmp)->lpNext) {
|
1999-07-24 12:41:28 +02:00
|
|
|
if (*tmp == wmd) {
|
|
|
|
*tmp = wmd->lpNext;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wmd->lpstrDeviceType);
|
|
|
|
HeapFree(GetProcessHeap(), 0, wmd->lpstrAlias);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, wmd);
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2000-12-13 03:07:40 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_OpenMciDriver [internal]
|
|
|
|
*/
|
2005-09-12 12:52:38 +02:00
|
|
|
static BOOL MCI_OpenMciDriver(LPWINE_MCIDRIVER wmd, LPCWSTR drvTyp, DWORD_PTR lp)
|
2000-12-13 03:07:40 +01:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
WCHAR libName[128];
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!DRIVER_GetLibName(drvTyp, wszMci, libName, sizeof(libName)))
|
2000-12-13 03:07:40 +01:00
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* First load driver */
|
2009-10-22 22:11:07 +02:00
|
|
|
wmd->hDriver = (HDRVR)DRIVER_TryOpenDriver32(libName, lp);
|
|
|
|
return wmd->hDriver != NULL;
|
2000-12-13 03:07:40 +01:00
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_LoadMciDriver [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_LoadMciDriver(LPCWSTR _strDevTyp, LPWINE_MCIDRIVER* lpwmd)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR strDevTyp = str_dup_upper(_strDevTyp);
|
1999-07-24 12:41:28 +02:00
|
|
|
LPWINE_MCIDRIVER wmd = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*wmd));
|
2005-02-09 23:26:25 +01:00
|
|
|
MCI_OPEN_DRIVER_PARMSW modp;
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD dwRet = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if (!wmd || !strDevTyp) {
|
|
|
|
dwRet = MCIERR_OUT_OF_MEMORY;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-04-29 16:19:02 +02:00
|
|
|
wmd->lpfnYieldProc = MCI_DefYieldProc;
|
|
|
|
wmd->dwYieldData = VK_CANCEL;
|
2002-07-29 01:48:27 +02:00
|
|
|
wmd->CreatorThread = GetCurrentThreadId();
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
2008-01-03 18:04:28 +01:00
|
|
|
/* wmd must be inserted in list before sending opening the driver, because it
|
1999-07-24 12:41:28 +02:00
|
|
|
* may want to lookup at wDevID
|
|
|
|
*/
|
2007-06-07 17:50:28 +02:00
|
|
|
wmd->lpNext = MciDrivers;
|
|
|
|
MciDrivers = wmd;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
for (modp.wDeviceID = MCI_MAGIC;
|
|
|
|
MCI_GetDriver(modp.wDeviceID) != 0;
|
1999-07-24 12:41:28 +02:00
|
|
|
modp.wDeviceID++);
|
|
|
|
|
|
|
|
wmd->wDeviceID = modp.wDeviceID;
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("wDevID=%04X\n", modp.wDeviceID);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
modp.lpstrParams = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2005-09-12 12:52:38 +02:00
|
|
|
if (!MCI_OpenMciDriver(wmd, strDevTyp, (DWORD_PTR)&modp)) {
|
2001-08-15 19:40:03 +02:00
|
|
|
/* silence warning if all is used... some bogus program use commands like
|
|
|
|
* 'open all'...
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
if (strcmpiW(strDevTyp, wszAll) == 0) {
|
2001-08-15 19:40:03 +02:00
|
|
|
dwRet = MCIERR_CANNOT_USE_ALL;
|
|
|
|
} else {
|
2008-08-16 08:47:34 +02:00
|
|
|
FIXME("Couldn't load driver for type %s.\n",
|
2005-02-09 23:26:25 +01:00
|
|
|
debugstr_w(strDevTyp));
|
2001-08-15 19:40:03 +02:00
|
|
|
dwRet = MCIERR_DEVICE_NOT_INSTALLED;
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
goto errCleanUp;
|
2000-12-13 03:07:40 +01:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/* FIXME: should also check that module's description is of the form
|
|
|
|
* MODULENAME:[MCI] comment
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* some drivers will return 0x0000FFFF, some others 0xFFFFFFFF */
|
|
|
|
wmd->uSpecificCmdTable = LOWORD(modp.wCustomCommandTable);
|
|
|
|
wmd->uTypeCmdTable = MCI_COMMAND_TABLE_NOT_LOADED;
|
|
|
|
|
2002-10-31 02:02:41 +01:00
|
|
|
TRACE("Loaded driver %p (%s), type is %d, cmdTable=%08x\n",
|
2005-02-09 23:26:25 +01:00
|
|
|
wmd->hDriver, debugstr_w(strDevTyp), modp.wType, modp.wCustomCommandTable);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
wmd->lpstrDeviceType = strDevTyp;
|
|
|
|
wmd->wType = modp.wType;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
TRACE("mcidev=%d, uDevTyp=%04X wDeviceID=%04X !\n",
|
1999-07-24 12:41:28 +02:00
|
|
|
modp.wDeviceID, modp.wType, modp.wDeviceID);
|
|
|
|
*lpwmd = wmd;
|
|
|
|
return 0;
|
|
|
|
errCleanUp:
|
2002-10-25 21:00:12 +02:00
|
|
|
MCI_UnLoadMciDriver(wmd);
|
1999-07-24 12:41:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, strDevTyp);
|
|
|
|
*lpwmd = 0;
|
|
|
|
return dwRet;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-01-31 14:02:34 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_SendCommandFrom32 [internal]
|
|
|
|
*/
|
|
|
|
static DWORD MCI_SendCommandFrom32(MCIDEVICEID wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
|
|
|
{
|
|
|
|
DWORD dwRet = MCIERR_INVALID_DEVICE_ID;
|
|
|
|
LPWINE_MCIDRIVER wmd = MCI_GetDriver(wDevID);
|
|
|
|
|
|
|
|
if (wmd) {
|
2009-10-22 22:11:07 +02:00
|
|
|
dwRet = SendDriverMessage(wmd->hDriver, wMsg, dwParam1, dwParam2);
|
2009-01-31 14:02:34 +01:00
|
|
|
}
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_FinishOpen [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_FinishOpen(LPWINE_MCIDRIVER wmd, LPMCI_OPEN_PARMSW lpParms,
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD dwParam)
|
|
|
|
{
|
2010-09-01 17:50:43 +02:00
|
|
|
LPCWSTR alias = NULL;
|
|
|
|
/* Open always defines an alias for further reference */
|
2010-09-01 20:57:24 +02:00
|
|
|
if (dwParam & MCI_OPEN_ALIAS) { /* open ... alias */
|
2010-09-01 17:50:43 +02:00
|
|
|
alias = lpParms->lpstrAlias;
|
2010-09-01 20:57:24 +02:00
|
|
|
if (MCI_GetDriverFromString(alias))
|
|
|
|
return MCIERR_DUPLICATE_ALIAS;
|
|
|
|
} else {
|
2010-09-01 17:50:43 +02:00
|
|
|
if ((dwParam & MCI_OPEN_ELEMENT) /* open file.wav */
|
|
|
|
&& !(dwParam & MCI_OPEN_ELEMENT_ID))
|
|
|
|
alias = lpParms->lpstrElementName;
|
|
|
|
else if (dwParam & MCI_OPEN_TYPE ) /* open cdaudio */
|
|
|
|
alias = wmd->lpstrDeviceType;
|
2010-09-01 20:57:24 +02:00
|
|
|
if (alias && MCI_GetDriverFromString(alias))
|
|
|
|
return MCIERR_DEVICE_OPEN;
|
2001-07-24 23:45:22 +02:00
|
|
|
}
|
2010-09-01 17:50:43 +02:00
|
|
|
if (alias) {
|
|
|
|
wmd->lpstrAlias = HeapAlloc(GetProcessHeap(), 0, (strlenW(alias)+1) * sizeof(WCHAR));
|
|
|
|
if (!wmd->lpstrAlias) return MCIERR_OUT_OF_MEMORY;
|
|
|
|
strcpyW( wmd->lpstrAlias, alias);
|
|
|
|
/* In most cases, natives adds MCI_OPEN_ALIAS to the flags passed to the driver.
|
|
|
|
* Don't. The drivers don't care about the winmm alias. */
|
2001-07-24 23:45:22 +02:00
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
lpParms->wDeviceID = wmd->wDeviceID;
|
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
return MCI_SendCommandFrom32(wmd->wDeviceID, MCI_OPEN_DRIVER, dwParam,
|
2009-05-20 17:50:54 +02:00
|
|
|
(DWORD_PTR)lpParms);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_FindCommand [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static LPCWSTR MCI_FindCommand(UINT uTbl, LPCWSTR verb)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
1999-09-22 18:43:18 +02:00
|
|
|
UINT idx;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2003-04-30 19:28:45 +02:00
|
|
|
if (uTbl >= MAX_MCICMDTABLE || !S_MciCmdTable[uTbl].lpTable)
|
1999-07-24 12:41:28 +02:00
|
|
|
return NULL;
|
|
|
|
|
1999-09-22 18:43:18 +02:00
|
|
|
/* another improvement would be to have the aVerbs array sorted,
|
|
|
|
* so that we could use a dichotomic search on it, rather than this dumb
|
|
|
|
* array look up
|
|
|
|
*/
|
|
|
|
for (idx = 0; idx < S_MciCmdTable[uTbl].nVerbs; idx++) {
|
2005-02-09 23:26:25 +01:00
|
|
|
if (strcmpiW(S_MciCmdTable[uTbl].aVerbs[idx], verb) == 0)
|
1999-09-22 18:43:18 +02:00
|
|
|
return S_MciCmdTable[uTbl].aVerbs[idx];
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetReturnType [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_GetReturnType(LPCWSTR lpCmd)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2006-11-22 17:14:45 +01:00
|
|
|
lpCmd = (LPCWSTR)((const BYTE*)(lpCmd + strlenW(lpCmd) + 1) + sizeof(DWORD) + sizeof(WORD));
|
|
|
|
if (*lpCmd == '\0' && *(const WORD*)((const BYTE*)(lpCmd + 1) + sizeof(DWORD)) == MCI_RETURN) {
|
2004-11-30 22:38:57 +01:00
|
|
|
return *(const DWORD*)(lpCmd + 1);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetMessage [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static WORD MCI_GetMessage(LPCWSTR lpCmd)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
return (WORD)*(const DWORD*)(lpCmd + strlenW(lpCmd) + 1);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetDWord [internal]
|
|
|
|
*/
|
2010-09-29 14:47:55 +02:00
|
|
|
static BOOL MCI_GetDWord(DWORD* data, LPWSTR* ptr)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
DWORD val;
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR ret;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2011-02-23 10:07:42 +01:00
|
|
|
val = strtoulW(*ptr, &ret, 10);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
switch (*ret) {
|
|
|
|
case '\0': break;
|
|
|
|
case ' ': ret++; break;
|
|
|
|
default: return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*data |= val;
|
|
|
|
*ptr = ret;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_GetString [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_GetString(LPWSTR* str, LPWSTR* args)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR ptr = *args;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
/* see if we have a quoted string */
|
|
|
|
if (*ptr == '"') {
|
2005-02-09 23:26:25 +01:00
|
|
|
ptr = strchrW(*str = ptr + 1, '"');
|
1999-07-24 12:41:28 +02:00
|
|
|
if (!ptr) return MCIERR_NO_CLOSING_QUOTE;
|
|
|
|
/* FIXME: shall we escape \" from string ?? */
|
|
|
|
if (ptr[-1] == '\\') TRACE("Ooops: un-escaped \"\n");
|
|
|
|
*ptr++ = '\0'; /* remove trailing " */
|
|
|
|
if (*ptr != ' ' && *ptr != '\0') return MCIERR_EXTRA_CHARACTERS;
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
ptr = strchrW(ptr, ' ');
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (ptr) {
|
|
|
|
*ptr++ = '\0';
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
ptr = *args + strlenW(*args);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
*str = *args;
|
|
|
|
}
|
|
|
|
|
|
|
|
*args = ptr;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MCI_DATA_SIZE 16
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_ParseOptArgs [internal]
|
|
|
|
*/
|
2010-09-29 14:47:55 +02:00
|
|
|
static DWORD MCI_ParseOptArgs(DWORD* data, int _offset, LPCWSTR lpCmd,
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR args, LPDWORD dwFlags)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
int len, offset;
|
2005-02-09 23:26:25 +01:00
|
|
|
const char* lmem;
|
|
|
|
LPCWSTR str;
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD dwRet, flg, cflg = 0;
|
|
|
|
WORD eid;
|
|
|
|
BOOL inCst, found;
|
|
|
|
|
|
|
|
/* loop on arguments */
|
|
|
|
while (*args) {
|
2005-02-09 23:26:25 +01:00
|
|
|
lmem = (const char*)lpCmd;
|
1999-07-24 12:41:28 +02:00
|
|
|
found = inCst = FALSE;
|
|
|
|
offset = _offset;
|
2001-01-29 00:11:27 +01:00
|
|
|
|
|
|
|
/* skip any leading white space(s) */
|
|
|
|
while (*args == ' ') args++;
|
2010-04-13 23:26:37 +02:00
|
|
|
TRACE("args=%s\n", debugstr_w(args));
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
do { /* loop on options for command table for the requested verb */
|
2005-02-09 23:26:25 +01:00
|
|
|
str = (LPCWSTR)lmem;
|
|
|
|
lmem += ((len = strlenW(str)) + 1) * sizeof(WCHAR);
|
2004-11-30 22:38:57 +01:00
|
|
|
flg = *(const DWORD*)lmem;
|
|
|
|
eid = *(const WORD*)(lmem + sizeof(DWORD));
|
1999-07-24 12:41:28 +02:00
|
|
|
lmem += sizeof(DWORD) + sizeof(WORD);
|
2005-02-09 23:26:25 +01:00
|
|
|
/* TRACE("\tcmd=%s inCst=%c eid=%04x\n", debugstr_w(str), inCst ? 'Y' : 'N', eid); */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
switch (eid) {
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_CONSTANT:
|
1999-07-24 12:41:28 +02:00
|
|
|
inCst = TRUE; cflg = flg; break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_END_CONSTANT:
|
1999-07-24 12:41:28 +02:00
|
|
|
/* there may be additional integral values after flag in constant */
|
|
|
|
if (inCst && MCI_GetDWord(&(data[offset]), &args)) {
|
|
|
|
*dwFlags |= cflg;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
inCst = FALSE; cflg = 0;
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
2010-04-13 23:26:37 +02:00
|
|
|
case MCI_RETURN:
|
|
|
|
if (offset != _offset) {
|
|
|
|
ERR("MCI_RETURN not in first position\n");
|
|
|
|
return MCIERR_PARSER_INTERNAL;
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
if (strncmpiW(args, str, len) == 0 &&
|
2005-11-29 11:24:55 +01:00
|
|
|
((eid == MCI_STRING && len == 0) || args[len] == 0 || args[len] == ' ')) {
|
1999-07-24 12:41:28 +02:00
|
|
|
/* store good values into data[] */
|
|
|
|
args += len;
|
2001-01-29 00:11:27 +01:00
|
|
|
while (*args == ' ') args++;
|
1999-07-24 12:41:28 +02:00
|
|
|
found = TRUE;
|
|
|
|
|
|
|
|
switch (eid) {
|
|
|
|
case MCI_COMMAND_HEAD:
|
|
|
|
case MCI_RETURN:
|
|
|
|
case MCI_END_COMMAND:
|
|
|
|
case MCI_END_COMMAND_LIST:
|
|
|
|
case MCI_CONSTANT: /* done above */
|
|
|
|
case MCI_END_CONSTANT: /* done above */
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_FLAG:
|
1999-07-24 12:41:28 +02:00
|
|
|
*dwFlags |= flg;
|
2010-04-13 23:26:37 +02:00
|
|
|
TRACE("flag=%08x\n", flg);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
2010-03-24 19:58:38 +01:00
|
|
|
case MCI_HWND:
|
|
|
|
case MCI_HPAL:
|
|
|
|
case MCI_HDC:
|
1999-07-24 12:41:28 +02:00
|
|
|
case MCI_INTEGER:
|
|
|
|
if (inCst) {
|
|
|
|
data[offset] |= flg;
|
|
|
|
*dwFlags |= cflg;
|
|
|
|
inCst = FALSE;
|
2010-04-13 23:26:37 +02:00
|
|
|
TRACE("flag=%08x constant=%08x\n", cflg, flg);
|
1999-07-24 12:41:28 +02:00
|
|
|
} else {
|
|
|
|
*dwFlags |= flg;
|
|
|
|
if (!MCI_GetDWord(&(data[offset]), &args)) {
|
|
|
|
return MCIERR_BAD_INTEGER;
|
|
|
|
}
|
2010-09-29 14:47:55 +02:00
|
|
|
TRACE("flag=%08x int=%d\n", flg, data[offset]);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_RECT:
|
2008-11-25 17:42:38 +01:00
|
|
|
/* store rect in data (offset..offset+3) */
|
1999-07-24 12:41:28 +02:00
|
|
|
*dwFlags |= flg;
|
|
|
|
if (!MCI_GetDWord(&(data[offset+0]), &args) ||
|
|
|
|
!MCI_GetDWord(&(data[offset+1]), &args) ||
|
|
|
|
!MCI_GetDWord(&(data[offset+2]), &args) ||
|
|
|
|
!MCI_GetDWord(&(data[offset+3]), &args)) {
|
2005-02-09 23:26:25 +01:00
|
|
|
ERR("Bad rect %s\n", debugstr_w(args));
|
1999-07-24 12:41:28 +02:00
|
|
|
return MCIERR_BAD_INTEGER;
|
|
|
|
}
|
2010-04-13 23:26:37 +02:00
|
|
|
TRACE("flag=%08x for rectangle\n", flg);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_STRING:
|
|
|
|
*dwFlags |= flg;
|
2005-02-09 23:26:25 +01:00
|
|
|
if ((dwRet = MCI_GetString((LPWSTR*)&data[offset], &args)))
|
1999-07-24 12:41:28 +02:00
|
|
|
return dwRet;
|
2010-09-29 14:47:55 +02:00
|
|
|
TRACE("flag=%08x string=%s\n", flg, debugstr_w(*(LPWSTR*)&data[offset]));
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
2001-05-09 19:31:31 +02:00
|
|
|
default: ERR("oops\n");
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2001-01-29 00:11:27 +01:00
|
|
|
/* exit inside while loop, except if just entered in constant area definition */
|
|
|
|
if (!inCst || eid != MCI_CONSTANT) eid = MCI_END_COMMAND;
|
1999-07-24 12:41:28 +02:00
|
|
|
} else {
|
|
|
|
/* have offset incremented if needed */
|
|
|
|
switch (eid) {
|
|
|
|
case MCI_COMMAND_HEAD:
|
|
|
|
case MCI_RETURN:
|
|
|
|
case MCI_END_COMMAND:
|
|
|
|
case MCI_END_COMMAND_LIST:
|
|
|
|
case MCI_CONSTANT:
|
|
|
|
case MCI_FLAG: break;
|
2010-03-24 19:58:38 +01:00
|
|
|
case MCI_HWND:
|
|
|
|
case MCI_HPAL:
|
|
|
|
case MCI_HDC: if (!inCst) offset += sizeof(HANDLE)/sizeof(DWORD); break;
|
1999-07-24 12:41:28 +02:00
|
|
|
case MCI_INTEGER: if (!inCst) offset++; break;
|
2010-09-29 14:47:55 +02:00
|
|
|
case MCI_END_CONSTANT: offset++; break;
|
|
|
|
case MCI_STRING: offset += sizeof(LPWSTR)/sizeof(DWORD); break;
|
1999-07-24 12:41:28 +02:00
|
|
|
case MCI_RECT: offset += 4; break;
|
2001-05-09 19:31:31 +02:00
|
|
|
default: ERR("oops\n");
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
} while (eid != MCI_END_COMMAND);
|
|
|
|
if (!found) {
|
2005-02-09 23:26:25 +01:00
|
|
|
WARN("Optarg %s not found\n", debugstr_w(args));
|
1999-07-24 12:41:28 +02:00
|
|
|
return MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
}
|
|
|
|
if (offset == MCI_DATA_SIZE) {
|
|
|
|
ERR("Internal data[] buffer overflow\n");
|
|
|
|
return MCIERR_PARSER_INTERNAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_HandleReturnValues [internal]
|
|
|
|
*/
|
2010-01-23 18:56:50 +01:00
|
|
|
static DWORD MCI_HandleReturnValues(DWORD dwRet, LPWINE_MCIDRIVER wmd, DWORD retType,
|
2010-09-29 14:47:55 +02:00
|
|
|
MCI_GENERIC_PARMS *params, LPWSTR lpstrRet, UINT uRetLen)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2010-09-29 14:47:55 +02:00
|
|
|
static const WCHAR fmt_d [] = {'%','d',0};
|
|
|
|
static const WCHAR fmt_d4 [] = {'%','d',' ','%','d',' ','%','d',' ','%','d',0};
|
2009-10-18 17:40:41 +02:00
|
|
|
static const WCHAR wszCol3[] = {'%','0','2','d',':','%','0','2','d',':','%','0','2','d',0};
|
|
|
|
static const WCHAR wszCol4[] = {'%','0','2','d',':','%','0','2','d',':','%','0','2','d',':','%','0','2','d',0};
|
2005-02-09 23:26:25 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if (lpstrRet) {
|
2002-10-28 21:05:25 +01:00
|
|
|
switch (retType) {
|
1999-07-24 12:41:28 +02:00
|
|
|
case 0: /* nothing to return */
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_INTEGER:
|
2010-09-29 14:47:55 +02:00
|
|
|
{
|
|
|
|
DWORD data = *(DWORD *)(params + 1);
|
1999-07-24 12:41:28 +02:00
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
|
|
|
case MCI_INTEGER_RETURNED:
|
2010-09-29 14:47:55 +02:00
|
|
|
snprintfW(lpstrRet, uRetLen, fmt_d, data);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED:
|
2010-09-29 14:47:55 +02:00
|
|
|
/* return string which ID is HIWORD(data),
|
1999-07-24 12:41:28 +02:00
|
|
|
* string is loaded from mmsystem.dll */
|
2010-09-29 14:47:55 +02:00
|
|
|
LoadStringW(hWinMM32Instance, HIWORD(data), lpstrRet, uRetLen);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
2010-09-29 14:47:55 +02:00
|
|
|
/* return string which ID is HIWORD(data),
|
1999-07-24 12:41:28 +02:00
|
|
|
* string is loaded from driver */
|
2000-12-13 03:07:40 +01:00
|
|
|
/* FIXME: this is wrong for a 16 bit handle */
|
2005-02-09 23:26:25 +01:00
|
|
|
LoadStringW(GetDriverModuleHandle(wmd->hDriver),
|
2010-09-29 14:47:55 +02:00
|
|
|
HIWORD(data), lpstrRet, uRetLen);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_COLONIZED3_RETURN:
|
2005-02-09 23:26:25 +01:00
|
|
|
snprintfW(lpstrRet, uRetLen, wszCol3,
|
2010-09-29 14:47:55 +02:00
|
|
|
LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
|
|
|
|
LOBYTE(HIWORD(data)));
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_COLONIZED4_RETURN:
|
2005-02-09 23:26:25 +01:00
|
|
|
snprintfW(lpstrRet, uRetLen, wszCol4,
|
2010-09-29 14:47:55 +02:00
|
|
|
LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
|
|
|
|
LOBYTE(HIWORD(data)), HIBYTE(HIWORD(data)));
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
default: ERR("Ooops (%04X)\n", HIWORD(dwRet));
|
|
|
|
}
|
|
|
|
break;
|
2010-09-29 14:47:55 +02:00
|
|
|
}
|
2010-09-29 14:49:48 +02:00
|
|
|
#ifdef MCI_INTEGER64
|
|
|
|
case MCI_INTEGER64:
|
|
|
|
{
|
|
|
|
static const WCHAR fmt_ld [] = {'%','l','d',0};
|
|
|
|
DWORD_PTR data = *(DWORD_PTR *)(params + 1);
|
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
|
|
|
case MCI_INTEGER_RETURNED:
|
|
|
|
snprintfW(lpstrRet, uRetLen, fmt_ld, data);
|
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED:
|
|
|
|
/* return string which ID is HIWORD(data),
|
|
|
|
* string is loaded from mmsystem.dll */
|
|
|
|
LoadStringW(hWinMM32Instance, HIWORD(data), lpstrRet, uRetLen);
|
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
|
|
|
/* return string which ID is HIWORD(data),
|
|
|
|
* string is loaded from driver */
|
|
|
|
/* FIXME: this is wrong for a 16 bit handle */
|
|
|
|
LoadStringW(GetDriverModuleHandle(wmd->hDriver),
|
|
|
|
HIWORD(data), lpstrRet, uRetLen);
|
|
|
|
break;
|
|
|
|
case MCI_COLONIZED3_RETURN:
|
|
|
|
snprintfW(lpstrRet, uRetLen, wszCol3,
|
|
|
|
LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
|
|
|
|
LOBYTE(HIWORD(data)));
|
|
|
|
break;
|
|
|
|
case MCI_COLONIZED4_RETURN:
|
|
|
|
snprintfW(lpstrRet, uRetLen, wszCol4,
|
|
|
|
LOBYTE(LOWORD(data)), HIBYTE(LOWORD(data)),
|
|
|
|
LOBYTE(HIWORD(data)), HIBYTE(HIWORD(data)));
|
|
|
|
break;
|
|
|
|
default: ERR("Ooops (%04X)\n", HIWORD(dwRet));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_STRING:
|
1999-07-24 12:41:28 +02:00
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
2010-09-29 14:47:55 +02:00
|
|
|
/* nothing to do data[0] == lpstrRet */
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_INTEGER_RETURNED:
|
2010-09-29 14:47:55 +02:00
|
|
|
{
|
|
|
|
DWORD *data = (DWORD *)(params + 1);
|
|
|
|
*data = *(LPDWORD)lpstrRet;
|
|
|
|
snprintfW(lpstrRet, uRetLen, fmt_d, *data);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
2010-09-29 14:47:55 +02:00
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
default:
|
|
|
|
WARN("Oooch. MCI_STRING and HIWORD(dwRet)=%04x\n", HIWORD(dwRet));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
case MCI_RECT:
|
2010-09-29 14:47:55 +02:00
|
|
|
{
|
|
|
|
DWORD *data = (DWORD *)(params + 1);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (dwRet & 0xFFFF0000ul)
|
1999-07-24 12:41:28 +02:00
|
|
|
WARN("Oooch. MCI_STRING and HIWORD(dwRet)=%04x\n", HIWORD(dwRet));
|
2010-09-29 14:47:55 +02:00
|
|
|
snprintfW(lpstrRet, uRetLen, fmt_d4, data[0], data[1], data[2], data[3]);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
2010-09-29 14:47:55 +02:00
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
default: ERR("oops\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return LOWORD(dwRet);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-09 23:26:25 +01:00
|
|
|
* mciSendStringW [WINMM.@]
|
1999-07-24 12:41:28 +02:00
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
DWORD WINAPI mciSendStringW(LPCWSTR lpstrCommand, LPWSTR lpstrRet,
|
1999-07-24 12:41:28 +02:00
|
|
|
UINT uRetLen, HWND hwndCallback)
|
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR verb, dev, args;
|
1999-07-24 12:41:28 +02:00
|
|
|
LPWINE_MCIDRIVER wmd = 0;
|
2010-08-25 07:32:28 +02:00
|
|
|
MCIDEVICEID uDevID, auto_open = 0;
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD dwFlags = 0, dwRet = 0;
|
|
|
|
int offset = 0;
|
2002-10-28 21:05:25 +01:00
|
|
|
DWORD retType;
|
2005-02-09 23:26:25 +01:00
|
|
|
LPCWSTR lpCmd = 0;
|
2010-08-25 07:32:28 +02:00
|
|
|
WORD wMsg = 0;
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR wszNew[] = {'n','e','w',0};
|
|
|
|
static const WCHAR wszSAliasS[] = {' ','a','l','i','a','s',' ',0};
|
2010-03-28 20:34:03 +02:00
|
|
|
static const WCHAR wszTypeS[] = {'t','y','p','e',' ',0};
|
2010-09-29 14:47:55 +02:00
|
|
|
union
|
|
|
|
{
|
|
|
|
MCI_GENERIC_PARMS generic;
|
|
|
|
MCI_OPEN_PARMSW open;
|
|
|
|
MCI_SOUND_PARMSW sound;
|
|
|
|
MCI_SYSINFO_PARMSW sysinfo;
|
|
|
|
DWORD dw[MCI_DATA_SIZE];
|
|
|
|
} data;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("(%s, %p, %d, %p)\n",
|
|
|
|
debugstr_w(lpstrCommand), lpstrRet, uRetLen, hwndCallback);
|
2010-08-25 07:32:28 +02:00
|
|
|
if (lpstrRet && uRetLen) *lpstrRet = '\0';
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
/* format is <command> <device> <optargs> */
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!(verb = HeapAlloc(GetProcessHeap(), 0, (strlenW(lpstrCommand)+1) * sizeof(WCHAR))))
|
1999-07-24 12:41:28 +02:00
|
|
|
return MCIERR_OUT_OF_MEMORY;
|
2005-02-09 23:26:25 +01:00
|
|
|
strcpyW( verb, lpstrCommand );
|
|
|
|
CharLowerW(verb);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2010-09-29 14:47:55 +02:00
|
|
|
memset(&data, 0, sizeof(data));
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!(args = strchrW(verb, ' '))) {
|
1999-07-24 12:41:28 +02:00
|
|
|
dwRet = MCIERR_MISSING_DEVICE_NAME;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
*args++ = '\0';
|
|
|
|
if ((dwRet = MCI_GetString(&dev, &args))) {
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2010-03-31 16:08:48 +02:00
|
|
|
uDevID = strcmpiW(dev, wszAll) ? 0 : MCI_ALL_DEVICE_ID;
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2006-06-12 16:19:06 +02:00
|
|
|
/* Determine devType from open */
|
2005-02-09 23:26:25 +01:00
|
|
|
if (!strcmpW(verb, wszOpen)) {
|
|
|
|
LPWSTR devType, tmp;
|
2006-06-25 16:04:19 +02:00
|
|
|
WCHAR buf[128];
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2006-06-12 16:19:06 +02:00
|
|
|
/* case dev == 'new' has to be handled */
|
|
|
|
if (!strcmpW(dev, wszNew)) {
|
|
|
|
dev = 0;
|
|
|
|
if ((devType = strstrW(args, wszTypeS)) != NULL) {
|
|
|
|
devType += 5;
|
|
|
|
tmp = strchrW(devType, ' ');
|
|
|
|
if (tmp) *tmp = '\0';
|
|
|
|
devType = str_dup_upper(devType);
|
|
|
|
if (tmp) *tmp = ' ';
|
|
|
|
/* dwFlags and data[2] will be correctly set in ParseOpt loop */
|
|
|
|
} else {
|
|
|
|
WARN("open new requires device type\n");
|
|
|
|
dwRet = MCIERR_MISSING_DEVICE_NAME;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
} else if ((devType = strchrW(dev, '!')) != NULL) {
|
2002-06-01 01:06:46 +02:00
|
|
|
*devType++ = '\0';
|
1999-07-24 12:41:28 +02:00
|
|
|
tmp = devType; devType = dev; dev = tmp;
|
|
|
|
|
|
|
|
dwFlags |= MCI_OPEN_TYPE;
|
2010-09-29 14:47:55 +02:00
|
|
|
data.open.lpstrDeviceType = devType;
|
2001-07-24 23:45:22 +02:00
|
|
|
devType = str_dup_upper(devType);
|
2001-01-29 00:11:27 +01:00
|
|
|
dwFlags |= MCI_OPEN_ELEMENT;
|
2010-09-29 14:47:55 +02:00
|
|
|
data.open.lpstrElementName = dev;
|
2006-06-25 16:04:19 +02:00
|
|
|
} else if (DRIVER_GetLibName(dev, wszMci, buf, sizeof(buf))) {
|
|
|
|
/* this is the name of a mci driver's type */
|
|
|
|
tmp = strchrW(dev, ' ');
|
2000-07-08 14:43:09 +02:00
|
|
|
if (tmp) *tmp = '\0';
|
2010-09-29 14:47:55 +02:00
|
|
|
data.open.lpstrDeviceType = dev;
|
2001-07-24 23:45:22 +02:00
|
|
|
devType = str_dup_upper(dev);
|
2000-07-08 14:43:09 +02:00
|
|
|
if (tmp) *tmp = ' ';
|
|
|
|
dwFlags |= MCI_OPEN_TYPE;
|
1999-07-24 12:41:28 +02:00
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
if ((devType = strstrW(args, wszTypeS)) != NULL) {
|
1999-07-24 12:41:28 +02:00
|
|
|
devType += 5;
|
2005-02-09 23:26:25 +01:00
|
|
|
tmp = strchrW(devType, ' ');
|
1999-07-24 12:41:28 +02:00
|
|
|
if (tmp) *tmp = '\0';
|
2001-07-24 23:45:22 +02:00
|
|
|
devType = str_dup_upper(devType);
|
1999-07-24 12:41:28 +02:00
|
|
|
if (tmp) *tmp = ' ';
|
2010-09-29 14:47:55 +02:00
|
|
|
/* dwFlags and lpstrDeviceType will be correctly set in ParseOpt loop */
|
1999-07-24 12:41:28 +02:00
|
|
|
} else {
|
|
|
|
if ((dwRet = MCI_GetDevTypeFromFileName(dev, buf, sizeof(buf))))
|
|
|
|
goto errCleanUp;
|
|
|
|
|
2001-07-24 23:45:22 +02:00
|
|
|
devType = str_dup_upper(buf);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
dwFlags |= MCI_OPEN_ELEMENT;
|
2010-09-29 14:47:55 +02:00
|
|
|
data.open.lpstrElementName = dev;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2010-03-31 16:08:48 +02:00
|
|
|
if (MCI_ALL_DEVICE_ID == uDevID) {
|
|
|
|
dwRet = MCIERR_CANNOT_USE_ALL;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2009-10-25 20:18:41 +01:00
|
|
|
if (!strstrW(args, wszSAliasS) && !dev) {
|
2006-06-12 16:19:06 +02:00
|
|
|
dwRet = MCIERR_NEW_REQUIRES_ALIAS;
|
|
|
|
goto errCleanUp;
|
2000-12-16 21:17:04 +01:00
|
|
|
}
|
|
|
|
|
2002-10-25 21:00:12 +02:00
|
|
|
dwRet = MCI_LoadMciDriver(devType, &wmd);
|
2004-03-16 02:14:27 +01:00
|
|
|
if (dwRet == MCIERR_DEVICE_NOT_INSTALLED)
|
|
|
|
dwRet = MCIERR_INVALID_DEVICE_NAME;
|
1999-07-24 12:41:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, devType);
|
2010-08-30 19:43:26 +02:00
|
|
|
if (dwRet)
|
1999-07-24 12:41:28 +02:00
|
|
|
goto errCleanUp;
|
2010-09-14 20:45:16 +02:00
|
|
|
} else if ((MCI_ALL_DEVICE_ID != uDevID) && !(wmd = MCI_GetDriver(mciGetDeviceIDW(dev)))
|
|
|
|
&& (lpCmd = MCI_FindCommand(MCI_GetCommandTable(0), verb))) {
|
|
|
|
/* auto-open uses the core command table */
|
|
|
|
switch (MCI_GetMessage(lpCmd)) {
|
|
|
|
case MCI_SOUND: /* command does not use a device name */
|
|
|
|
case MCI_SYSINFO:
|
|
|
|
break;
|
|
|
|
case MCI_CLOSE: /* don't auto-open for close */
|
|
|
|
case MCI_BREAK: /* no auto-open for system commands */
|
|
|
|
dwRet = MCIERR_INVALID_DEVICE_NAME;
|
1999-08-18 20:26:58 +02:00
|
|
|
goto errCleanUp;
|
2010-09-14 20:45:16 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
static const WCHAR wszOpenWait[] = {'o','p','e','n',' ','%','s',' ','w','a','i','t',0};
|
|
|
|
WCHAR buf[138], retbuf[6];
|
|
|
|
snprintfW(buf, sizeof(buf)/sizeof(WCHAR), wszOpenWait, dev);
|
|
|
|
/* open via mciSendString handles quoting, dev!file syntax and alias creation */
|
|
|
|
if ((dwRet = mciSendStringW(buf, retbuf, sizeof(retbuf)/sizeof(WCHAR), 0)) != 0)
|
|
|
|
goto errCleanUp;
|
|
|
|
auto_open = strtoulW(retbuf, NULL, 10);
|
|
|
|
TRACE("auto-opened %u for %s\n", auto_open, debugstr_w(dev));
|
|
|
|
|
|
|
|
/* FIXME: test for notify flag (how to preparse?) before opening */
|
|
|
|
wmd = MCI_GetDriver(auto_open);
|
|
|
|
if (!wmd) {
|
|
|
|
ERR("No auto-open device %u\n", auto_open);
|
|
|
|
dwRet = MCIERR_INVALID_DEVICE_ID;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
}
|
1999-08-18 20:26:58 +02:00
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* get the verb in the different command tables */
|
2001-01-29 00:11:27 +01:00
|
|
|
if (wmd) {
|
|
|
|
/* try the device specific command table */
|
|
|
|
lpCmd = MCI_FindCommand(wmd->uSpecificCmdTable, verb);
|
|
|
|
if (!lpCmd) {
|
|
|
|
/* try the type specific command table */
|
|
|
|
if (wmd->uTypeCmdTable == MCI_COMMAND_TABLE_NOT_LOADED)
|
2002-10-25 21:00:12 +02:00
|
|
|
wmd->uTypeCmdTable = MCI_GetCommandTable(wmd->wType);
|
2001-01-29 00:11:27 +01:00
|
|
|
if (wmd->uTypeCmdTable != MCI_NO_COMMAND_TABLE)
|
|
|
|
lpCmd = MCI_FindCommand(wmd->uTypeCmdTable, verb);
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
/* try core command table */
|
2002-10-25 21:00:12 +02:00
|
|
|
if (!lpCmd) lpCmd = MCI_FindCommand(MCI_GetCommandTable(0), verb);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (!lpCmd) {
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("Command %s not found!\n", debugstr_w(verb));
|
1999-07-24 12:41:28 +02:00
|
|
|
dwRet = MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2010-08-25 07:32:28 +02:00
|
|
|
wMsg = MCI_GetMessage(lpCmd);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
/* set return information */
|
2010-09-29 14:47:55 +02:00
|
|
|
offset = sizeof(data.generic);
|
2002-10-28 21:05:25 +01:00
|
|
|
switch (retType = MCI_GetReturnType(lpCmd)) {
|
2010-09-29 14:47:55 +02:00
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
case MCI_INTEGER:
|
|
|
|
offset += sizeof(DWORD);
|
|
|
|
break;
|
|
|
|
case MCI_STRING:
|
|
|
|
data.sysinfo.lpstrReturn = lpstrRet;
|
|
|
|
data.sysinfo.dwRetSize = uRetLen;
|
|
|
|
offset = FIELD_OFFSET( MCI_SYSINFO_PARMSW, dwNumber );
|
|
|
|
break;
|
|
|
|
case MCI_RECT:
|
|
|
|
offset += 4 * sizeof(DWORD);
|
|
|
|
break;
|
2010-09-29 14:49:48 +02:00
|
|
|
#ifdef MCI_INTEGER64
|
|
|
|
case MCI_INTEGER64:
|
|
|
|
offset += sizeof(DWORD_PTR);
|
|
|
|
break;
|
|
|
|
#endif
|
2010-09-29 14:47:55 +02:00
|
|
|
default:
|
|
|
|
ERR("oops\n");
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("verb=%s on dev=%s; offset=%d\n",
|
|
|
|
debugstr_w(verb), debugstr_w(dev), offset);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2010-09-29 14:47:55 +02:00
|
|
|
if ((dwRet = MCI_ParseOptArgs(data.dw, offset / sizeof(DWORD), lpCmd, args, &dwFlags)))
|
1999-07-24 12:41:28 +02:00
|
|
|
goto errCleanUp;
|
|
|
|
|
2009-10-13 08:00:03 +02:00
|
|
|
/* set up call back */
|
2010-08-25 07:32:28 +02:00
|
|
|
if (auto_open) {
|
|
|
|
if (dwFlags & MCI_NOTIFY) {
|
|
|
|
dwRet = MCIERR_NOTIFY_ON_AUTO_OPEN;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
/* FIXME: the command should get its own notification window set up and
|
|
|
|
* ask for device closing while processing the notification mechanism.
|
|
|
|
* hwndCallback = ...
|
|
|
|
* dwFlags |= MCI_NOTIFY;
|
|
|
|
* In the meantime special-case all commands but PLAY and RECORD below. */
|
|
|
|
}
|
2009-10-13 08:00:03 +02:00
|
|
|
if (dwFlags & MCI_NOTIFY) {
|
2010-09-29 14:47:55 +02:00
|
|
|
data.generic.dwCallback = (DWORD_PTR)hwndCallback;
|
2009-10-13 08:00:03 +02:00
|
|
|
}
|
|
|
|
|
2010-09-03 06:33:52 +02:00
|
|
|
switch (wMsg) {
|
|
|
|
case MCI_OPEN:
|
|
|
|
if (strcmpW(verb, wszOpen)) {
|
|
|
|
FIXME("Cannot open with command %s\n", debugstr_w(verb));
|
|
|
|
dwRet = MCIERR_INTERNAL;
|
|
|
|
wMsg = 0;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_SYSINFO:
|
|
|
|
/* Requirements on dev depend on the flags:
|
|
|
|
* alias with INSTALLNAME, name like "digitalvideo"
|
|
|
|
* with QUANTITY and NAME. */
|
|
|
|
{
|
2010-09-29 14:47:55 +02:00
|
|
|
data.sysinfo.wDeviceType = MCI_ALL_DEVICE_ID;
|
2010-09-03 06:33:52 +02:00
|
|
|
if (uDevID != MCI_ALL_DEVICE_ID) {
|
|
|
|
if (dwFlags & MCI_SYSINFO_INSTALLNAME)
|
|
|
|
wmd = MCI_GetDriver(mciGetDeviceIDW(dev));
|
2010-09-29 14:47:55 +02:00
|
|
|
else if (!(data.sysinfo.wDeviceType = MCI_GetDevTypeFromResource(dev))) {
|
2010-09-03 06:33:52 +02:00
|
|
|
dwRet = MCIERR_DEVICE_TYPE_REQUIRED;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2010-03-28 21:54:50 +02:00
|
|
|
case MCI_SOUND:
|
|
|
|
/* FIXME: name is optional, "sound" is a valid command.
|
|
|
|
* FIXME: Parse "sound notify" as flag, not as name. */
|
2010-09-29 14:47:55 +02:00
|
|
|
data.sound.lpstrSoundName = dev;
|
2010-03-28 21:54:50 +02:00
|
|
|
dwFlags |= MCI_SOUND_NAME;
|
|
|
|
break;
|
2010-08-30 19:43:26 +02:00
|
|
|
}
|
|
|
|
|
2010-09-29 14:47:55 +02:00
|
|
|
TRACE("[%d, %s, %08x, %08x %08x %08x %08x %08x %08x %08x %08x %08x %08x]\n",
|
2010-08-25 07:32:28 +02:00
|
|
|
wmd ? wmd->wDeviceID : uDevID, MCI_MessageToString(wMsg), dwFlags,
|
2010-09-29 14:47:55 +02:00
|
|
|
data.dw[0], data.dw[1], data.dw[2], data.dw[3], data.dw[4],
|
|
|
|
data.dw[5], data.dw[6], data.dw[7], data.dw[8], data.dw[9]);
|
1999-07-24 12:41:28 +02:00
|
|
|
|
2010-08-30 19:43:26 +02:00
|
|
|
if (wMsg == MCI_OPEN) {
|
2010-09-29 14:47:55 +02:00
|
|
|
if ((dwRet = MCI_FinishOpen(wmd, &data.open, dwFlags)))
|
2010-08-30 19:43:26 +02:00
|
|
|
goto errCleanUp;
|
1999-07-24 12:41:28 +02:00
|
|
|
/* FIXME: notification is not properly shared across two opens */
|
|
|
|
} else {
|
2010-09-29 14:47:55 +02:00
|
|
|
dwRet = MCI_SendCommand(wmd ? wmd->wDeviceID : uDevID, wMsg, dwFlags, (DWORD_PTR)&data);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("=> 1/ %x (%s)\n", dwRet, debugstr_w(lpstrRet));
|
2010-09-21 19:28:20 +02:00
|
|
|
if (!LOWORD(dwRet)) {
|
|
|
|
dwRet = MCI_HandleReturnValues(dwRet, wmd, retType, &data.generic, lpstrRet, uRetLen);
|
|
|
|
TRACE("=> 2/ %x (%s)\n", dwRet, debugstr_w(lpstrRet));
|
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
errCleanUp:
|
2010-08-25 07:32:28 +02:00
|
|
|
if (auto_open) {
|
|
|
|
/* PLAY and RECORD are the only known non-immediate commands */
|
|
|
|
if (LOWORD(dwRet) || !(wMsg == MCI_PLAY || wMsg == MCI_RECORD))
|
|
|
|
MCI_SendCommand(auto_open, MCI_CLOSE, 0, 0);
|
|
|
|
else
|
|
|
|
FIXME("leaking auto-open device %u\n", auto_open);
|
|
|
|
}
|
2010-08-30 19:43:26 +02:00
|
|
|
if (wMsg == MCI_OPEN && LOWORD(dwRet) && wmd)
|
|
|
|
MCI_UnLoadMciDriver(wmd);
|
1999-07-24 12:41:28 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, verb);
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2005-02-09 23:26:25 +01:00
|
|
|
* mciSendStringA [WINMM.@]
|
1999-07-24 12:41:28 +02:00
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
DWORD WINAPI mciSendStringA(LPCSTR lpstrCommand, LPSTR lpstrRet,
|
1999-07-24 12:41:28 +02:00
|
|
|
UINT uRetLen, HWND hwndCallback)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR lpwstrCommand;
|
|
|
|
LPWSTR lpwstrRet = NULL;
|
1999-07-24 12:41:28 +02:00
|
|
|
UINT ret;
|
2001-12-24 21:30:24 +01:00
|
|
|
INT len;
|
1999-03-15 16:42:26 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/* FIXME: is there something to do with lpstrReturnString ? */
|
2005-02-09 23:26:25 +01:00
|
|
|
len = MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, NULL, 0 );
|
|
|
|
lpwstrCommand = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpstrCommand, -1, lpwstrCommand, len );
|
|
|
|
if (lpstrRet)
|
2003-09-15 22:13:30 +02:00
|
|
|
{
|
2010-09-21 19:28:20 +02:00
|
|
|
if (uRetLen) *lpstrRet = '\0'; /* NT-w2k3 use memset(lpstrRet, 0, uRetLen); */
|
2005-02-09 23:26:25 +01:00
|
|
|
lpwstrRet = HeapAlloc(GetProcessHeap(), 0, uRetLen * sizeof(WCHAR));
|
2005-03-15 16:39:03 +01:00
|
|
|
if (!lpwstrRet) {
|
|
|
|
HeapFree( GetProcessHeap(), 0, lpwstrCommand );
|
|
|
|
return MCIERR_OUT_OF_MEMORY;
|
|
|
|
}
|
2003-09-15 22:13:30 +02:00
|
|
|
}
|
2005-02-09 23:26:25 +01:00
|
|
|
ret = mciSendStringW(lpwstrCommand, lpwstrRet, uRetLen, hwndCallback);
|
2009-07-04 06:52:38 +02:00
|
|
|
if (!ret && lpwstrRet)
|
2005-02-09 23:26:25 +01:00
|
|
|
WideCharToMultiByte( CP_ACP, 0, lpwstrRet, -1, lpstrRet, uRetLen, NULL, NULL );
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwstrCommand);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpwstrRet);
|
1999-07-24 12:41:28 +02:00
|
|
|
return ret;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* mciExecute [WINMM.@]
|
1999-03-15 16:42:26 +01:00
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
BOOL WINAPI mciExecute(LPCSTR lpstrCommand)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
char strRet[256];
|
|
|
|
DWORD ret;
|
1999-03-15 16:42:26 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
TRACE("(%s)!\n", lpstrCommand);
|
|
|
|
|
2001-08-15 19:40:03 +02:00
|
|
|
ret = mciSendStringA(lpstrCommand, strRet, sizeof(strRet), 0);
|
1999-07-24 12:41:28 +02:00
|
|
|
if (ret != 0) {
|
|
|
|
if (!mciGetErrorStringA(ret, strRet, sizeof(strRet))) {
|
2006-11-08 22:24:36 +01:00
|
|
|
sprintf(strRet, "Unknown MCI error (%d)", ret);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
MessageBoxA(0, strRet, "Error in mciExecute()", MB_OK);
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
|
|
|
/* FIXME: what shall I return ? */
|
2005-02-09 23:26:25 +01:00
|
|
|
return TRUE;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* mciLoadCommandResource [WINMM.@]
|
1999-07-24 12:41:28 +02:00
|
|
|
*
|
2008-11-23 20:53:43 +01:00
|
|
|
* Strangely, this function only exists as a UNICODE one.
|
1999-07-24 12:41:28 +02:00
|
|
|
*/
|
2001-01-29 00:11:27 +01:00
|
|
|
UINT WINAPI mciLoadCommandResource(HINSTANCE hInst, LPCWSTR resNameW, UINT type)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
2009-10-20 21:54:52 +02:00
|
|
|
UINT ret = MCI_NO_COMMAND_TABLE;
|
|
|
|
HRSRC hRsrc = 0;
|
|
|
|
HGLOBAL hMem;
|
2001-01-29 00:11:27 +01:00
|
|
|
|
2002-10-31 02:02:41 +01:00
|
|
|
TRACE("(%p, %s, %d)!\n", hInst, debugstr_w(resNameW), type);
|
2001-01-29 00:11:27 +01:00
|
|
|
|
2002-10-11 01:28:22 +02:00
|
|
|
/* if a file named "resname.mci" exits, then load resource "resname" from it
|
2001-01-29 00:11:27 +01:00
|
|
|
* otherwise directly from driver
|
|
|
|
* We don't support it (who uses this feature ?), but we check anyway
|
|
|
|
*/
|
|
|
|
if (!type) {
|
2002-10-11 01:28:22 +02:00
|
|
|
#if 0
|
|
|
|
/* FIXME: we should put this back into order, but I never found a program
|
2005-02-09 23:26:25 +01:00
|
|
|
* actually using this feature, so we may not need it
|
2002-10-11 01:28:22 +02:00
|
|
|
*/
|
2001-01-29 00:11:27 +01:00
|
|
|
char buf[128];
|
|
|
|
OFSTRUCT ofs;
|
|
|
|
|
|
|
|
strcat(strcpy(buf, resname), ".mci");
|
|
|
|
if (OpenFile(buf, &ofs, OF_EXIST) != HFILE_ERROR) {
|
|
|
|
FIXME("NIY: command table to be loaded from '%s'\n", ofs.szPathName);
|
|
|
|
}
|
|
|
|
#endif
|
2002-10-11 01:28:22 +02:00
|
|
|
}
|
2009-10-20 21:54:52 +02:00
|
|
|
if ((hRsrc = FindResourceW(hInst, resNameW, (LPWSTR)RT_RCDATA)) &&
|
|
|
|
(hMem = LoadResource(hInst, hRsrc))) {
|
|
|
|
ret = MCI_SetCommandTable(hMem, type);
|
|
|
|
FreeResource(hMem);
|
2001-01-29 00:11:27 +01:00
|
|
|
}
|
2009-10-20 21:54:52 +02:00
|
|
|
else WARN("No command table found in module for %s\n", debugstr_w(resNameW));
|
|
|
|
|
2001-01-29 00:11:27 +01:00
|
|
|
TRACE("=> %04x\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-03-15 16:42:26 +01:00
|
|
|
/**************************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* mciFreeCommandResource [WINMM.@]
|
1999-03-15 16:42:26 +01:00
|
|
|
*/
|
1999-07-24 12:41:28 +02:00
|
|
|
BOOL WINAPI mciFreeCommandResource(UINT uTable)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
1999-07-24 12:41:28 +02:00
|
|
|
TRACE("(%08x)!\n", uTable);
|
|
|
|
|
2009-10-20 21:54:52 +02:00
|
|
|
if (uTable >= MAX_MCICMDTABLE || !S_MciCmdTable[uTable].lpTable)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
FreeResource(S_MciCmdTable[uTable].hMem);
|
|
|
|
S_MciCmdTable[uTable].hMem = NULL;
|
|
|
|
S_MciCmdTable[uTable].lpTable = NULL;
|
|
|
|
HeapFree(GetProcessHeap(), 0, S_MciCmdTable[uTable].aVerbs);
|
|
|
|
S_MciCmdTable[uTable].aVerbs = 0;
|
|
|
|
S_MciCmdTable[uTable].nVerbs = 0;
|
|
|
|
return TRUE;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_Open [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_Open(DWORD dwParam, LPMCI_OPEN_PARMSW lpParms)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
2005-02-09 23:26:25 +01:00
|
|
|
WCHAR strDevTyp[128];
|
2002-06-01 01:06:46 +02:00
|
|
|
DWORD dwRet;
|
2000-04-29 16:19:02 +02:00
|
|
|
LPWINE_MCIDRIVER wmd = NULL;
|
1999-07-15 16:42:44 +02:00
|
|
|
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%08X, %p)\n", dwParam, lpParms);
|
1999-03-15 16:42:26 +01:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
1999-06-05 10:48:01 +02:00
|
|
|
|
|
|
|
/* only two low bytes are generic, the other ones are dev type specific */
|
1999-09-22 18:43:18 +02:00
|
|
|
#define WINE_MCIDRIVER_SUPP (0xFFFF0000|MCI_OPEN_SHAREABLE|MCI_OPEN_ELEMENT| \
|
1999-08-18 20:26:58 +02:00
|
|
|
MCI_OPEN_ALIAS|MCI_OPEN_TYPE|MCI_OPEN_TYPE_ID| \
|
|
|
|
MCI_NOTIFY|MCI_WAIT)
|
2011-10-24 23:22:16 +02:00
|
|
|
if ((dwParam & ~WINE_MCIDRIVER_SUPP) != 0)
|
|
|
|
FIXME("Unsupported yet dwFlags=%08X\n", dwParam & ~WINE_MCIDRIVER_SUPP);
|
1999-09-22 18:43:18 +02:00
|
|
|
#undef WINE_MCIDRIVER_SUPP
|
1999-03-15 16:42:26 +01:00
|
|
|
|
|
|
|
strDevTyp[0] = 0;
|
|
|
|
|
1999-08-18 20:26:58 +02:00
|
|
|
if (dwParam & MCI_OPEN_TYPE) {
|
|
|
|
if (dwParam & MCI_OPEN_TYPE_ID) {
|
2009-05-20 17:50:54 +02:00
|
|
|
WORD uDevType = LOWORD(lpParms->lpstrDeviceType);
|
1999-08-18 20:26:58 +02:00
|
|
|
|
|
|
|
if (uDevType < MCI_DEVTYPE_FIRST ||
|
|
|
|
uDevType > MCI_DEVTYPE_LAST ||
|
2007-06-07 17:50:28 +02:00
|
|
|
!LoadStringW(hWinMM32Instance, uDevType,
|
2005-02-09 23:26:25 +01:00
|
|
|
strDevTyp, sizeof(strDevTyp) / sizeof(WCHAR))) {
|
1999-08-18 20:26:58 +02:00
|
|
|
dwRet = MCIERR_BAD_INTEGER;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
LPWSTR ptr;
|
1999-08-18 20:26:58 +02:00
|
|
|
if (lpParms->lpstrDeviceType == NULL) {
|
|
|
|
dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
2005-02-09 23:26:25 +01:00
|
|
|
strcpyW(strDevTyp, lpParms->lpstrDeviceType);
|
|
|
|
ptr = strchrW(strDevTyp, '!');
|
1999-12-06 00:08:08 +01:00
|
|
|
if (ptr) {
|
|
|
|
/* this behavior is not documented in windows. However, since, in
|
|
|
|
* some occasions, MCI_OPEN handling is translated by WinMM into
|
|
|
|
* a call to mciSendString("open <type>"); this code shall be correct
|
|
|
|
*/
|
|
|
|
if (dwParam & MCI_OPEN_ELEMENT) {
|
|
|
|
ERR("Both MCI_OPEN_ELEMENT(%s) and %s are used\n",
|
2005-02-09 23:26:25 +01:00
|
|
|
debugstr_w(lpParms->lpstrElementName),
|
|
|
|
debugstr_w(strDevTyp));
|
1999-12-06 00:08:08 +01:00
|
|
|
dwRet = MCIERR_UNRECOGNIZED_KEYWORD;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
dwParam |= MCI_OPEN_ELEMENT;
|
|
|
|
*ptr++ = 0;
|
|
|
|
/* FIXME: not a good idea to write in user supplied buffer */
|
|
|
|
lpParms->lpstrElementName = ptr;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-08-18 20:26:58 +02:00
|
|
|
}
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("devType=%s !\n", debugstr_w(strDevTyp));
|
1999-08-18 20:26:58 +02:00
|
|
|
}
|
|
|
|
|
1999-03-15 16:42:26 +01:00
|
|
|
if (dwParam & MCI_OPEN_ELEMENT) {
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("lpstrElementName=%s\n", debugstr_w(lpParms->lpstrElementName));
|
1999-07-24 12:41:28 +02:00
|
|
|
|
|
|
|
if (dwParam & MCI_OPEN_ELEMENT_ID) {
|
|
|
|
FIXME("Unsupported yet flag MCI_OPEN_ELEMENT_ID\n");
|
|
|
|
dwRet = MCIERR_UNRECOGNIZED_KEYWORD;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
|
1999-07-15 16:42:44 +02:00
|
|
|
if (!lpParms->lpstrElementName) {
|
|
|
|
dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
|
1999-08-18 20:26:58 +02:00
|
|
|
/* type, if given as a parameter, supersedes file extension */
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!strDevTyp[0] &&
|
|
|
|
MCI_GetDevTypeFromFileName(lpParms->lpstrElementName,
|
1999-08-18 20:26:58 +02:00
|
|
|
strDevTyp, sizeof(strDevTyp))) {
|
2005-02-09 23:26:25 +01:00
|
|
|
static const WCHAR wszCdAudio[] = {'C','D','A','U','D','I','O',0};
|
|
|
|
if (GetDriveTypeW(lpParms->lpstrElementName) != DRIVE_CDROM) {
|
1999-07-15 16:42:44 +02:00
|
|
|
dwRet = MCIERR_EXTENSION_NOT_FOUND;
|
|
|
|
goto errCleanUp;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
1999-09-22 18:43:18 +02:00
|
|
|
/* FIXME: this will not work if several CDROM drives are installed on the machine */
|
2005-02-09 23:26:25 +01:00
|
|
|
strcpyW(strDevTyp, wszCdAudio);
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-04-11 14:17:53 +02:00
|
|
|
if (strDevTyp[0] == 0) {
|
1999-05-24 10:20:31 +02:00
|
|
|
FIXME("Couldn't load driver\n");
|
1999-07-24 12:41:28 +02:00
|
|
|
dwRet = MCIERR_INVALID_DEVICE_NAME;
|
1999-07-15 16:42:44 +02:00
|
|
|
goto errCleanUp;
|
1999-04-11 14:17:53 +02:00
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if (dwParam & MCI_OPEN_ALIAS) {
|
2005-02-09 23:26:25 +01:00
|
|
|
TRACE("Alias=%s !\n", debugstr_w(lpParms->lpstrAlias));
|
1999-07-24 12:41:28 +02:00
|
|
|
if (!lpParms->lpstrAlias) {
|
|
|
|
dwRet = MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
goto errCleanUp;
|
|
|
|
}
|
|
|
|
}
|
1999-07-15 16:42:44 +02:00
|
|
|
|
2002-10-25 21:00:12 +02:00
|
|
|
if ((dwRet = MCI_LoadMciDriver(strDevTyp, &wmd))) {
|
1999-07-15 16:42:44 +02:00
|
|
|
goto errCleanUp;
|
1999-07-24 12:41:28 +02:00
|
|
|
}
|
1999-05-02 12:21:49 +02:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if ((dwRet = MCI_FinishOpen(wmd, lpParms, dwParam))) {
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("Failed to open driver (MCI_OPEN_DRIVER) [%08x], closing\n", dwRet);
|
1999-07-15 16:42:44 +02:00
|
|
|
/* FIXME: is dwRet the correct ret code ? */
|
|
|
|
goto errCleanUp;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
1999-07-15 16:42:44 +02:00
|
|
|
|
|
|
|
/* only handled devices fall through */
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("wDevID=%04X wDeviceID=%d dwRet=%d\n", wmd->wDeviceID, lpParms->wDeviceID, dwRet);
|
1999-07-15 16:42:44 +02:00
|
|
|
return 0;
|
2010-05-19 05:42:18 +02:00
|
|
|
|
1999-07-15 16:42:44 +02:00
|
|
|
errCleanUp:
|
2002-10-25 21:00:12 +02:00
|
|
|
if (wmd) MCI_UnLoadMciDriver(wmd);
|
1999-03-15 16:42:26 +01:00
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_Close [internal]
|
|
|
|
*/
|
2009-11-14 14:40:04 +01:00
|
|
|
static DWORD MCI_Close(UINT wDevID, DWORD dwParam, LPMCI_GENERIC_PARMS lpParms)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
1999-07-15 16:42:44 +02:00
|
|
|
DWORD dwRet;
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%04x, %08X, %p)\n", wDevID, dwParam, lpParms);
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2009-10-19 22:14:45 +02:00
|
|
|
/* Every device must handle MCI_NOTIFY on its own. */
|
2009-11-14 14:40:04 +01:00
|
|
|
if ((UINT16)wDevID == (UINT16)MCI_ALL_DEVICE_ID) {
|
2008-03-17 21:15:42 +01:00
|
|
|
while (MciDrivers) {
|
|
|
|
/* Retrieve the device ID under lock, but send the message without,
|
|
|
|
* the driver might be calling some winmm functions from another
|
|
|
|
* thread before being fully stopped.
|
|
|
|
*/
|
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
if (!MciDrivers)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
wDevID = MciDrivers->wDeviceID;
|
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
|
|
|
MCI_Close(wDevID, dwParam, lpParms);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-07-15 16:42:44 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(wmd = MCI_GetDriver(wDevID))) {
|
|
|
|
return MCIERR_INVALID_DEVICE_ID;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
|
2009-05-20 17:50:54 +02:00
|
|
|
dwRet = MCI_SendCommandFrom32(wDevID, MCI_CLOSE_DRIVER, dwParam, (DWORD_PTR)lpParms);
|
1999-07-15 16:42:44 +02:00
|
|
|
|
2002-10-25 21:00:12 +02:00
|
|
|
MCI_UnLoadMciDriver(wmd);
|
1999-04-11 14:17:53 +02:00
|
|
|
|
1999-03-15 16:42:26 +01:00
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_WriteString [internal]
|
|
|
|
*/
|
2009-01-31 14:02:34 +01:00
|
|
|
static DWORD MCI_WriteString(LPWSTR lpDstStr, DWORD dstSize, LPCWSTR lpSrcStr)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
1999-07-24 12:41:28 +02:00
|
|
|
DWORD ret = 0;
|
1999-03-15 16:42:26 +01:00
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
if (lpSrcStr) {
|
2005-02-09 23:26:25 +01:00
|
|
|
if (dstSize <= strlenW(lpSrcStr)) {
|
1999-07-24 12:41:28 +02:00
|
|
|
ret = MCIERR_PARAM_OVERFLOW;
|
|
|
|
} else {
|
2005-02-09 23:26:25 +01:00
|
|
|
strcpyW(lpDstStr, lpSrcStr);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
} else {
|
1999-07-24 12:41:28 +02:00
|
|
|
*lpDstStr = 0;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_Sysinfo [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParms)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
2004-06-30 20:12:20 +02:00
|
|
|
DWORD ret = MCIERR_INVALID_DEVICE_ID, cnt = 0;
|
2011-07-05 21:37:32 +02:00
|
|
|
WCHAR buf[2048], *s, *p;
|
1999-07-15 16:42:44 +02:00
|
|
|
LPWINE_MCIDRIVER wmd;
|
2004-06-30 20:12:20 +02:00
|
|
|
HKEY hKey;
|
1999-07-15 16:42:44 +02:00
|
|
|
|
2009-10-18 18:41:10 +02:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
if (lpParms->lpstrReturn == NULL) return MCIERR_PARAM_OVERFLOW;
|
1999-07-15 16:42:44 +02:00
|
|
|
|
2009-05-20 17:50:54 +02:00
|
|
|
TRACE("(%08x, %08X, %p[num=%d, wDevTyp=%u])\n",
|
|
|
|
uDevID, dwFlags, lpParms, lpParms->dwNumber, lpParms->wDeviceType);
|
2009-11-17 22:07:55 +01:00
|
|
|
if ((WORD)MCI_ALL_DEVICE_ID == LOWORD(uDevID))
|
|
|
|
uDevID = MCI_ALL_DEVICE_ID; /* Be compatible with Win9x */
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2009-11-17 22:07:55 +01:00
|
|
|
switch (dwFlags & ~(MCI_SYSINFO_OPEN|MCI_NOTIFY|MCI_WAIT)) {
|
1999-03-15 16:42:26 +01:00
|
|
|
case MCI_SYSINFO_QUANTITY:
|
2009-11-17 22:07:55 +01:00
|
|
|
if (lpParms->dwRetSize < sizeof(DWORD))
|
|
|
|
return MCIERR_PARAM_OVERFLOW;
|
|
|
|
/* Win9x returns 0 for 0 < uDevID < (UINT16)MCI_ALL_DEVICE_ID */
|
|
|
|
if (uDevID == MCI_ALL_DEVICE_ID) {
|
|
|
|
/* wDeviceType == MCI_ALL_DEVICE_ID is not recognized. */
|
2004-06-30 20:12:20 +02:00
|
|
|
if (dwFlags & MCI_SYSINFO_OPEN) {
|
|
|
|
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
|
2004-06-30 20:12:20 +02:00
|
|
|
cnt++;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
1999-03-15 16:42:26 +01:00
|
|
|
} else {
|
2004-06-30 20:12:20 +02:00
|
|
|
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
|
2005-02-09 23:26:25 +01:00
|
|
|
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, wszHklmMci,
|
2004-06-30 20:12:20 +02:00
|
|
|
0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
|
2005-02-09 23:26:25 +01:00
|
|
|
RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
|
2004-06-30 20:12:20 +02:00
|
|
|
RegCloseKey( hKey );
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2005-03-21 11:28:38 +01:00
|
|
|
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, sizeof(buf) / sizeof(buf[0]), wszSystemIni))
|
2005-02-09 23:26:25 +01:00
|
|
|
for (s = buf; *s; s += strlenW(s) + 1) cnt++;
|
2004-06-30 20:12:20 +02:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (dwFlags & MCI_SYSINFO_OPEN) {
|
2009-11-17 22:07:55 +01:00
|
|
|
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %d\n", lpParms->wDeviceType);
|
2007-06-07 17:50:28 +02:00
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
|
2004-06-30 20:12:20 +02:00
|
|
|
if (wmd->wType == lpParms->wDeviceType) cnt++;
|
|
|
|
}
|
2007-06-07 17:50:28 +02:00
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
2004-06-30 20:12:20 +02:00
|
|
|
} else {
|
2009-11-17 22:07:55 +01:00
|
|
|
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %d\n", lpParms->wDeviceType);
|
2004-06-30 20:12:20 +02:00
|
|
|
FIXME("Don't know how to get # of MCI devices of a given type\n");
|
2010-09-03 06:33:52 +02:00
|
|
|
/* name = LoadStringW(hWinMM32Instance, LOWORD(lpParms->wDeviceType))
|
|
|
|
* then lookup registry and/or system.ini for name, ignoring digits suffix */
|
|
|
|
switch (LOWORD(lpParms->wDeviceType)) {
|
|
|
|
case MCI_DEVTYPE_CD_AUDIO:
|
|
|
|
case MCI_DEVTYPE_WAVEFORM_AUDIO:
|
|
|
|
case MCI_DEVTYPE_SEQUENCER:
|
|
|
|
cnt = 1;
|
|
|
|
break;
|
|
|
|
default: /* "digitalvideo" gets 0 because it's not in the registry */
|
|
|
|
cnt = 0;
|
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
}
|
2004-06-30 20:12:20 +02:00
|
|
|
*(DWORD*)lpParms->lpstrReturn = cnt;
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%d) => '%d'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn);
|
1999-07-24 12:41:28 +02:00
|
|
|
ret = MCI_INTEGER_RETURNED;
|
2009-11-17 22:07:55 +01:00
|
|
|
/* return ret; Only Win9x sends a notification in this case. */
|
1999-03-15 16:42:26 +01:00
|
|
|
break;
|
|
|
|
case MCI_SYSINFO_INSTALLNAME:
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE("MCI_SYSINFO_INSTALLNAME\n");
|
1999-07-15 16:42:44 +02:00
|
|
|
if ((wmd = MCI_GetDriver(uDevID))) {
|
2002-06-01 01:06:46 +02:00
|
|
|
ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize,
|
1999-07-24 12:41:28 +02:00
|
|
|
wmd->lpstrDeviceType);
|
1999-03-15 16:42:26 +01:00
|
|
|
} else {
|
2010-09-03 06:33:52 +02:00
|
|
|
ret = (uDevID == MCI_ALL_DEVICE_ID)
|
|
|
|
? MCIERR_CANNOT_USE_ALL : MCIERR_INVALID_DEVICE_NAME;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%d) => %s\n", lpParms->dwNumber, debugstr_w(lpParms->lpstrReturn));
|
1999-03-15 16:42:26 +01:00
|
|
|
break;
|
|
|
|
case MCI_SYSINFO_NAME:
|
2009-11-17 22:07:55 +01:00
|
|
|
s = NULL;
|
1999-03-15 16:42:26 +01:00
|
|
|
if (dwFlags & MCI_SYSINFO_OPEN) {
|
2009-11-17 22:07:55 +01:00
|
|
|
/* Win9x returns 0 for 0 < uDevID < (UINT16)MCI_ALL_DEVICE_ID */
|
|
|
|
TRACE("MCI_SYSINFO_NAME: nth alias of type %d\n",
|
|
|
|
uDevID == MCI_ALL_DEVICE_ID ? MCI_ALL_DEVICE_ID : lpParms->wDeviceType);
|
|
|
|
EnterCriticalSection(&WINMM_cs);
|
|
|
|
for (wmd = MciDrivers; wmd; wmd = wmd->lpNext) {
|
|
|
|
/* wDeviceType == MCI_ALL_DEVICE_ID is not recognized. */
|
|
|
|
if (uDevID == MCI_ALL_DEVICE_ID ||
|
|
|
|
lpParms->wDeviceType == wmd->wType) {
|
|
|
|
cnt++;
|
|
|
|
if (cnt == lpParms->dwNumber) {
|
|
|
|
s = wmd->lpstrAlias;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&WINMM_cs);
|
2010-04-09 05:45:07 +02:00
|
|
|
ret = s ? MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, s) : MCIERR_OUTOFRANGE;
|
2009-11-17 22:07:55 +01:00
|
|
|
} else if (MCI_ALL_DEVICE_ID == uDevID) {
|
|
|
|
TRACE("MCI_SYSINFO_NAME: device #%d\n", lpParms->dwNumber);
|
2005-02-09 23:26:25 +01:00
|
|
|
if (RegOpenKeyExW( HKEY_LOCAL_MACHINE, wszHklmMci, 0,
|
|
|
|
KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
|
|
|
|
if (RegQueryInfoKeyW( hKey, 0, 0, 0, &cnt,
|
|
|
|
0, 0, 0, 0, 0, 0, 0) == ERROR_SUCCESS &&
|
|
|
|
lpParms->dwNumber <= cnt) {
|
2008-10-12 19:50:20 +02:00
|
|
|
DWORD bufLen = sizeof(buf)/sizeof(buf[0]);
|
2005-02-09 23:26:25 +01:00
|
|
|
if (RegEnumKeyExW(hKey, lpParms->dwNumber - 1,
|
|
|
|
buf, &bufLen, 0, 0, 0, 0) == ERROR_SUCCESS)
|
|
|
|
s = buf;
|
2004-06-30 20:12:20 +02:00
|
|
|
}
|
|
|
|
RegCloseKey( hKey );
|
|
|
|
}
|
|
|
|
if (!s) {
|
2005-03-21 11:28:38 +01:00
|
|
|
if (GetPrivateProfileStringW(wszMci, 0, wszNull, buf, sizeof(buf) / sizeof(buf[0]), wszSystemIni)) {
|
2005-02-09 23:26:25 +01:00
|
|
|
for (p = buf; *p; p += strlenW(p) + 1, cnt++) {
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("%d: %s\n", cnt, debugstr_w(p));
|
2004-06-30 20:12:20 +02:00
|
|
|
if (cnt == lpParms->dwNumber - 1) {
|
|
|
|
s = p;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-04-09 05:45:07 +02:00
|
|
|
ret = s ? MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, s) : MCIERR_OUTOFRANGE;
|
2009-11-17 22:07:55 +01:00
|
|
|
} else {
|
|
|
|
FIXME("MCI_SYSINFO_NAME: nth device of type %d\n", lpParms->wDeviceType);
|
|
|
|
/* Cheating: what is asked for is the nth device from the registry. */
|
|
|
|
if (1 != lpParms->dwNumber || /* Handle only one of each kind. */
|
|
|
|
lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST)
|
|
|
|
ret = MCIERR_OUTOFRANGE;
|
|
|
|
else {
|
|
|
|
LoadStringW(hWinMM32Instance, LOWORD(lpParms->wDeviceType),
|
2010-04-09 05:45:07 +02:00
|
|
|
lpParms->lpstrReturn, lpParms->dwRetSize);
|
2009-11-17 22:07:55 +01:00
|
|
|
ret = 0;
|
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%d) => %s\n", lpParms->dwNumber, debugstr_w(lpParms->lpstrReturn));
|
1999-03-15 16:42:26 +01:00
|
|
|
break;
|
|
|
|
default:
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("Unsupported flag value=%08x\n", dwFlags);
|
2009-11-17 22:07:55 +01:00
|
|
|
ret = MCIERR_UNRECOGNIZED_KEYWORD;
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2009-11-17 22:07:55 +01:00
|
|
|
if ((dwFlags & MCI_NOTIFY) && HRESULT_CODE(ret)==0)
|
|
|
|
mciDriverNotify((HWND)lpParms->dwCallback, uDevID, MCI_NOTIFY_SUCCESSFUL);
|
1999-03-15 16:42:26 +01:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-06-05 10:48:01 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_Break [internal]
|
|
|
|
*/
|
1999-07-24 12:41:28 +02:00
|
|
|
static DWORD MCI_Break(UINT wDevID, DWORD dwFlags, LPMCI_BREAK_PARMS lpParms)
|
1999-06-05 10:48:01 +02:00
|
|
|
{
|
|
|
|
DWORD dwRet = 0;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-05 10:48:01 +02:00
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
2010-03-28 20:34:03 +02:00
|
|
|
FIXME("(%04x) vkey %04X stub\n", dwFlags, lpParms->nVirtKey);
|
1999-06-05 10:48:01 +02:00
|
|
|
|
2010-03-28 20:34:03 +02:00
|
|
|
if (MMSYSERR_NOERROR==dwRet && (dwFlags & MCI_NOTIFY))
|
|
|
|
mciDriverNotify((HWND)lpParms->dwCallback, wDevID, MCI_NOTIFY_SUCCESSFUL);
|
1999-06-05 10:48:01 +02:00
|
|
|
return dwRet;
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-04-05 22:16:11 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_Sound [internal]
|
|
|
|
*/
|
2005-02-09 23:26:25 +01:00
|
|
|
static DWORD MCI_Sound(UINT wDevID, DWORD dwFlags, LPMCI_SOUND_PARMSW lpParms)
|
2004-04-05 22:16:11 +02:00
|
|
|
{
|
2010-03-28 21:54:50 +02:00
|
|
|
DWORD dwRet;
|
|
|
|
|
|
|
|
if (dwFlags & MCI_SOUND_NAME) {
|
|
|
|
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
|
|
|
|
else dwRet = PlaySoundW(lpParms->lpstrSoundName, NULL,
|
|
|
|
SND_ALIAS | (dwFlags & MCI_WAIT ? SND_SYNC : SND_ASYNC))
|
|
|
|
? 0 : MCIERR_HARDWARE;
|
|
|
|
} else dwRet = PlaySoundW((LPCWSTR)SND_ALIAS_SYSTEMDEFAULT, NULL,
|
|
|
|
SND_ALIAS_ID | (dwFlags & MCI_WAIT ? SND_SYNC : SND_ASYNC))
|
|
|
|
? 0 : MCIERR_HARDWARE;
|
|
|
|
|
|
|
|
if (!dwRet && lpParms && (dwFlags & MCI_NOTIFY))
|
2010-03-28 20:34:03 +02:00
|
|
|
mciDriverNotify((HWND)lpParms->dwCallback, wDevID, MCI_NOTIFY_SUCCESSFUL);
|
2004-04-05 22:16:11 +02:00
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
1999-07-24 12:41:28 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_SendCommand [internal]
|
|
|
|
*/
|
2009-10-17 12:05:04 +02:00
|
|
|
DWORD MCI_SendCommand(UINT wDevID, UINT16 wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
1999-07-24 12:41:28 +02:00
|
|
|
{
|
|
|
|
DWORD dwRet = MCIERR_UNRECOGNIZED_COMMAND;
|
|
|
|
|
|
|
|
switch (wMsg) {
|
|
|
|
case MCI_OPEN:
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_Open(dwParam1, (LPMCI_OPEN_PARMSW)dwParam2);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_CLOSE:
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_Close(wDevID, dwParam1, (LPMCI_GENERIC_PARMS)dwParam2);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_SYSINFO:
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_SysInfo(wDevID, dwParam1, (LPMCI_SYSINFO_PARMSW)dwParam2);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_BREAK:
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_Break(wDevID, dwParam1, (LPMCI_BREAK_PARMS)dwParam2);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
case MCI_SOUND:
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_Sound(wDevID, dwParam1, (LPMCI_SOUND_PARMSW)dwParam2);
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
default:
|
2009-11-14 14:40:04 +01:00
|
|
|
if ((UINT16)wDevID == (UINT16)MCI_ALL_DEVICE_ID) {
|
1999-07-24 12:41:28 +02:00
|
|
|
FIXME("unhandled MCI_ALL_DEVICE_ID\n");
|
|
|
|
dwRet = MCIERR_CANNOT_USE_ALL;
|
|
|
|
} else {
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_SendCommandFrom32(wDevID, wMsg, dwParam1, dwParam2);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
1999-03-15 16:42:26 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* MCI_CleanUp [internal]
|
|
|
|
*
|
2002-06-01 01:06:46 +02:00
|
|
|
* Some MCI commands need to be cleaned-up (when not called from
|
1999-03-15 16:42:26 +01:00
|
|
|
* mciSendString), because MCI drivers return extra information for string
|
1999-08-18 20:26:58 +02:00
|
|
|
* transformation. This function gets rid of them.
|
1999-03-15 16:42:26 +01:00
|
|
|
*/
|
2009-10-17 12:05:04 +02:00
|
|
|
static LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD_PTR dwParam2)
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
if (LOWORD(dwRet))
|
1999-07-24 12:41:28 +02:00
|
|
|
return LOWORD(dwRet);
|
|
|
|
|
1999-03-15 16:42:26 +01:00
|
|
|
switch (wMsg) {
|
|
|
|
case MCI_GETDEVCAPS:
|
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
|
|
|
case MCI_COLONIZED3_RETURN:
|
|
|
|
case MCI_COLONIZED4_RETURN:
|
|
|
|
case MCI_INTEGER_RETURNED:
|
1999-08-18 20:26:58 +02:00
|
|
|
/* nothing to do */
|
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED:
|
|
|
|
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
1999-07-24 12:41:28 +02:00
|
|
|
LPMCI_GETDEVCAPS_PARMS lmgp;
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2009-05-20 17:50:54 +02:00
|
|
|
lmgp = (LPMCI_GETDEVCAPS_PARMS)dwParam2;
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("Changing %08x to %08x\n", lmgp->dwReturn, LOWORD(lmgp->dwReturn));
|
1999-03-15 16:42:26 +01:00
|
|
|
lmgp->dwReturn = LOWORD(lmgp->dwReturn);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
break;
|
|
|
|
default:
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("Unsupported value for hiword (%04x) returned by DriverProc(%s)\n",
|
1999-07-24 12:41:28 +02:00
|
|
|
HIWORD(dwRet), MCI_MessageToString(wMsg));
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_STATUS:
|
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
|
|
|
case MCI_COLONIZED3_RETURN:
|
|
|
|
case MCI_COLONIZED4_RETURN:
|
|
|
|
case MCI_INTEGER_RETURNED:
|
1999-08-18 20:26:58 +02:00
|
|
|
/* nothing to do */
|
|
|
|
break;
|
|
|
|
case MCI_RESOURCE_RETURNED:
|
|
|
|
case MCI_RESOURCE_RETURNED|MCI_RESOURCE_DRIVER:
|
1999-03-15 16:42:26 +01:00
|
|
|
{
|
1999-07-24 12:41:28 +02:00
|
|
|
LPMCI_STATUS_PARMS lsp;
|
1999-03-15 16:42:26 +01:00
|
|
|
|
2009-01-09 17:46:46 +01:00
|
|
|
lsp = (LPMCI_STATUS_PARMS)dwParam2;
|
|
|
|
TRACE("Changing %08lx to %08x\n", lsp->dwReturn, LOWORD(lsp->dwReturn));
|
1999-03-15 16:42:26 +01:00
|
|
|
lsp->dwReturn = LOWORD(lsp->dwReturn);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("Unsupported value for hiword (%04x) returned by DriverProc(%s)\n",
|
1999-07-24 12:41:28 +02:00
|
|
|
HIWORD(dwRet), MCI_MessageToString(wMsg));
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case MCI_SYSINFO:
|
|
|
|
switch (dwRet & 0xFFFF0000ul) {
|
|
|
|
case 0:
|
|
|
|
case MCI_INTEGER_RETURNED:
|
1999-08-18 20:26:58 +02:00
|
|
|
/* nothing to do */
|
1999-07-24 12:41:28 +02:00
|
|
|
break;
|
|
|
|
default:
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("Unsupported value for hiword (%04x)\n", HIWORD(dwRet));
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
1999-08-18 20:26:58 +02:00
|
|
|
if (HIWORD(dwRet)) {
|
2002-06-01 01:06:46 +02:00
|
|
|
FIXME("Got non null hiword for dwRet=0x%08lx for command %s\n",
|
1999-07-24 12:41:28 +02:00
|
|
|
dwRet, MCI_MessageToString(wMsg));
|
1999-07-15 16:42:44 +02:00
|
|
|
}
|
1999-03-15 16:42:26 +01:00
|
|
|
break;
|
|
|
|
}
|
1999-08-18 20:26:58 +02:00
|
|
|
return LOWORD(dwRet);
|
1999-03-15 16:42:26 +01:00
|
|
|
}
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetErrorStringW [WINMM.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI mciGetErrorStringW(MCIERROR wError, LPWSTR lpstrBuffer, UINT uLength)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (lpstrBuffer != NULL && uLength > 0 &&
|
|
|
|
wError >= MCIERR_BASE && wError <= MCIERR_CUSTOM_DRIVER_BASE) {
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
if (LoadStringW(hWinMM32Instance, wError, lpstrBuffer, uLength) > 0) {
|
2005-02-09 23:26:25 +01:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetErrorStringA [WINMM.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI mciGetErrorStringA(MCIERROR dwError, LPSTR lpstrBuffer, UINT uLength)
|
|
|
|
{
|
|
|
|
BOOL ret = FALSE;
|
|
|
|
|
|
|
|
if (lpstrBuffer != NULL && uLength > 0 &&
|
|
|
|
dwError >= MCIERR_BASE && dwError <= MCIERR_CUSTOM_DRIVER_BASE) {
|
|
|
|
|
2007-06-07 17:50:28 +02:00
|
|
|
if (LoadStringA(hWinMM32Instance, dwError, lpstrBuffer, uLength) > 0) {
|
2005-02-09 23:26:25 +01:00
|
|
|
ret = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciDriverNotify [WINMM.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI mciDriverNotify(HWND hWndCallBack, MCIDEVICEID wDevID, UINT wStatus)
|
|
|
|
{
|
|
|
|
TRACE("(%p, %04x, %04X)\n", hWndCallBack, wDevID, wStatus);
|
|
|
|
|
|
|
|
return PostMessageW(hWndCallBack, MM_MCINOTIFY, wStatus, wDevID);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetDriverData [WINMM.@]
|
|
|
|
*/
|
2009-02-04 00:56:28 +01:00
|
|
|
DWORD_PTR WINAPI mciGetDriverData(MCIDEVICEID uDeviceID)
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
|
|
|
|
TRACE("(%04x)\n", uDeviceID);
|
|
|
|
|
|
|
|
wmd = MCI_GetDriver(uDeviceID);
|
|
|
|
|
|
|
|
if (!wmd) {
|
|
|
|
WARN("Bad uDeviceID\n");
|
|
|
|
return 0L;
|
|
|
|
}
|
|
|
|
|
|
|
|
return wmd->dwPrivate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciSetDriverData [WINMM.@]
|
|
|
|
*/
|
2009-02-04 00:56:28 +01:00
|
|
|
BOOL WINAPI mciSetDriverData(MCIDEVICEID uDeviceID, DWORD_PTR data)
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
|
2009-02-04 00:56:28 +01:00
|
|
|
TRACE("(%04x, %08lx)\n", uDeviceID, data);
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
wmd = MCI_GetDriver(uDeviceID);
|
|
|
|
|
|
|
|
if (!wmd) {
|
|
|
|
WARN("Bad uDeviceID\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
wmd->dwPrivate = data;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciSendCommandW [WINMM.@]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
DWORD WINAPI mciSendCommandW(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
|
|
|
{
|
|
|
|
DWORD dwRet;
|
|
|
|
|
|
|
|
TRACE("(%08x, %s, %08lx, %08lx)\n",
|
|
|
|
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
|
|
|
|
|
2009-10-17 12:05:04 +02:00
|
|
|
dwRet = MCI_SendCommand(wDevID, wMsg, dwParam1, dwParam2);
|
2005-02-09 23:26:25 +01:00
|
|
|
dwRet = MCI_CleanUp(dwRet, wMsg, dwParam2);
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("=> %08x\n", dwRet);
|
2005-02-09 23:26:25 +01:00
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciSendCommandA [WINMM.@]
|
|
|
|
*/
|
|
|
|
DWORD WINAPI mciSendCommandA(MCIDEVICEID wDevID, UINT wMsg, DWORD_PTR dwParam1, DWORD_PTR dwParam2)
|
|
|
|
{
|
|
|
|
DWORD ret;
|
|
|
|
int mapped;
|
|
|
|
|
|
|
|
TRACE("(%08x, %s, %08lx, %08lx)\n",
|
|
|
|
wDevID, MCI_MessageToString(wMsg), dwParam1, dwParam2);
|
|
|
|
|
|
|
|
mapped = MCI_MapMsgAtoW(wMsg, dwParam1, &dwParam2);
|
|
|
|
if (mapped == -1)
|
|
|
|
{
|
|
|
|
FIXME("message %04x mapping failed\n", wMsg);
|
2010-03-28 20:01:15 +02:00
|
|
|
return MCIERR_OUT_OF_MEMORY;
|
2005-02-09 23:26:25 +01:00
|
|
|
}
|
|
|
|
ret = mciSendCommandW(wDevID, wMsg, dwParam1, dwParam2);
|
|
|
|
if (mapped)
|
|
|
|
MCI_UnmapMsgAtoW(wMsg, dwParam1, dwParam2, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetDeviceIDA [WINMM.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI mciGetDeviceIDA(LPCSTR lpstrName)
|
|
|
|
{
|
|
|
|
LPWSTR w = MCI_strdupAtoW(lpstrName);
|
|
|
|
UINT ret = MCIERR_OUT_OF_MEMORY;
|
|
|
|
|
|
|
|
if (w)
|
|
|
|
{
|
|
|
|
ret = mciGetDeviceIDW(w);
|
|
|
|
HeapFree(GetProcessHeap(), 0, w);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetDeviceIDW [WINMM.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI mciGetDeviceIDW(LPCWSTR lpwstrName)
|
|
|
|
{
|
|
|
|
return MCI_GetDriverFromString(lpwstrName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* MCI_DefYieldProc [internal]
|
|
|
|
*/
|
2009-01-31 14:02:34 +01:00
|
|
|
static UINT WINAPI MCI_DefYieldProc(MCIDEVICEID wDevID, DWORD data)
|
2005-02-09 23:26:25 +01:00
|
|
|
{
|
|
|
|
INT16 ret;
|
2009-11-12 21:52:55 +01:00
|
|
|
MSG msg;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(0x%04x, 0x%08x)\n", wDevID, data);
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if ((HIWORD(data) != 0 && HWND_16(GetActiveWindow()) != HIWORD(data)) ||
|
|
|
|
(GetAsyncKeyState(LOWORD(data)) & 1) == 0) {
|
2009-11-12 21:52:55 +01:00
|
|
|
PeekMessageW(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
|
2005-02-09 23:26:25 +01:00
|
|
|
ret = 0;
|
|
|
|
} else {
|
|
|
|
msg.hwnd = HWND_32(HIWORD(data));
|
|
|
|
while (!PeekMessageW(&msg, msg.hwnd, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE));
|
|
|
|
ret = -1;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciSetYieldProc [WINMM.@]
|
|
|
|
*/
|
|
|
|
BOOL WINAPI mciSetYieldProc(MCIDEVICEID uDeviceID, YIELDPROC fpYieldProc, DWORD dwYieldData)
|
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
|
2006-11-08 22:24:36 +01:00
|
|
|
TRACE("(%u, %p, %08x)\n", uDeviceID, fpYieldProc, dwYieldData);
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
if (!(wmd = MCI_GetDriver(uDeviceID))) {
|
|
|
|
WARN("Bad uDeviceID\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
wmd->lpfnYieldProc = fpYieldProc;
|
|
|
|
wmd->dwYieldData = dwYieldData;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetDeviceIDFromElementIDA [WINMM.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI mciGetDeviceIDFromElementIDA(DWORD dwElementID, LPCSTR lpstrType)
|
|
|
|
{
|
|
|
|
LPWSTR w = MCI_strdupAtoW(lpstrType);
|
|
|
|
UINT ret = 0;
|
|
|
|
|
|
|
|
if (w)
|
|
|
|
{
|
|
|
|
ret = mciGetDeviceIDFromElementIDW(dwElementID, w);
|
|
|
|
HeapFree(GetProcessHeap(), 0, w);
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetDeviceIDFromElementIDW [WINMM.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI mciGetDeviceIDFromElementIDW(DWORD dwElementID, LPCWSTR lpstrType)
|
|
|
|
{
|
|
|
|
/* FIXME: that's rather strange, there is no
|
|
|
|
* mciGetDeviceIDFromElementID32A in winmm.spec
|
|
|
|
*/
|
2006-11-08 22:24:36 +01:00
|
|
|
FIXME("(%u, %s) stub\n", dwElementID, debugstr_w(lpstrType));
|
2005-02-09 23:26:25 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetYieldProc [WINMM.@]
|
|
|
|
*/
|
|
|
|
YIELDPROC WINAPI mciGetYieldProc(MCIDEVICEID uDeviceID, DWORD* lpdwYieldData)
|
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
|
|
|
|
TRACE("(%u, %p)\n", uDeviceID, lpdwYieldData);
|
|
|
|
|
|
|
|
if (!(wmd = MCI_GetDriver(uDeviceID))) {
|
|
|
|
WARN("Bad uDeviceID\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!wmd->lpfnYieldProc) {
|
|
|
|
WARN("No proc set\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
2009-10-04 14:31:04 +02:00
|
|
|
if (lpdwYieldData) *lpdwYieldData = wmd->dwYieldData;
|
2005-02-09 23:26:25 +01:00
|
|
|
return wmd->lpfnYieldProc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciGetCreatorTask [WINMM.@]
|
|
|
|
*/
|
|
|
|
HTASK WINAPI mciGetCreatorTask(MCIDEVICEID uDeviceID)
|
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
HTASK ret = 0;
|
|
|
|
|
2010-01-23 18:56:50 +01:00
|
|
|
if ((wmd = MCI_GetDriver(uDeviceID))) ret = (HTASK)(DWORD_PTR)wmd->CreatorThread;
|
2005-02-09 23:26:25 +01:00
|
|
|
|
|
|
|
TRACE("(%u) => %p\n", uDeviceID, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* mciDriverYield [WINMM.@]
|
|
|
|
*/
|
|
|
|
UINT WINAPI mciDriverYield(MCIDEVICEID uDeviceID)
|
|
|
|
{
|
|
|
|
LPWINE_MCIDRIVER wmd;
|
|
|
|
UINT ret = 0;
|
|
|
|
|
|
|
|
TRACE("(%04x)\n", uDeviceID);
|
|
|
|
|
2009-10-17 12:05:04 +02:00
|
|
|
if (!(wmd = MCI_GetDriver(uDeviceID)) || !wmd->lpfnYieldProc) {
|
2009-11-12 21:52:55 +01:00
|
|
|
MSG msg;
|
|
|
|
PeekMessageW(&msg, 0, 0, 0, PM_REMOVE | PM_QS_SENDMESSAGE);
|
2005-02-09 23:26:25 +01:00
|
|
|
} else {
|
|
|
|
ret = wmd->lpfnYieldProc(uDeviceID, wmd->dwYieldData);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|