Still, I'm not persuaded that your patch is at the right place. I believe the midi* functions should be tiny wrappers around MODM_* messages, same for the wave* functions. Every time I see somebody attempt to violate this 1:1 mapping, I'm suspicious. Perhaps the logic that you're adding belongs to the individual wine*.drv/midi.c?
Maybe it worth compare visually between builtin and native by adding sysex dump code to one driver if needed as 1st and last 3 bytes are currently dump.
Therefore, I'd be happy if you could invest some more time and check, based on your real MIDI HW, and perhaps native w* machines, whether MODM_LONGDATA and midiOutLongMsg are equivalent or whether midiOut* does some additional processing.
I don't know if Johannes uses alsa driver but I took a look at the alsa code and this code simply does not do what it is supposed to. I think that would be better to fix this code first as it might be the cause of the bug.
984 if (lpData[0] != 0xF0) { 985 /* Send start of System Exclusive */ 986 len_add = 1; 987 lpData[0] = 0xF0; 988 memcpy(lpNewData, lpData, lpMidiHdr->dwBufferLength); 989 WARN("Adding missing 0xF0 marker at the beginning of " 990 "system exclusive byte stream\n"); 991 } 992 if (lpData[lpMidiHdr->dwBufferLength-1] != 0xF7) { 993 /* Send end of System Exclusive */ 994 memcpy(lpData + len_add, lpData, lpMidiHdr->dwBufferLength); 995 lpNewData[lpMidiHdr->dwBufferLength + len_add - 1] = 0xF0; 996 len_add++; 997 WARN("Adding missing 0xF7 marker at the end of " 998 "system exclusive byte stream\n");
999 }