Fixed a problem were a trace accesses a data member that may be
outside of the actual data structure passed in.
Added some more debug traces.
diff --git a/dlls/winmm/lolvldrv.c b/dlls/winmm/lolvldrv.c
index 1dd5624..b8fba4e 100644
--- a/dlls/winmm/lolvldrv.c
+++ b/dlls/winmm/lolvldrv.c
@@ -95,6 +95,7 @@
*/
BOOL MMDRV_Is32(unsigned int idx)
{
+ TRACE("(%d)\n", idx);
return MMDrvs[idx].bIs32;
}
@@ -114,6 +115,7 @@
FARPROC pGetFileVersionInfoA;
FARPROC pVerQueryValueA;
HMODULE hmodule = 0;
+ TRACE("(%p, %p, %d)\n", fname, buf, buflen);
#define E(_x) do {TRACE _x;goto theEnd;} while(0)
@@ -164,6 +166,7 @@
*/
UINT MMDRV_GetNum(UINT type)
{
+ TRACE("(%04x)\n", type);
assert(type < MMDRV_MAX);
return llTypes[type].wMaxId;
}
@@ -294,6 +297,8 @@
{
LPWINE_MLD mld;
UINT i;
+ TRACE("(%d, %04x, %p, %p, %p, %p, %c)\n",
+ size, type, hndl, dwFlags, dwCallback, dwInstance, bFrom32?'Y':'N');
mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (!mld) return NULL;
@@ -338,6 +343,8 @@
*/
void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
{
+ TRACE("(%p, %p)\n", hndl, mld);
+
if ((UINT)hndl & 0x8000) {
unsigned idx = (UINT)hndl & ~0x8000;
if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
@@ -357,6 +364,7 @@
DWORD dwRet = MMSYSERR_BADDEVICEID;
DWORD dwInstance;
WINE_LLTYPE* llType = &llTypes[mld->type];
+ TRACE("(%p, %04x, 0x%08lx, 0x%08lx)\n", mld, wMsg, dwParam1, dwFlags);
mld->dwDriverInstance = (DWORD)&dwInstance;
@@ -398,6 +406,7 @@
*/
DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
{
+ TRACE("(%p, %04x)\n", mld, wMsg);
return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE);
}
@@ -406,6 +415,7 @@
*/
LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
{
+ TRACE("(%04x, %04x)\n", uDevID, type);
if (uDevID < llTypes[type].wMaxId)
return &llTypes[type].lpMlds[uDevID];
if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
@@ -420,6 +430,7 @@
{
LPWINE_MLD mld = NULL;
UINT hndl = (UINT)_hndl;
+ TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
assert(type < MMDRV_MAX);
@@ -448,6 +459,8 @@
BOOL bSrcCanBeID, UINT dstType)
{
LPWINE_MLD mld;
+ TRACE("(%p, %04x, %c, %04x)\n",
+ hndl, srcType, bSrcCanBeID ? 'Y' : 'N', dstType);
if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) {
WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType];
@@ -518,6 +531,7 @@
DWORD ret;
UINT count = 0;
int i, k;
+ TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
part->nIDMin = part->nIDMax = 0;
@@ -707,6 +721,7 @@
char* p2;
DWORD type, size;
BOOL ret = FALSE;
+ TRACE("()\n");
if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) {
TRACE("Cannot open WinMM config key\n");
@@ -742,6 +757,7 @@
*/
static BOOL MMDRV_InitHardcoded(void)
{
+ TRACE("()\n");
/* first load hardware drivers */
MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE);
@@ -757,6 +773,7 @@
*/
BOOL MMDRV_Init(void)
{
+ TRACE("()\n");
/* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */
return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded();
}
@@ -770,6 +787,7 @@
{
WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
DWORD ret;
+ TRACE("(%p, %04x)\n", lpDrv, type);
if (lpDrv->bIs32 && part->u.fnMessage32) {
#if 0
@@ -802,6 +820,7 @@
void MMDRV_Exit(void)
{
int i;
+ TRACE("()\n");
for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
{
diff --git a/dlls/winmm/winmm.c b/dlls/winmm/winmm.c
index 56afb20..e9dbf97 100644
--- a/dlls/winmm/winmm.c
+++ b/dlls/winmm/winmm.c
@@ -2425,19 +2425,29 @@
lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback,
dwInstance, dwFlags, bFrom32?32:16);
- if (dwFlags & WAVE_FORMAT_QUERY) TRACE("WAVE_FORMAT_QUERY requested !\n");
+ if (dwFlags & WAVE_FORMAT_QUERY)
+ TRACE("WAVE_FORMAT_QUERY requested !\n");
- if (lpFormat == NULL) return WAVERR_BADFORMAT;
- if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1))
+ if (lpFormat == NULL) {
+ WARN("bad format\n");
+ return WAVERR_BADFORMAT;
+ }
+
+ if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1)) {
+ WARN("invalid parameter\n");
return MMSYSERR_INVALPARAM;
+ }
- TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u, cbSize=%u\n",
+ /* may have a PCMWAVEFORMAT rather than a WAVEFORMATEX so don't read cbSize */
+ TRACE("wFormatTag=%u, nChannels=%u, nSamplesPerSec=%lu, nAvgBytesPerSec=%lu, nBlockAlign=%u, wBitsPerSample=%u\n",
lpFormat->wFormatTag, lpFormat->nChannels, lpFormat->nSamplesPerSec,
- lpFormat->nAvgBytesPerSec, lpFormat->nBlockAlign, lpFormat->wBitsPerSample, lpFormat->cbSize);
+ lpFormat->nAvgBytesPerSec, lpFormat->nBlockAlign, lpFormat->wBitsPerSample);
if ((wmld = MMDRV_Alloc(sizeof(WINE_WAVE), uType, &handle,
- &dwFlags, &dwCallback, &dwInstance, bFrom32)) == NULL)
+ &dwFlags, &dwCallback, &dwInstance, bFrom32)) == NULL) {
+ WARN("no memory\n");
return MMSYSERR_NOMEM;
+ }
wod.hWave = handle;
wod.lpFormat = lpFormat; /* should the struct be copied iso pointer? */