From ceabe25983c921d2279fc4ef59386e5e0e4bc471 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Fri, 12 Mar 2004 21:20:53 +0000 Subject: [PATCH] Sync to Wine-20040309: Jason Edmeades - Handle playing of files containing a '+' as part of the filename. Robert Reif - Cleanup prepare/unprepare header parameter checking. - Fix midiInGetDevCapsW. Sean Young - Check uSize parameter in waveOutUnprepareHeader and waveOutPrepareHeader. Christian Costa - Fixed waveInGetDevCapsW. svn path=/trunk/; revision=8672 --- reactos/lib/winmm/mmio.c | 50 +++++++++++++++++------------- reactos/lib/winmm/winehq2ros.patch | 50 +++++++++++++++++++++--------- reactos/lib/winmm/winmm.c | 30 +++++++++++++++--- 3 files changed, 88 insertions(+), 42 deletions(-) diff --git a/reactos/lib/winmm/mmio.c b/reactos/lib/winmm/mmio.c index 25631c52164..f588690e527 100644 --- a/reactos/lib/winmm/mmio.c +++ b/reactos/lib/winmm/mmio.c @@ -389,41 +389,47 @@ static LRESULT send_message(struct IOProcList* ioProc, LPMMIOINFO mmioinfo, */ static FOURCC MMIO_ParseExtA(LPCSTR szFileName) { - /* Filenames are of the form file.ext+ABC - FIXME: What if a '+' is part of the file name? - For now, we take the last '+' present */ + /* Filenames are of the form file.ext{+ABC} + For now, we take the last '+' if present */ FOURCC ret = 0; /* Note that ext{Start,End} point to the . and + respectively */ LPSTR extEnd; + LPSTR extStart; TRACE("(%s)\n", debugstr_a(szFileName)); if (!szFileName) return ret; - extEnd = strrchr(szFileName,'+'); - if (extEnd) { - /* Need to parse to find the extension */ - LPSTR extStart; - extStart = extEnd; - while (extStart >= szFileName && extStart[0] != '.') { - extStart--; - } + /* Find the last '.' */ + extStart = strrchr(szFileName,'.'); - if (extStart < szFileName) { - ERR("+ but no . in szFileName: %s\n", debugstr_a(szFileName)); - } else { - CHAR ext[5]; + if (!extStart) { + ERR("No . in szFileName: %s\n", debugstr_a(szFileName)); + } else { + CHAR ext[5]; - if (extEnd - extStart - 1 > 4) - WARN("Extension length > 4\n"); - lstrcpynA(ext, extStart + 1, min(extEnd-extStart,5)); - TRACE("Got extension: %s\n", debugstr_a(ext)); - /* FOURCC codes identifying file-extensions must be uppercase */ - ret = mmioStringToFOURCCA(ext, MMIO_TOUPPER); - } + /* Find the '+' afterwards */ + extEnd = strchr(extStart,'+'); + if (extEnd) { + + if (extEnd - extStart - 1 > 4) + WARN("Extension length > 4\n"); + lstrcpynA(ext, extStart + 1, min(extEnd-extStart,5)); + + } else { + /* No + so just an extension */ + if (strlen(extStart) > 4) { + WARN("Extension length > 4\n"); + } + lstrcpynA(ext, extStart + 1, 5); + } + TRACE("Got extension: %s\n", debugstr_a(ext)); + + /* FOURCC codes identifying file-extensions must be uppercase */ + ret = mmioStringToFOURCCA(ext, MMIO_TOUPPER); } return ret; } diff --git a/reactos/lib/winmm/winehq2ros.patch b/reactos/lib/winmm/winehq2ros.patch index 44c2764e0eb..937c04a2ee7 100644 --- a/reactos/lib/winmm/winehq2ros.patch +++ b/reactos/lib/winmm/winehq2ros.patch @@ -1,6 +1,10 @@ -diff -u /c/source/wine/dlls/winmm/lolvldrv.c winmm/lolvldrv.c ---- /c/source/wine/dlls/winmm/lolvldrv.c Wed Feb 25 18:47:36 2004 -+++ winmm/lolvldrv.c Tue Feb 17 01:15:52 2004 +Index: lolvldrv.c +=================================================================== +RCS file: /home/wine/wine/dlls/winmm/lolvldrv.c,v +retrieving revision 1.55 +diff -u -r1.55 lolvldrv.c +--- lolvldrv.c 31 Dec 2003 23:49:45 -0000 1.55 ++++ lolvldrv.c 12 Mar 2004 21:27:34 -0000 @@ -497,10 +497,12 @@ case DRV_QUERYDEVICEINTERFACESIZE: return MMDRV_Message(mld, uMsg, dwParam1, dwParam2, TRUE); @@ -14,21 +18,34 @@ diff -u /c/source/wine/dlls/winmm/lolvldrv.c winmm/lolvldrv.c default: WARN("Unknown call %04x\n", uMsg); -@@ -741,8 +743,9 @@ +@@ -741,11 +743,18 @@ static BOOL MMDRV_InitHardcoded(void) { /* first load hardware drivers */ +#ifndef __REACTOS__ MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); -- +#endif /* __REACTOS__ */ ++ ++#ifdef __REACTOS__ ++ // AG: TESTING: ++ MMDRV_Install("mmdrv.dll", "mmdrv.dll", FALSE); ++#endif + /* finish with mappers */ - MMDRV_Install("wavemapper", "msacm.drv", TRUE); - MMDRV_Install("midimapper", "midimap.drv", TRUE); - -diff -u /c/source/wine/dlls/winmm/time.c winmm/time.c ---- /c/source/wine/dlls/winmm/time.c Mon Jan 12 16:03:10 2004 -+++ winmm/time.c Sun Feb 15 16:55:10 2004 +- MMDRV_Install("wavemapper", "msacm.drv", TRUE); +- MMDRV_Install("midimapper", "midimap.drv", TRUE); ++ MMDRV_Install("wavemapper", "msacm32.dll", TRUE); ++ MMDRV_Install("midimapper", "midimap.dll", TRUE); + + return TRUE; + } +Index: time.c +=================================================================== +RCS file: /home/wine/wine/dlls/winmm/time.c,v +retrieving revision 1.26 +diff -u -r1.26 time.c +--- time.c 12 Jan 2004 21:03:10 -0000 1.26 ++++ time.c 12 Mar 2004 21:27:34 -0000 @@ -175,14 +175,19 @@ volatile HANDLE *pActive = (volatile HANDLE *)&TIME_hMMTimer; DWORD last_time, cur_time; @@ -49,10 +66,13 @@ diff -u /c/source/wine/dlls/winmm/time.c winmm/time.c } return 0; } - -diff -u /c/source/wine/dlls/winmm/winmm.c winmm/winmm.c ---- /c/source/wine/dlls/winmm/winmm.c Wed Feb 25 14:28:52 2004 -+++ winmm/winmm.c Sun Feb 15 22:58:58 2004 +Index: winmm.c +=================================================================== +RCS file: /home/wine/wine/dlls/winmm/winmm.c,v +retrieving revision 1.33 +diff -u -r1.33 winmm.c +--- winmm.c 27 Feb 2004 21:29:32 -0000 1.33 ++++ winmm.c 12 Mar 2004 21:27:36 -0000 @@ -125,10 +125,12 @@ loaded = -1; if (h) diff --git a/reactos/lib/winmm/winmm.c b/reactos/lib/winmm/winmm.c index 7fe006fd468..773eb0955b9 100644 --- a/reactos/lib/winmm/winmm.c +++ b/reactos/lib/winmm/winmm.c @@ -1371,6 +1371,9 @@ UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut, TRACE("(%p, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize); + if (lpMidiOutHdr == NULL || uSize < sizeof (MIDIHDR)) + return MMSYSERR_INVALPARAM; + if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; @@ -1387,6 +1390,9 @@ UINT WINAPI midiOutUnprepareHeader(HMIDIOUT hMidiOut, TRACE("(%p, %p, %d)\n", hMidiOut, lpMidiOutHdr, uSize); + if (lpMidiOutHdr == NULL || uSize < sizeof (MIDIHDR)) + return MMSYSERR_INVALPARAM; + if (!(lpMidiOutHdr->dwFlags & MHDR_PREPARED)) { return MMSYSERR_NOERROR; } @@ -1556,7 +1562,7 @@ UINT WINAPI midiInGetNumDevs(void) UINT WINAPI midiInGetDevCapsW(UINT_PTR uDeviceID, LPMIDIINCAPSW lpCaps, UINT uSize) { MIDIINCAPSA micA; - UINT ret = midiInGetDevCapsA(uDeviceID, &micA, uSize); + UINT ret = midiInGetDevCapsA(uDeviceID, &micA, sizeof(micA)); if (ret == MMSYSERR_NOERROR) { MIDIINCAPSW micW; @@ -1681,6 +1687,9 @@ UINT WINAPI midiInPrepareHeader(HMIDIIN hMidiIn, TRACE("(%p, %p, %d)\n", hMidiIn, lpMidiInHdr, uSize); + if (lpMidiInHdr == NULL || uSize < sizeof (MIDIHDR)) + return MMSYSERR_INVALPARAM; + if ((wmld = MMDRV_Get(hMidiIn, MMDRV_MIDIIN, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; @@ -1697,6 +1706,9 @@ UINT WINAPI midiInUnprepareHeader(HMIDIIN hMidiIn, TRACE("(%p, %p, %d)\n", hMidiIn, lpMidiInHdr, uSize); + if (lpMidiInHdr == NULL || uSize < sizeof (MIDIHDR)) + return MMSYSERR_INVALPARAM; + if (!(lpMidiInHdr->dwFlags & MHDR_PREPARED)) { return MMSYSERR_NOERROR; } @@ -2609,7 +2621,8 @@ UINT WINAPI waveOutPrepareHeader(HWAVEOUT hWaveOut, TRACE("(%p, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize); - if (lpWaveOutHdr == NULL) return MMSYSERR_INVALPARAM; + if (lpWaveOutHdr == NULL || uSize < sizeof (WAVEHDR)) + return MMSYSERR_INVALPARAM; if ((wmld = MMDRV_Get(hWaveOut, MMDRV_WAVEOUT, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; @@ -2627,6 +2640,9 @@ UINT WINAPI waveOutUnprepareHeader(HWAVEOUT hWaveOut, TRACE("(%p, %p, %u);\n", hWaveOut, lpWaveOutHdr, uSize); + if (lpWaveOutHdr == NULL || uSize < sizeof (WAVEHDR)) + return MMSYSERR_INVALPARAM; + if (!(lpWaveOutHdr->dwFlags & WHDR_PREPARED)) { return MMSYSERR_NOERROR; } @@ -2867,7 +2883,7 @@ UINT WINAPI waveInGetNumDevs(void) UINT WINAPI waveInGetDevCapsW(UINT_PTR uDeviceID, LPWAVEINCAPSW lpCaps, UINT uSize) { WAVEINCAPSA wicA; - UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, uSize); + UINT ret = waveInGetDevCapsA(uDeviceID, &wicA, sizeof(wicA)); if (ret == MMSYSERR_NOERROR) { WAVEINCAPSW wicW; @@ -2961,7 +2977,9 @@ UINT WINAPI waveInPrepareHeader(HWAVEIN hWaveIn, WAVEHDR* lpWaveInHdr, TRACE("(%p, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize); - if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM; + if (lpWaveInHdr == NULL || uSize < sizeof (WAVEHDR)) + return MMSYSERR_INVALPARAM; + if ((wmld = MMDRV_Get(hWaveIn, MMDRV_WAVEIN, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; @@ -2980,7 +2998,9 @@ UINT WINAPI waveInUnprepareHeader(HWAVEIN hWaveIn, WAVEHDR* lpWaveInHdr, TRACE("(%p, %p, %u);\n", hWaveIn, lpWaveInHdr, uSize); - if (lpWaveInHdr == NULL) return MMSYSERR_INVALPARAM; + if (lpWaveInHdr == NULL || uSize < sizeof (WAVEHDR)) + return MMSYSERR_INVALPARAM; + if (!(lpWaveInHdr->dwFlags & WHDR_PREPARED)) { return MMSYSERR_NOERROR; }