OpenFile has a filpath 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 --- dlls/winmm/mmio.c | 49 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-)
diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index 6f14301975..2e2dfe13d7 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] */ @@ -74,11 +108,16 @@ static LRESULT CALLBACK mmioDosIOProc(LPMMIOINFO lpmmioinfo, UINT uMessage, return MMIOERR_CANNOTOPEN; }
- /* if filename NULL, assume open file handle in adwInfo[0] */ - if (szFileName) { - OFSTRUCT ofs; - lpmmioinfo->adwInfo[0] = OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF); - } + /* if filename NULL, assume open file handle in adwInfo[0] */ + if (szFileName) { + 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; }
This needs a test, or at minimum a comment explaining why you copied the kernel32 code.
-Alex