Commit a9f9b34e authored by Jörg Höhle's avatar Jörg Höhle Committed by Alexandre Julliard

winmm: MCI_SYSINFO doesn't change the output buffer in case of error.

parent 88a8d211
......@@ -1843,7 +1843,6 @@ static DWORD MCI_WriteString(LPWSTR lpDstStr, DWORD dstSize, LPCWSTR lpSrcStr)
if (lpSrcStr) {
if (dstSize <= strlenW(lpSrcStr)) {
lstrcpynW(lpDstStr, lpSrcStr, dstSize - 1);
ret = MCIERR_PARAM_OVERFLOW;
} else {
strcpyW(lpDstStr, lpSrcStr);
......@@ -1931,7 +1930,6 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSW lpParm
ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize,
wmd->lpstrDeviceType);
} else {
*lpParms->lpstrReturn = 0;
ret = (uDevID == MCI_ALL_DEVICE_ID)
? MCIERR_CANNOT_USE_ALL : MCIERR_INVALID_DEVICE_NAME;
}
......
......@@ -162,6 +162,13 @@ static void test_notification_dbg(HWND hwnd, const char* command, WPARAM type, i
else ok_(__FILE__,line)(msg.wParam == type, "got %04lx instead of MCI_NOTIFY_xyz %04lx from command %s\n", msg.wParam, type, command);
}
static int strcmp_wa(LPCWSTR strw, const char *stra)
{
CHAR buf[512];
WideCharToMultiByte(CP_ACP, 0, strw, -1, buf, sizeof(buf), 0, 0);
return lstrcmpA(buf, stra);
}
static void test_mciParser(HWND hwnd)
{
MCIERROR err;
......@@ -385,6 +392,9 @@ static void test_openCloseWAVE(HWND hwnd)
ok(!err,"mci close shareable returned %s\n", dbg_mcierr(err));
}
err = mciGetDeviceID("waveaudio");
ok(err==0,"mciGetDeviceID waveaudio returned %u, expected 0\n", err);
err = mciSendString(command_open, buf, sizeof(buf), hwnd);
ok(!err,"mci %s returned %s\n", command_open, dbg_mcierr(err));
ok(!strcmp(buf,"1"), "mci open deviceId: %s, expected 1\n", buf);
......@@ -427,24 +437,27 @@ static void test_openCloseWAVE(HWND hwnd)
/* MCI_..._PARMSA and PARMSW share the same layout, use one for both tests. */
err = mciSendCommandW(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
ok(!err || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open buffer[8]: %s\n", dbg_mcierr(err));
/* TODO strcmpW((LPWSTR)buf,"mysound") */
if(!err) ok(!strcmp_wa((LPWSTR)buf,"mysound"), "sysinfo name 1 open contents\n");
buf[0] = 'Y';
parm.sys.dwNumber = 1;
parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
parm.sys.lpstrReturn = buf;
parm.sys.dwRetSize = 7; /* too short for mysound\0 */
err = mciSendCommandW(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
ok(err==MCIERR_PARAM_OVERFLOW || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommandW MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
ok(!strcmp(buf,"Y"), "output buffer %s\n", buf);
/* Win9x overwrites the tiny buffer and returns success, newer versions signal overflow. */
memset(buf, 0, sizeof(buf));
buf[0] = 'Y';
parm.sys.dwNumber = 1;
parm.sys.wDeviceType = MCI_DEVTYPE_WAVEFORM_AUDIO; /* ignored */
parm.sys.lpstrReturn = buf;
parm.sys.dwRetSize = 2; /* too short for mysound\0 */
err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_NAME | MCI_SYSINFO_OPEN, (DWORD_PTR)&parm);
ok(err==MCIERR_PARAM_OVERFLOW || broken(!err /* Win9x */),"mciCommand MCI_SYSINFO all name 1 open too small: %s\n", dbg_mcierr(err));
if(!err) ok(!strcmp(buf,"mysound"), "sysinfo short name returned %s\n", buf);
ok(!strcmp(buf, err ? "Y" : "mysound"), "sysinfo short name returned %s\n", buf);
err = mciSendString("sysinfo mysound quantity open", buf, sizeof(buf), hwnd);
ok(err==MCIERR_DEVICE_TYPE_REQUIRED,"sysinfo alias quantity: %s\n", dbg_mcierr(err));
......@@ -455,12 +468,26 @@ static void test_openCloseWAVE(HWND hwnd)
err = mciSendString("sysinfo all installname", buf, sizeof(buf), hwnd);
ok(err==MCIERR_CANNOT_USE_ALL,"sysinfo all installname: %s\n", dbg_mcierr(err));
buf[0] = 'M'; buf[1] = 0;
parm.sys.lpstrReturn = buf;
parm.sys.dwRetSize = sizeof(buf);
err = mciSendCommand(MCI_ALL_DEVICE_ID, MCI_SYSINFO, MCI_SYSINFO_INSTALLNAME, (DWORD_PTR)&parm);
ok(err==MCIERR_CANNOT_USE_ALL,"mciCommand MCI_SYSINFO all installname: %s\n", dbg_mcierr(err));
ok(!strcmp(buf,"M"), "output buffer %s\n", buf);
err = mciSendString("sysinfo nodev installname", buf, sizeof(buf), hwnd);
ok(err==MCIERR_INVALID_DEVICE_NAME,"sysinfo nodev installname: %s\n", dbg_mcierr(err));
ok(!buf[0], "sysinfo error buffer %s\n", buf);
buf[0] = 'K';
parm.sys.lpstrReturn = buf;
parm.sys.dwRetSize = sizeof(buf);
err = mciSendCommandW(24000, MCI_SYSINFO, MCI_SYSINFO_INSTALLNAME, (DWORD_PTR)&parm);
ok(err==MCIERR_INVALID_DEVICE_NAME || broken(err==MMSYSERR_NOTSUPPORTED/* Win9x */), "mciCommand MCI_SYSINFO nodev installname: %s\n", dbg_mcierr(err));
ok(!strcmp(buf,"K"), "output buffer %s\n", buf);
err = mciGetDeviceID("all");
ok(MCI_ALL_DEVICE_ID==err || /* Win9x */(UINT16)MCI_ALL_DEVICE_ID==err,"mciGetDeviceID all returned %u, expected %d\n", err, MCI_ALL_DEVICE_ID);
ok(MCI_ALL_DEVICE_ID==err || /* Win9x */(WORD)MCI_ALL_DEVICE_ID==err,"mciGetDeviceID all returned %u, expected %d\n", err, MCI_ALL_DEVICE_ID);
err = mciSendString(command_close_my, NULL, 0, hwnd);
ok(!err,"mci %s returned %s\n", command_close_my, dbg_mcierr(err));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment