From a758c6a981b1f4d3653f9cf44f6d136f2fc0e6b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20H=C3=B6hle?= Date: Sun, 31 Jan 2010 21:19:39 +0100 Subject: [PATCH] winmm: The 64KB buffer limit on MIDIHDR buffers applies to streams only. --- dlls/winealsa.drv/midi.c | 8 +++----- dlls/winecoreaudio.drv/midi.c | 6 ++---- dlls/wineoss.drv/midi.c | 8 +++----- dlls/winmm/tests/midi.c | 6 +++--- dlls/winmm/winmm.c | 1 + 5 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dlls/winealsa.drv/midi.c b/dlls/winealsa.drv/midi.c index b62a8852b5f..33d57837704 100644 --- a/dlls/winealsa.drv/midi.c +++ b/dlls/winealsa.drv/midi.c @@ -611,8 +611,7 @@ static DWORD midPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) TRACE("(%04X, %p, %08X);\n", wDevID, lpMidiHdr, dwSize); if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) return MMSYSERR_INVALPARAM; lpMidiHdr->lpNext = 0; @@ -633,7 +632,7 @@ static DWORD midUnprepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) if (MidiInDev[wDevID].state == -1) return MIDIERR_NODEVICE; if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || lpMidiHdr->dwBufferLength >= 0x10000ul) + lpMidiHdr->lpData == 0) return MMSYSERR_INVALPARAM; if (!(lpMidiHdr->dwFlags & MHDR_PREPARED)) return MIDIERR_UNPREPARED; @@ -1057,8 +1056,7 @@ static DWORD modPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) * So at least check for the inqueue flag */ if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) { + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) { WARN("%p %p %08x %d\n", lpMidiHdr, lpMidiHdr ? lpMidiHdr->lpData : NULL, lpMidiHdr ? lpMidiHdr->dwFlags : 0, dwSize); return MMSYSERR_INVALPARAM; diff --git a/dlls/winecoreaudio.drv/midi.c b/dlls/winecoreaudio.drv/midi.c index a31a0764c07..e66d43571be 100644 --- a/dlls/winecoreaudio.drv/midi.c +++ b/dlls/winecoreaudio.drv/midi.c @@ -470,8 +470,7 @@ static DWORD MIDIOut_Prepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) * So at least check for the inqueue flag */ if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) { + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) { WARN("%p %p %08x %lu/%d\n", lpMidiHdr, lpMidiHdr->lpData, lpMidiHdr->dwFlags, sizeof(MIDIHDR), dwSize); return MMSYSERR_INVALPARAM; @@ -721,8 +720,7 @@ static DWORD MIDIIn_Prepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) * So at least check for the inqueue flag */ if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) { + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) { WARN("Invalid parameter %p %p %08x %d\n", lpMidiHdr, lpMidiHdr->lpData, lpMidiHdr->dwFlags, dwSize); return MMSYSERR_INVALPARAM; diff --git a/dlls/wineoss.drv/midi.c b/dlls/wineoss.drv/midi.c index 99a9ce08f63..d82dbdc9569 100644 --- a/dlls/wineoss.drv/midi.c +++ b/dlls/wineoss.drv/midi.c @@ -875,8 +875,7 @@ static DWORD midPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) TRACE("(%04X, %p, %08X);\n", wDevID, lpMidiHdr, dwSize); if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) return MMSYSERR_INVALPARAM; lpMidiHdr->lpNext = 0; @@ -897,7 +896,7 @@ static DWORD midUnprepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) if (MidiInDev[wDevID].state == -1) return MIDIERR_NODEVICE; if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || lpMidiHdr->dwBufferLength >= 0x10000ul) + lpMidiHdr->lpData == 0) return MMSYSERR_INVALPARAM; if (!(lpMidiHdr->dwFlags & MHDR_PREPARED)) return MIDIERR_UNPREPARED; @@ -1621,8 +1620,7 @@ static DWORD modPrepare(WORD wDevID, LPMIDIHDR lpMidiHdr, DWORD dwSize) * So at least check for the inqueue flag */ if (dwSize < sizeof(MIDIHDR) || lpMidiHdr == 0 || - lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0 || - lpMidiHdr->dwBufferLength >= 0x10000ul) { + lpMidiHdr->lpData == 0 || (lpMidiHdr->dwFlags & MHDR_INQUEUE) != 0) { WARN("%p %p %08x %d\n", lpMidiHdr, lpMidiHdr ? lpMidiHdr->lpData : NULL, lpMidiHdr ? lpMidiHdr->dwFlags : 0, dwSize); return MMSYSERR_INVALPARAM; diff --git a/dlls/winmm/tests/midi.c b/dlls/winmm/tests/midi.c index 082cf3c3874..82d61d1ba98 100644 --- a/dlls/winmm/tests/midi.c +++ b/dlls/winmm/tests/midi.c @@ -121,7 +121,7 @@ static void test_midiIn_device(UINT udev, HWND hwnd) ok(mhdr.lpData!=NULL, "No %d bytes of memory!\n", mhdr.dwBufferLength); if (mhdr.lpData) { rc = midiInPrepareHeader(hm, &mhdr, sizeof(mhdr)); - todo_wine ok(!rc, "midiInPrepare rc=%s\n", mmsys_error(rc)); + ok(!rc, "midiInPrepare rc=%s\n", mmsys_error(rc)); rc = midiInUnprepareHeader(hm, &mhdr, sizeof(mhdr)); ok(!rc, "midiInUnprepare rc=%s\n", mmsys_error(rc)); trace("MIDIHDR flags=%x when unsent\n", mhdr.dwFlags); @@ -260,7 +260,7 @@ static void test_midiOut_device(UINT udev, HWND hwnd) test_notification(hwnd, "midiOutLong unprepared", 0, WHATEVER); rc = midiOutPrepareHeader(hm, &mhdr, sizeof(mhdr)); - todo_wine ok(!rc, "midiOutPrepare rc=%s\n", mmsys_error(rc)); + ok(!rc, "midiOutPrepare rc=%s\n", mmsys_error(rc)); rc = midiOutUnprepareHeader(hm, &mhdr, sizeof(mhdr)); ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc)); trace("MIDIHDR flags=%x when unsent\n", mhdr.dwFlags); @@ -416,7 +416,7 @@ static void test_midiStream(UINT udev, HWND hwnd) mhdr.dwFlags = 0; /* PrepareHeader detects the too large buffer is for a stream. */ rc = midiOutPrepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr)); - ok(rc==MMSYSERR_INVALPARAM, "midiOutPrepare stream too large rc=%s\n", mmsys_error(rc)); + todo_wine ok(rc==MMSYSERR_INVALPARAM, "midiOutPrepare stream too large rc=%s\n", mmsys_error(rc)); rc = midiOutUnprepareHeader((HMIDIOUT)hm, &mhdr, sizeof(mhdr)); ok(!rc, "midiOutUnprepare rc=%s\n", mmsys_error(rc)); diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c index 3fee0a8efcf..a2074f673f6 100644 --- a/dlls/winmm/winmm.c +++ b/dlls/winmm/winmm.c @@ -969,6 +969,7 @@ UINT WINAPI midiOutPrepareHeader(HMIDIOUT hMidiOut, if ((wmld = MMDRV_Get(hMidiOut, MMDRV_MIDIOUT, FALSE)) == NULL) return MMSYSERR_INVALHANDLE; + /* FIXME: detect MIDIStream handles and enforce 64KB buffer limit on those */ return MMDRV_Message(wmld, MODM_PREPARE, (DWORD_PTR)lpMidiOutHdr, uSize); }