From c62cf2e049ad37d9561957c47d23fc7ba13adc90 Mon Sep 17 00:00:00 2001 From: Eric Pouech Date: Sat, 23 Jan 2010 18:56:45 +0100 Subject: [PATCH] winmm: In mmio manipulation, always ensure that we use a HFILE for mmio internal handlers (and not a HANDLE). --- dlls/winmm/mmio.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/dlls/winmm/mmio.c b/dlls/winmm/mmio.c index b774003abb8..75439a4212d 100644 --- a/dlls/winmm/mmio.c +++ b/dlls/winmm/mmio.c @@ -76,9 +76,9 @@ 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] = (DWORD)OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF); + lpmmioinfo->adwInfo[0] = OpenFile(szFileName, &ofs, lpmmioinfo->dwFlags & 0xFFFF); } - if (lpmmioinfo->adwInfo[0] == (DWORD)HFILE_ERROR) + if (lpmmioinfo->adwInfo[0] == HFILE_ERROR) ret = MMIOERR_CANNOTOPEN; } break; @@ -582,6 +582,7 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, { LPWINE_MMIO wm; MMIOINFO mmioinfo; + DWORD pos; TRACE("('%s', %p, %08X, %s);\n", szFileName, refmminfo, dwOpenFlags, is_unicode ? "unicode" : "ansi"); @@ -666,7 +667,12 @@ static HMMIO MMIO_Open(LPSTR szFileName, MMIOINFO* refmminfo, DWORD dwOpenFlags, (LPARAM)szFileName, 0, FALSE); /* grab file size, when possible */ - wm->dwFileSize = GetFileSize((HANDLE)wm->info.adwInfo[0], NULL); + if ((pos = _llseek((HFILE)wm->info.adwInfo[0], 0, SEEK_CUR)) != -1) + { + wm->dwFileSize = _llseek((HFILE)wm->info.adwInfo[0], 0, SEEK_END); + _llseek((HFILE)wm->info.adwInfo[0], pos, SEEK_SET); + } + else wm->dwFileSize = 0; if (refmminfo->wErrorRet == 0) return wm->info.hmmio;