From: Alistair Leslie-Hughes leslie_alistair@hotmail.com
OpenFile has a filepath limit of 128. Use CreateFile which doesn't have this limit.
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=48832 Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=27324 Signed-off-by: Alistair Leslie-Hughes leslie_alistair@hotmail.com Signed-off-by: Andrew Eikum aeikum@codeweavers.com ---
v4: Match surrounding tab style.
dlls/winmm/mmio.c | 45 ++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 6f143019751..48bbd3ed48d 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -48,6 +48,40 @@ WINE_DEFAULT_DEBUG_CHANNEL(mmio);
static WINE_MMIO *MMIOList;
+/* From kernel32 */ +static HANDLE create_file_OF( LPCSTR path, INT mode ) +{ + DWORD access, sharing, creation; + + if (mode & OF_CREATE) + { + creation = CREATE_ALWAYS; + access = GENERIC_READ | GENERIC_WRITE; + } + else + { + creation = OPEN_EXISTING; + switch(mode & 0x03) + { + case OF_READ: access = GENERIC_READ; break; + case OF_WRITE: access = GENERIC_WRITE; break; + case OF_READWRITE: access = GENERIC_READ | GENERIC_WRITE; break; + default: access = 0; break; + } + } + + switch(mode & 0x70) + { + case OF_SHARE_EXCLUSIVE: sharing = 0; break; + case OF_SHARE_DENY_WRITE: sharing = FILE_SHARE_READ; break; + case OF_SHARE_DENY_READ: sharing = FILE_SHARE_WRITE; break; + case OF_SHARE_DENY_NONE: + case OF_SHARE_COMPAT: + default: sharing = FILE_SHARE_READ | FILE_SHARE_WRITE; break; + } + return CreateFileA( path, access, sharing, NULL, creation, FILE_ATTRIBUTE_NORMAL, 0 ); +} + /************************************************************************** * mmioDosIOProc [internal] */ @@ -76,9 +110,14 @@ static LRESULT CALLBACK mmioDosIOProc(LPMMIOINFO lpmmioinfo, UINT uMessage,
/* if filename NULL, assume open file handle in adwInfo[0] */ if (szFileName) { - OFSTRUCT ofs; - lpmmioinfo->adwInfo[0] = OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF); - } + HANDLE file; + + file = create_file_OF( szFileName, lpmmioinfo->dwFlags ); + if (file != INVALID_HANDLE_VALUE) + lpmmioinfo->adwInfo[0] = HandleToLong(file); + else + lpmmioinfo->adwInfo[0] = HFILE_ERROR; + } if (lpmmioinfo->adwInfo[0] == HFILE_ERROR) ret = MMIOERR_FILENOTFOUND; }