Better function parameter checking.
This commit is contained in:
parent
2f0a4ac46d
commit
445fc35e20
|
@ -132,29 +132,38 @@ MMRESULT WINAPI acmDriverDetailsA(HACMDRIVERID hadid, PACMDRIVERDETAILSA padd, D
|
|||
MMRESULT mmr;
|
||||
ACMDRIVERDETAILSW addw;
|
||||
|
||||
if (!padd)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (padd->cbStruct < 4)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
addw.cbStruct = sizeof(addw);
|
||||
mmr = acmDriverDetailsW(hadid, &addw, fdwDetails);
|
||||
if (mmr == 0) {
|
||||
padd->fccType = addw.fccType;
|
||||
padd->fccComp = addw.fccComp;
|
||||
padd->wMid = addw.wMid;
|
||||
padd->wPid = addw.wPid;
|
||||
padd->vdwACM = addw.vdwACM;
|
||||
padd->vdwDriver = addw.vdwDriver;
|
||||
padd->fdwSupport = addw.fdwSupport;
|
||||
padd->cFormatTags = addw.cFormatTags;
|
||||
padd->cFilterTags = addw.cFilterTags;
|
||||
padd->hicon = addw.hicon;
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szShortName, -1, padd->szShortName,
|
||||
sizeof(padd->szShortName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szLongName, -1, padd->szLongName,
|
||||
sizeof(padd->szLongName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szCopyright, -1, padd->szCopyright,
|
||||
sizeof(padd->szCopyright), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szLicensing, -1, padd->szLicensing,
|
||||
sizeof(padd->szLicensing), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szFeatures, -1, padd->szFeatures,
|
||||
sizeof(padd->szFeatures), NULL, NULL );
|
||||
ACMDRIVERDETAILSA padda;
|
||||
|
||||
padda.fccType = addw.fccType;
|
||||
padda.fccComp = addw.fccComp;
|
||||
padda.wMid = addw.wMid;
|
||||
padda.wPid = addw.wPid;
|
||||
padda.vdwACM = addw.vdwACM;
|
||||
padda.vdwDriver = addw.vdwDriver;
|
||||
padda.fdwSupport = addw.fdwSupport;
|
||||
padda.cFormatTags = addw.cFormatTags;
|
||||
padda.cFilterTags = addw.cFilterTags;
|
||||
padda.hicon = addw.hicon;
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szShortName, -1, padda.szShortName,
|
||||
sizeof(padda.szShortName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szLongName, -1, padda.szLongName,
|
||||
sizeof(padda.szLongName), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szCopyright, -1, padda.szCopyright,
|
||||
sizeof(padda.szCopyright), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szLicensing, -1, padda.szLicensing,
|
||||
sizeof(padda.szLicensing), NULL, NULL );
|
||||
WideCharToMultiByte( CP_ACP, 0, addw.szFeatures, -1, padda.szFeatures,
|
||||
sizeof(padda.szFeatures), NULL, NULL );
|
||||
memcpy(padd, &padda, min(padd->cbStruct, sizeof(*padd)));
|
||||
}
|
||||
return mmr;
|
||||
}
|
||||
|
@ -167,14 +176,22 @@ MMRESULT WINAPI acmDriverDetailsW(HACMDRIVERID hadid, PACMDRIVERDETAILSW padd, D
|
|||
HACMDRIVER acmDrvr;
|
||||
MMRESULT mmr;
|
||||
|
||||
if (!padd)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (padd->cbStruct < 4)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (fdwDetails)
|
||||
return MMSYSERR_INVALFLAG;
|
||||
|
||||
mmr = acmDriverOpen(&acmDrvr, hadid, 0);
|
||||
if (mmr == MMSYSERR_NOERROR) {
|
||||
mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)padd, 0);
|
||||
ACMDRIVERDETAILSW paddw;
|
||||
mmr = (MMRESULT)MSACM_Message(acmDrvr, ACMDM_DRIVER_DETAILS, (LPARAM)&paddw, 0);
|
||||
|
||||
acmDriverClose(acmDrvr, 0);
|
||||
memcpy(padd, &paddw, min(padd->cbStruct, sizeof(*padd)));
|
||||
}
|
||||
|
||||
return mmr;
|
||||
|
@ -216,9 +233,6 @@ MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID
|
|||
{
|
||||
PWINE_ACMOBJ pao;
|
||||
|
||||
if (!phadid)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (fdwDriverID)
|
||||
return MMSYSERR_INVALFLAG;
|
||||
|
||||
|
@ -226,6 +240,9 @@ MMRESULT WINAPI acmDriverID(HACMOBJ hao, PHACMDRIVERID phadid, DWORD fdwDriverID
|
|||
if (!pao)
|
||||
return MMSYSERR_INVALHANDLE;
|
||||
|
||||
if (!phadid)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
*phadid = (HACMDRIVERID) pao->pACMDriverID;
|
||||
|
||||
return MMSYSERR_NOERROR;
|
||||
|
|
|
@ -411,6 +411,12 @@ MMRESULT WINAPI acmFormatEnumA(HACMDRIVER had, PACMFORMATDETAILSA pafda,
|
|||
ACMFORMATDETAILSW afdw;
|
||||
struct MSACM_FormatEnumWtoA_Instance afei;
|
||||
|
||||
if (!pafda)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (pafda->cbStruct < sizeof(*pafda))
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
memset(&afdw, 0, sizeof(afdw));
|
||||
afdw.cbStruct = sizeof(afdw);
|
||||
afdw.dwFormatIndex = pafda->dwFormatIndex;
|
||||
|
@ -489,7 +495,11 @@ MMRESULT WINAPI acmFormatEnumW(HACMDRIVER had, PACMFORMATDETAILSW pafd,
|
|||
TRACE("(%p, %p, %p, %ld, %ld)\n",
|
||||
had, pafd, fnCallback, dwInstance, fdwEnum);
|
||||
|
||||
if (pafd->cbStruct < sizeof(*pafd)) return MMSYSERR_INVALPARAM;
|
||||
if (!pafd)
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (pafd->cbStruct < sizeof(*pafd))
|
||||
return MMSYSERR_INVALPARAM;
|
||||
|
||||
if (fdwEnum & (ACM_FORMATENUMF_WFORMATTAG|ACM_FORMATENUMF_NCHANNELS|
|
||||
ACM_FORMATENUMF_NSAMPLESPERSEC|ACM_FORMATENUMF_WBITSPERSAMPLE|
|
||||
|
|
|
@ -120,6 +120,7 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
/* fall through */
|
||||
case ACM_METRIC_COUNT_LOCAL_DRIVERS:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
|
||||
if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
|
||||
val++;
|
||||
|
@ -131,6 +132,7 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
/* fall through */
|
||||
case ACM_METRIC_COUNT_LOCAL_CODECS:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
|
||||
if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
|
||||
(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CODEC) &&
|
||||
|
@ -144,6 +146,7 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
/* fall through */
|
||||
case ACM_METRIC_COUNT_LOCAL_CONVERTERS:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
|
||||
if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
|
||||
(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_CONVERTER) &&
|
||||
|
@ -157,6 +160,7 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
/* fall through */
|
||||
case ACM_METRIC_COUNT_LOCAL_FILTERS:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
|
||||
if (!(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) &&
|
||||
(padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_FILTER) &&
|
||||
|
@ -170,6 +174,7 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
/* fall through */
|
||||
case ACM_METRIC_COUNT_LOCAL_DISABLED:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
for (padid = MSACM_pFirstACMDriverID; padid; padid = padid->pNextACMDriverID)
|
||||
if ((padid->fdwSupport & ACMDRIVERDETAILS_SUPPORTF_DISABLED) && CheckLocal(padid))
|
||||
val++;
|
||||
|
@ -204,10 +209,17 @@ MMRESULT WINAPI acmMetrics(HACMOBJ hao, UINT uMetric, LPVOID pMetric)
|
|||
} else {
|
||||
return MMSYSERR_INVALHANDLE;
|
||||
}
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
*(LPDWORD)pMetric = val;
|
||||
break;
|
||||
|
||||
case ACM_METRIC_COUNT_HARDWARE:
|
||||
if (hao) return MMSYSERR_INVALHANDLE;
|
||||
if (!pMetric) return MMSYSERR_INVALPARAM;
|
||||
*(LPDWORD)pMetric = 0;
|
||||
FIXME("ACM_METRIC_COUNT_HARDWARE not implemented\n");
|
||||
break;
|
||||
|
||||
case ACM_METRIC_HARDWARE_WAVE_INPUT:
|
||||
case ACM_METRIC_HARDWARE_WAVE_OUTPUT:
|
||||
case ACM_METRIC_MAX_SIZE_FILTER:
|
||||
|
|
Loading…
Reference in New Issue