[PATCH] dlls/msacm32: use extended structure definition for driver configuration

Andrew Eikum aeikum at codeweavers.com
Mon Feb 14 14:23:04 CST 2022


Signed-off-by: Andrew Eikum <aeikum at codeweavers.com>

On Fri, Feb 11, 2022 at 06:49:45PM +0100, Eric Pouech wrote:
> 1a) fixes a too short memory allocation on 64bit (DRVCONFIGINFO is 20 byte
>     large while only 16 bytes were allocated)
> 1b) incidentally, removes a bunch of GCC11 warnings (generated by 1a)
> 2)  introduces DRVCONFIGINFOEX (note, in SDK, it's defined in mmiscapi.h;
>     since it doesn't exist yet in Wine, I added the structure to
>     mmsystem.h, where DRVCONFIGINFO already exists)
> 3)  initializes the missing field
> 
> Note: my testing don't show on Win10's msacm32 that DRV_CONFIGURE uses the
> DRVCONFIGINFOEX structure.
> So, maybe (wild guess here), the extended structure is only used
> when the driver is linked to some hardware.
> 
> Signed-off-by: Eric Pouech <eric.pouech at gmail.com>
> 
> ---
>  dlls/msacm32/driver.c |   18 +++++++++---------
>  include/mmsystem.h    |    6 ++++++
>  2 files changed, 15 insertions(+), 9 deletions(-)
> 
> diff --git a/dlls/msacm32/driver.c b/dlls/msacm32/driver.c
> index a8d6f3cf6d7..036461800b1 100644
> --- a/dlls/msacm32/driver.c
> +++ b/dlls/msacm32/driver.c
> @@ -400,7 +400,7 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
>      {
>          PWINE_ACMDRIVERID padid;
>          LRESULT lResult;
> -        LPDRVCONFIGINFO pConfigInfo = NULL;
> +        LPDRVCONFIGINFOEX pConfigInfo = NULL;
>          LPWSTR section_name = NULL;
>          LPWSTR alias_name = NULL;
>  
> @@ -425,16 +425,15 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
>              }
>          
>              if (pAlias != NULL) {
> -                /* DRVCONFIGINFO is only 12 bytes long, but native msacm
> -                 * reports a 16-byte structure to codecs, so allocate 16 bytes,
> -                 * just to be on the safe side.
> -                 */
> -                const unsigned int iStructSize = 16;
> -                pConfigInfo = HeapAlloc(MSACM_hHeap, 0, iStructSize);
> +                pConfigInfo = HeapAlloc(MSACM_hHeap, 0, sizeof(*pConfigInfo));
>                  if (!pConfigInfo) {
> -                    ERR("OOM while supplying DRVCONFIGINFO for DRV_CONFIGURE, using NULL\n");
> +                    ERR("OOM while supplying DRVCONFIGINFOEX for DRV_CONFIGURE, using NULL\n");
>                  } else {
> -                    pConfigInfo->dwDCISize = iStructSize;
> +                    /* In some cases (seen in the 32bit world), a DRVCONFIGINFOEX struct is passed
> +                     * (with extended size) instead of the documented DRVCONFIGINFO.
> +                     * So, always pass a DRVCONFIGINFOEX to be one the safe side
> +                     */
> +                    pConfigInfo->dwDCISize = sizeof(*pConfigInfo);
>  
>                      section_name = HeapAlloc(MSACM_hHeap, 0, sizeof(L"Drivers32"));
>                      if (section_name) lstrcpyW(section_name, L"Drivers32");
> @@ -442,6 +441,7 @@ LRESULT WINAPI acmDriverMessage(HACMDRIVER had, UINT uMsg, LPARAM lParam1, LPARA
>                      alias_name = HeapAlloc(MSACM_hHeap, 0, (lstrlenW(pAlias) + 1) * sizeof(WCHAR));
>                      if (alias_name) lstrcpyW(alias_name, pAlias);
>                      pConfigInfo->lpszDCIAliasName = alias_name;
> +                    pConfigInfo->dnDevNode = 0; /* FIXME */
>  
>                      if (pConfigInfo->lpszDCISectionName == NULL || pConfigInfo->lpszDCIAliasName == NULL) {
>                          HeapFree(MSACM_hHeap, 0, alias_name);
> diff --git a/include/mmsystem.h b/include/mmsystem.h
> index 2a0782d0cb9..5684ff20683 100644
> --- a/include/mmsystem.h
> +++ b/include/mmsystem.h
> @@ -225,6 +225,12 @@ typedef struct tagDRVCONFIGINFO {
>      LPCWSTR  			lpszDCIAliasName;
>  } DRVCONFIGINFO, *LPDRVCONFIGINFO;
>  
> +typedef struct tagDRVCONFIGINFOEX {
> +    DWORD   			dwDCISize;
> +    LPCWSTR  			lpszDCISectionName;
> +    LPCWSTR  			lpszDCIAliasName;
> +    DWORD			dnDevNode;
> +} DRVCONFIGINFOEX, *LPDRVCONFIGINFOEX;
>  
>  LRESULT WINAPI DefDriverProc(DWORD_PTR,HDRVR,UINT,LPARAM,LPARAM);
>  /* this sounds odd, but it's the way it is. OpenDriverA even disappeared
> 
> 



More information about the wine-devel mailing list