[PATCH v2] winmm: Pass a fullpath to CreateFileA
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Mon Aug 31 02:33:58 CDT 2020
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
dlls/winmm/mmio.c | 18 +++++++++++++++++-
dlls/winmm/tests/mmio.c | 9 +++++++++
2 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c
index 48bbd3ed48..a3e2650f50 100644
--- a/dlls/winmm/mmio.c
+++ b/dlls/winmm/mmio.c
@@ -52,6 +52,9 @@ static WINE_MMIO *MMIOList;
static HANDLE create_file_OF( LPCSTR path, INT mode )
{
DWORD access, sharing, creation;
+ HANDLE ret;
+ char *fullpath = NULL;
+ DWORD len;
if (mode & OF_CREATE)
{
@@ -79,7 +82,20 @@ 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 );
+
+ len = SearchPathA( NULL, path, NULL, 0, fullpath, NULL );
+ if (!len)
+ return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
+
+ fullpath = HeapAlloc(GetProcessHeap(), 0, len);
+ if (!fullpath)
+ return INVALID_HANDLE_VALUE;
+
+ SearchPathA( NULL, path, NULL, len, fullpath, NULL );
+ ret = CreateFileA( fullpath, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 );
+
+ HeapFree(GetProcessHeap(), 0, fullpath);
+ return ret;
}
/**************************************************************************
diff --git a/dlls/winmm/tests/mmio.c b/dlls/winmm/tests/mmio.c
index e3984fbaf3..0de51a2562 100644
--- a/dlls/winmm/tests/mmio.c
+++ b/dlls/winmm/tests/mmio.c
@@ -478,6 +478,7 @@ static void test_mmioOpen_create(void)
WCHAR cwd[MAX_PATH], temp_dir[MAX_PATH];
/* According to docs, filename must be no more than 128 bytes, but it will
* actually allow longer than that. */
+ WCHAR relpath[] = L"local\\examplefile";
WCHAR filename[] = L"very_long_filename_"
L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
L"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
@@ -520,6 +521,14 @@ static void test_mmioOpen_create(void)
DeleteFileW(filename);
+ CreateDirectoryA("local", NULL);
+ hmmio = mmioOpenW(relpath, NULL, MMIO_CREATE | MMIO_WRITE | MMIO_EXCLUSIVE);
+ ok(hmmio != NULL, "mmioOpen failed\n");
+ mmioClose(hmmio, 0);
+
+ DeleteFileW(relpath);
+ RemoveDirectoryA("local");
+
SetCurrentDirectoryW(cwd);
}
--
2.28.0
More information about the wine-devel
mailing list