From 1d043f4da705d53615caf63da05bc0ed6d2b178f Mon Sep 17 00:00:00 2001 From: Zebediah Figura Date: Thu, 17 Dec 2020 16:40:51 -0600 Subject: [PATCH] winmm: Search the default path when opening an existing file in create_file_OF(). Based on a patch by Alistair Leslie-Hughes. Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=49650 Signed-off-by: Zebediah Figura Signed-off-by: Andrew Eikum Signed-off-by: Alexandre Julliard --- dlls/winmm/mmio.c | 9 ++++++++- dlls/winmm/tests/mmio.c | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index cb3175c5cd7..1255cf69da2 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -52,6 +52,7 @@ static WINE_MMIO *MMIOList; static HANDLE create_file_OF( LPCSTR path, INT mode ) { DWORD access, sharing, creation; + char full_path[MAX_PATH]; if (mode & OF_CREATE) { @@ -79,7 +80,13 @@ 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 (!SearchPathA( NULL, path, NULL, MAX_PATH, full_path, NULL )) + return INVALID_HANDLE_VALUE; + return CreateFileA( full_path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 ); } /************************************************************************** diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c index c9ceda24f3f..a232070064c 100644 --- a/dlls/winmm/tests/mmio.c +++ b/dlls/winmm/tests/mmio.c @@ -551,7 +551,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");