winmm: Improve MCI A/W mapping slightly.

Joerg-Cyril.Hoehle at Joerg-Cyril.Hoehle at
Wed Apr 7 08:48:22 CDT 2010


this patch slightly improves upon the current A/W mapper code.

You may object to it because it will cause new fixme messages from the
numerous apps that use MCI_SETVIDEO and MCI_SETAUDIO.  I didn't cover
them because:
1. I never saw an app set the Algorithm and Quality string parameters
   that need conversion and
2. Wine does not implement these two and, last but not least,
3. the resource and the include about SETVIDEO list them in different
   order(!) making the behaviour completely undefined without tests.

Of course, one could easily quiet the fixme from SETAUDIO and SETVIDEO.
Do you want this?

It fixes a buffer overflow in MCI_INFO.

Currently, I can't think of a fully general solution to the A/W
mapping problem. In theory, an unknown driver with new unknown
commands and keywords could be registered.  We have little idea how
large the structure is and which flags controls the validity of the
nth slot, e.g. when to call strdupAtoW.

One could think about parsing the command table to obtain this
information.  However,
 a) I see no guarantee that there's a unique MCI_STRING value for a
    given bit that is set in the flags parameter.
 b) This does not help with baroque commands like SYSINFO which
    sometimes put a string, sometimes a DWORD into the result object
    or which are documented to count buffer sizes in bytes, unlike
    other commands.

This latter example reveals that calling MCI_Cleanup() before
unwrapping is unfortunate, as valuable type information is
lost.  It is currently encapsulated inside mciSendCommandW.

Open questions:
 - Does Wine actually support hooking in a new native MCI driver?
   (beside DLL overrides)

 - Why does Wine copy dwCallback only when MCI_NOTIFY is set? It is
   not wrong, but why care? To prevent a Valgrind message when that
   slot was not filled by the caller?

BTW, my (unpublished) testing reveals that unlike what MSDN says,
dwRetSize is measured in characters in MCI_SYSINFO_PARMSW, not bytes
(at least on w2k with SYSINFO_NAME [OPEN]). But that shall be the
subject of another patch.

 Jörg Höhle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-winmm-Improve-MCI-A-W-mapping-slightly.patch
Type: application/octet-stream
Size: 10895 bytes
Desc: 0001-winmm-Improve-MCI-A-W-mapping-slightly.patch
URL: <>

More information about the wine-patches mailing list