Clean up *GetDevCaps to check for valid pointer and only copy proper

amount of data.
This commit is contained in:
Robert Reif 2003-10-30 23:07:23 +00:00 committed by Alexandre Julliard
parent 0f252372b7
commit b4e9ef02c2
3 changed files with 147 additions and 105 deletions

View File

@ -465,7 +465,7 @@ UINT MMDRV_PhysicalFeatures(LPWINE_MLD mld, UINT uMsg, DWORD dwParam1,
{
WINE_MM_DRIVER* lpDrv = &MMDrvs[mld->mmdIndex];
TRACE("(%p, %04x, %08lx, %08lx)\n", mld, uMsg, dwParam1, dwParam2);
TRACE("(%p, %04x, %08lx, %08lx, %d)\n", mld, uMsg, dwParam1, dwParam2, bFrom32);
/* all those function calls are undocumented */
switch (uMsg) {

View File

@ -215,12 +215,15 @@ UINT16 WINAPI mixerGetNumDevs16(void)
/**************************************************************************
* mixerGetDevCaps [MMSYSTEM.801]
*/
UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
UINT16 size)
UINT16 WINAPI mixerGetDevCaps16(UINT16 uDeviceID, LPMIXERCAPS16 lpCaps,
UINT16 uSize)
{
MIXERCAPSA micA;
UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
UINT ret;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = mixerGetDevCapsA(uDeviceID, &micA, sizeof(micA));
if (ret == MMSYSERR_NOERROR) {
MIXERCAPS16 mic16;
mic16.wMid = micA.wMid;
@ -229,7 +232,7 @@ UINT16 WINAPI mixerGetDevCaps16(UINT16 devid, LPMIXERCAPS16 mixcaps,
strcpy(mic16.szPname, micA.szPname);
mic16.fdwSupport = micA.fdwSupport;
mic16.cDestinations = micA.cDestinations;
memcpy(mixcaps, &mic16, min(size, sizeof(mic16)));
memcpy(lpCaps, &mic16, min(uSize, sizeof(mic16)));
}
return ret;
}
@ -453,13 +456,23 @@ UINT16 WINAPI auxGetNumDevs16(void)
*/
UINT16 WINAPI auxGetDevCaps16(UINT16 uDeviceID, LPAUXCAPS16 lpCaps, UINT16 uSize)
{
LPWINE_MLD wmld;
AUXCAPSA acA;
UINT ret;
TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get((HANDLE)(ULONG_PTR)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
ret = auxGetDevCapsA(uDeviceID, &acA, sizeof(acA));
if (ret == MMSYSERR_NOERROR) {
AUXCAPS16 ac16;
ac16.wMid = acA.wMid;
ac16.wPid = acA.wPid;
ac16.vDriverVersion = acA.vDriverVersion;
strcpy(ac16.szPname, acA.szPname);
ac16.wTechnology = acA.wTechnology;
ac16.dwSupport = acA.dwSupport;
memcpy(lpCaps, &ac16, min(uSize, sizeof(ac16)));
}
return ret;
}
/**************************************************************************
@ -691,24 +704,26 @@ UINT16 WINAPI midiOutGetNumDevs16(void)
UINT16 WINAPI midiOutGetDevCaps16(UINT16 uDeviceID, LPMIDIOUTCAPS16 lpCaps,
UINT16 uSize)
{
MIDIOUTCAPSA capsA;
UINT dwRet;
MIDIOUTCAPSA mocA;
UINT ret;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
dwRet = midiOutGetDevCapsA(uDeviceID, &capsA, sizeof(capsA));
if (dwRet == MMSYSERR_NOERROR) {
lpCaps->wMid = capsA.wMid;
lpCaps->wPid = capsA.wPid;
lpCaps->vDriverVersion = capsA.vDriverVersion;
strcpy(lpCaps->szPname, capsA.szPname);
lpCaps->wTechnology = capsA.wTechnology;
lpCaps->wVoices = capsA.wVoices;
lpCaps->wNotes = capsA.wNotes;
lpCaps->wChannelMask = capsA.wChannelMask;
lpCaps->dwSupport = capsA.dwSupport;
ret = midiOutGetDevCapsA(uDeviceID, &mocA, sizeof(mocA));
if (ret == MMSYSERR_NOERROR) {
MIDIOUTCAPS16 moc16;
moc16.wMid = mocA.wMid;
moc16.wPid = mocA.wPid;
moc16.vDriverVersion = mocA.vDriverVersion;
strcpy(moc16.szPname, mocA.szPname);
moc16.wTechnology = mocA.wTechnology;
moc16.wVoices = mocA.wVoices;
moc16.wNotes = mocA.wNotes;
moc16.wChannelMask = mocA.wChannelMask;
moc16.dwSupport = mocA.dwSupport;
memcpy(lpCaps, &moc16, min(uSize, sizeof(moc16)));
}
return dwRet;
return ret;
}
/**************************************************************************
@ -913,16 +928,20 @@ UINT16 WINAPI midiInGetDevCaps16(UINT16 uDeviceID, LPMIDIINCAPS16 lpCaps,
UINT16 uSize)
{
MIDIINCAPSA micA;
UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
UINT ret;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = micA.wMid;
lpCaps->wPid = micA.wPid;
lpCaps->vDriverVersion = micA.vDriverVersion;
strcpy(lpCaps->szPname, micA.szPname);
lpCaps->dwSupport = micA.dwSupport;
MIDIINCAPS16 mic16;
mic16.wMid = micA.wMid;
mic16.wPid = micA.wPid;
mic16.vDriverVersion = micA.vDriverVersion;
strcpy(mic16.szPname, micA.szPname);
mic16.dwSupport = micA.dwSupport;
memcpy(lpCaps, &mic16, min(uSize, sizeof(mic16)));
}
return ret;
}
@ -1195,21 +1214,20 @@ UINT16 WINAPI waveOutGetDevCaps16(UINT16 uDeviceID,
{
WAVEOUTCAPSA wocA;
UINT ret;
TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
if (ret == MMSYSERR_NOERROR) {
WAVEOUTCAPS16 woc16;
woc16.wMid = wocA.wMid;
woc16.wPid = wocA.wPid;
woc16.wMid = wocA.wMid;
woc16.wPid = wocA.wPid;
woc16.vDriverVersion = wocA.vDriverVersion;
strcpy(woc16.szPname, wocA.szPname);
woc16.dwFormats = wocA.dwFormats;
woc16.wChannels = wocA.wChannels;
woc16.dwSupport = wocA.dwSupport;
woc16.dwFormats = wocA.dwFormats;
woc16.wChannels = wocA.wChannels;
woc16.dwSupport = wocA.dwSupport;
memcpy(lpCaps, &woc16, min(uSize, sizeof(woc16)));
}
return ret;
@ -1494,18 +1512,19 @@ UINT16 WINAPI waveInGetDevCaps16(UINT16 uDeviceID, LPWAVEINCAPS16 lpCaps,
UINT16 uSize)
{
WAVEINCAPSA wicA;
UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
UINT ret;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA));
if (ret == MMSYSERR_NOERROR) {
WAVEINCAPS16 wic16;
wic16.wMid = wicA.wMid;
wic16.wPid = wicA.wPid;
wic16.wMid = wicA.wMid;
wic16.wPid = wicA.wPid;
wic16.vDriverVersion = wicA.vDriverVersion;
strcpy(wic16.szPname, wicA.szPname);
wic16.dwFormats = wicA.dwFormats;
wic16.wChannels = wicA.wChannels;
wic16.dwFormats = wicA.dwFormats;
wic16.wChannels = wicA.wChannels;
memcpy(lpCaps, &wic16, min(uSize, sizeof(wic16)));
}
return ret;
@ -2539,13 +2558,18 @@ MMRESULT16 WINAPI timeGetDevCaps16(LPTIMECAPS16 lpCaps, UINT16 wSize)
{
TIMECAPS caps;
MMRESULT ret;
TRACE("(%p, %u) !\n", lpCaps, wSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = timeGetDevCaps(&caps, sizeof(caps));
lpCaps->wPeriodMin = caps.wPeriodMin;
lpCaps->wPeriodMax = caps.wPeriodMax;
return 0;
if (ret == MMSYSERR_NOERROR) {
TIMECAPS16 tc16;
tc16.wPeriodMin = caps.wPeriodMin;
tc16.wPeriodMax = caps.wPeriodMax;
memcpy(lpCaps, &tc16, min(wSize, sizeof(tc16)));
}
return ret;
}
/**************************************************************************

View File

@ -228,32 +228,36 @@ UINT WINAPI mixerGetNumDevs(void)
/**************************************************************************
* mixerGetDevCapsA [WINMM.@]
*/
UINT WINAPI mixerGetDevCapsA(UINT devid, LPMIXERCAPSA mixcaps, UINT size)
UINT WINAPI mixerGetDevCapsA(UINT uDeviceID, LPMIXERCAPSA lpCaps, UINT uSize)
{
LPWINE_MLD wmld;
if ((wmld = MMDRV_Get((HANDLE)devid, MMDRV_MIXER, TRUE)) == NULL)
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get((HANDLE)uDeviceID, MMDRV_MIXER, TRUE)) == NULL)
return MMSYSERR_BADDEVICEID;
return MMDRV_Message(wmld, MXDM_GETDEVCAPS, (DWORD)mixcaps, size, TRUE);
return MMDRV_Message(wmld, MXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
}
/**************************************************************************
* mixerGetDevCapsW [WINMM.@]
*/
UINT WINAPI mixerGetDevCapsW(UINT devid, LPMIXERCAPSW mixcaps, UINT size)
UINT WINAPI mixerGetDevCapsW(UINT uDeviceID, LPMIXERCAPSW lpCaps, UINT uSize)
{
MIXERCAPSA micA;
UINT ret = mixerGetDevCapsA(devid, &micA, sizeof(micA));
UINT ret = mixerGetDevCapsA(uDeviceID, &micA, sizeof(micA));
if (ret == MMSYSERR_NOERROR) {
mixcaps->wMid = micA.wMid;
mixcaps->wPid = micA.wPid;
mixcaps->vDriverVersion = micA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, mixcaps->szPname,
sizeof(mixcaps->szPname)/sizeof(WCHAR) );
mixcaps->fdwSupport = micA.fdwSupport;
mixcaps->cDestinations = micA.cDestinations;
MIXERCAPSW micW;
micW.wMid = micA.wMid;
micW.wPid = micA.wPid;
micW.vDriverVersion = micA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, micW.szPname,
sizeof(micW.szPname)/sizeof(WCHAR) );
micW.fdwSupport = micA.fdwSupport;
micW.cDestinations = micA.cDestinations;
memcpy(lpCaps, &micW, min(uSize, sizeof(micW)));
}
return ret;
}
@ -625,13 +629,17 @@ UINT WINAPI auxGetDevCapsW(UINT uDeviceID, LPAUXCAPSW lpCaps, UINT uSize)
AUXCAPSA acA;
UINT ret = auxGetDevCapsA(uDeviceID, &acA, sizeof(acA));
lpCaps->wMid = acA.wMid;
lpCaps->wPid = acA.wPid;
lpCaps->vDriverVersion = acA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, acA.szPname, -1, lpCaps->szPname,
sizeof(lpCaps->szPname)/sizeof(WCHAR) );
lpCaps->wTechnology = acA.wTechnology;
lpCaps->dwSupport = acA.dwSupport;
if (ret == MMSYSERR_NOERROR) {
AUXCAPSW acW;
acW.wMid = acA.wMid;
acW.wPid = acA.wPid;
acW.vDriverVersion = acA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, acA.szPname, -1, acW.szPname,
sizeof(acW.szPname)/sizeof(WCHAR) );
acW.wTechnology = acA.wTechnology;
acW.dwSupport = acA.dwSupport;
memcpy(lpCaps, &acW, min(uSize, sizeof(acW)));
}
return ret;
}
@ -644,6 +652,8 @@ UINT WINAPI auxGetDevCapsA(UINT uDeviceID, LPAUXCAPSA lpCaps, UINT uSize)
TRACE("(%04X, %p, %d) !\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get((HANDLE)uDeviceID, MMDRV_AUX, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
return MMDRV_Message(wmld, AUXDM_GETDEVCAPS, (DWORD)lpCaps, uSize, TRUE);
@ -952,19 +962,22 @@ UINT WINAPI midiOutGetDevCapsW(UINT uDeviceID, LPMIDIOUTCAPSW lpCaps,
UINT uSize)
{
MIDIOUTCAPSA mocA;
UINT ret;
UINT ret = midiOutGetDevCapsA(uDeviceID, &mocA, sizeof(mocA));
ret = midiOutGetDevCapsA(uDeviceID, &mocA, sizeof(mocA));
lpCaps->wMid = mocA.wMid;
lpCaps->wPid = mocA.wPid;
lpCaps->vDriverVersion = mocA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, mocA.szPname, -1, lpCaps->szPname,
sizeof(lpCaps->szPname)/sizeof(WCHAR) );
lpCaps->wTechnology = mocA.wTechnology;
lpCaps->wVoices = mocA.wVoices;
lpCaps->wNotes = mocA.wNotes;
lpCaps->wChannelMask = mocA.wChannelMask;
lpCaps->dwSupport = mocA.dwSupport;
if (ret == MMSYSERR_NOERROR) {
MIDIOUTCAPSW mocW;
mocW.wMid = mocA.wMid;
mocW.wPid = mocA.wPid;
mocW.vDriverVersion = mocA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, mocA.szPname, -1, mocW.szPname,
sizeof(mocW.szPname)/sizeof(WCHAR) );
mocW.wTechnology = mocA.wTechnology;
mocW.wVoices = mocA.wVoices;
mocW.wNotes = mocA.wNotes;
mocW.wChannelMask = mocA.wChannelMask;
mocW.dwSupport = mocA.dwSupport;
memcpy(lpCaps, &mocW, min(uSize, sizeof(mocW)));
}
return ret;
}
@ -1323,12 +1336,14 @@ UINT WINAPI midiInGetDevCapsW(UINT uDeviceID, LPMIDIINCAPSW lpCaps, UINT uSize)
UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize);
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = micA.wMid;
lpCaps->wPid = micA.wPid;
lpCaps->vDriverVersion = micA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, lpCaps->szPname,
sizeof(lpCaps->szPname)/sizeof(WCHAR) );
lpCaps->dwSupport = micA.dwSupport;
MIDIINCAPSW micW;
micW.wMid = micA.wMid;
micW.wPid = micA.wPid;
micW.vDriverVersion = micA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, micA.szPname, -1, micW.szPname,
sizeof(micW.szPname)/sizeof(WCHAR) );
micW.dwSupport = micA.dwSupport;
memcpy(lpCaps, &micW, min(uSize, sizeof(micW)));
}
return ret;
}
@ -1342,6 +1357,8 @@ UINT WINAPI midiInGetDevCapsA(UINT uDeviceID, LPMIDIINCAPSA lpCaps, UINT uSize)
TRACE("(%d, %p, %d);\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get((HANDLE)uDeviceID, MMDRV_MIDIIN, TRUE)) == NULL)
return MMSYSERR_INVALHANDLE;
@ -2266,21 +2283,19 @@ UINT WINAPI waveOutGetDevCapsW(UINT uDeviceID, LPWAVEOUTCAPSW lpCaps,
UINT uSize)
{
WAVEOUTCAPSA wocA;
UINT ret;
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
UINT ret = waveOutGetDevCapsA(uDeviceID, &wocA, sizeof(wocA));
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = wocA.wMid;
lpCaps->wPid = wocA.wPid;
lpCaps->vDriverVersion = wocA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, wocA.szPname, -1, lpCaps->szPname,
sizeof(lpCaps->szPname)/sizeof(WCHAR) );
lpCaps->dwFormats = wocA.dwFormats;
lpCaps->wChannels = wocA.wChannels;
lpCaps->dwSupport = wocA.dwSupport;
WAVEOUTCAPSW wocW;
wocW.wMid = wocA.wMid;
wocW.wPid = wocA.wPid;
wocW.vDriverVersion = wocA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, wocA.szPname, -1, wocW.szPname,
sizeof(wocW.szPname)/sizeof(WCHAR) );
wocW.dwFormats = wocA.dwFormats;
wocW.wChannels = wocA.wChannels;
wocW.dwSupport = wocA.dwSupport;
memcpy(lpCaps, &wocW, min(uSize, sizeof(wocW)));
}
return ret;
}
@ -2634,15 +2649,16 @@ UINT WINAPI waveInGetDevCapsW(UINT uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize)
UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, uSize);
if (ret == MMSYSERR_NOERROR) {
lpCaps->wMid = wicA.wMid;
lpCaps->wPid = wicA.wPid;
lpCaps->vDriverVersion = wicA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, wicA.szPname, -1, lpCaps->szPname,
sizeof(lpCaps->szPname)/sizeof(WCHAR) );
lpCaps->dwFormats = wicA.dwFormats;
lpCaps->wChannels = wicA.wChannels;
WAVEINCAPSW wicW;
wicW.wMid = wicA.wMid;
wicW.wPid = wicA.wPid;
wicW.vDriverVersion = wicA.vDriverVersion;
MultiByteToWideChar( CP_ACP, 0, wicA.szPname, -1, wicW.szPname,
sizeof(wicW.szPname)/sizeof(WCHAR) );
wicW.dwFormats = wicA.dwFormats;
wicW.wChannels = wicA.wChannels;
memcpy(lpCaps, &wicW, min(uSize, sizeof(wicW)));
}
return ret;
}
@ -2655,6 +2671,8 @@ UINT WINAPI waveInGetDevCapsA(UINT uDeviceID, LPWAVEINCAPSA lpCaps, UINT uSize)
TRACE("(%u %p %u)!\n", uDeviceID, lpCaps, uSize);
if (lpCaps == NULL) return MMSYSERR_INVALPARAM;
if ((wmld = MMDRV_Get((HANDLE)uDeviceID, MMDRV_WAVEIN, TRUE)) == NULL)
return MMSYSERR_BADDEVICEID;