[PATCH 2/2] winmm: Search the default path when opening an existing file in create_file_OF().

Andrew Eikum aeikum at codeweavers.com
Thu Dec 17 13:13:33 CST 2020


This fails for me:

    wine.win64$ WINEPREFIX=$HOME/tmp/tmppfx/ make dlls/winmm/tests/mmio.ok
    ../wine/tools/runtest -q -P wine -T . -M winmm.dll -p dlls/winmm/tests/winmm_test.exe mmio && touch dlls/winmm/tests/mmio.ok
    mmio.c:533: Test failed: failed to open file, error 0x101
    make: *** [Makefile:171981: dlls/winmm/tests/mmio.ok] Error 1

Excerpts from a +file log:

    00d8:trace:file:CreateFileW L"test_mmio_path" GENERIC_WRITE FILE_SHARE_READ FILE_SHARE_WRITE  creation 2 attributes 0x80
    00d8:trace:file:nt_to_unix_file_name L"\\??\\Z:\\home\\andrew\\src\\wine.win64\\test_mmio_path" -> "/home/andrew/tmp/tmppfx/dosdevices/z:/home/andrew/src/wine.win64/test_mmio_path"
    0034:trace:file:CreateFileW returning 0000000000000094
    ...
    00d8:trace:mmio:MMIO_Open ("test_mmio_path", 000000000031F180, 00000001, unicode);
    ...
    00d8:warn:file:NtQueryAttributesFile L"\\??\\Z:\\home\\andrew\\src\\wine.win64\\dlls\\winmm\\tests\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\users\\andrew\\Temp\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\system32\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\system\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\system32\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\system32\\wbem\\test_mmio_path" not found (c0000034)
    00d8:warn:file:NtQueryAttributesFile L"\\??\\C:\\windows\\system32\\WindowsPowershell\\v1.0\\test_mmio_path" not found (c0000034)
    mmio.c:533: Test failed: failed to open file, error 0x101

The same happens if I run it while in the <dlls/winmm/tests/> dir.

Andrew

On Thu, Dec 17, 2020 at 11:55:06AM -0600, Zebediah Figura wrote:
> Based on a patch by Alistair Leslie-Hughes.
> 
> Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49650
> Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
> ---
>  dlls/winmm/mmio.c       | 24 ++++++++++++++++++++++--
>  dlls/winmm/tests/mmio.c |  2 +-
>  2 files changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
> index 48bbd3ed48d..c4838f388b6 100644
> --- a/dlls/winmm/mmio.c
> +++ b/dlls/winmm/mmio.c
> @@ -51,7 +51,9 @@ static WINE_MMIO *MMIOList;
>  /* From kernel32 */
>  static HANDLE create_file_OF( LPCSTR path, INT mode )
>  {
> -    DWORD access, sharing, creation;
> +    DWORD access, sharing, creation, len;
> +    char *full_path;
> +    HANDLE ret;
>  
>      if (mode & OF_CREATE)
>      {
> @@ -79,7 +81,25 @@ static HANDLE create_file_OF( LPCSTR path, INT mode )
>      case OF_SHARE_COMPAT:
>      default:                  sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break;
>      }
> -    return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
> +
> +    if (mode & OF_CREATE)
> +        return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
> +
> +    if (!(len = SearchPathA( NULL, path, NULL, 0, NULL, NULL )))
> +        return INVALID_HANDLE_VALUE;
> +    if (!(full_path = malloc(len + 1)))
> +    {
> +        SetLastError( ERROR_OUTOFMEMORY );
> +        return INVALID_HANDLE_VALUE;
> +    }
> +    if (!SearchPathA( NULL, path, NULL, len + 1, full_path, NULL ))
> +    {
> +        free(full_path);
> +        return INVALID_HANDLE_VALUE;
> +    }
> +    ret = CreateFileA( full_path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
> +    free(full_path);
> +    return ret;
>  }
>  
>  /**************************************************************************
> diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c
> index 5ad20eec521..fc9ec802657 100644
> --- a/dlls/winmm/tests/mmio.c
> +++ b/dlls/winmm/tests/mmio.c
> @@ -530,7 +530,7 @@ static void test_mmioOpen_create(void)
>  
>      wcscpy(buffer, L"test_mmio_path");
>      hmmio = mmioOpenW(buffer, &info, MMIO_WRITE);
> -    todo_wine ok(!!hmmio, "failed to open file, error %#x\n", info.wErrorRet);
> +    ok(!!hmmio, "failed to open file, error %#x\n", info.wErrorRet);
>      mmioClose(hmmio, 0);
>  
>      wcscpy(buffer, L"test_mmio_path");
> -- 
> 2.29.2
> 
> 



More information about the wine-devel mailing list