Commit 41c6b5b5 authored by Robert Reif's avatar Robert Reif Committed by Alexandre Julliard

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.
parent 63a4b203
...@@ -95,6 +95,7 @@ void MMDRV_InstallMap(unsigned int drv, ...@@ -95,6 +95,7 @@ void MMDRV_InstallMap(unsigned int drv,
*/ */
BOOL MMDRV_Is32(unsigned int idx) BOOL MMDRV_Is32(unsigned int idx)
{ {
TRACE("(%d)\n", idx);
return MMDrvs[idx].bIs32; return MMDrvs[idx].bIs32;
} }
...@@ -114,6 +115,7 @@ static BOOL MMDRV_GetDescription32(const char* fname, char* buf, int buflen) ...@@ -114,6 +115,7 @@ static BOOL MMDRV_GetDescription32(const char* fname, char* buf, int buflen)
FARPROC pGetFileVersionInfoA; FARPROC pGetFileVersionInfoA;
FARPROC pVerQueryValueA; FARPROC pVerQueryValueA;
HMODULE hmodule = 0; HMODULE hmodule = 0;
TRACE("(%p, %p, %d)\n", fname, buf, buflen);
#define E(_x) do {TRACE _x;goto theEnd;} while(0) #define E(_x) do {TRACE _x;goto theEnd;} while(0)
...@@ -164,6 +166,7 @@ theEnd: ...@@ -164,6 +166,7 @@ theEnd:
*/ */
UINT MMDRV_GetNum(UINT type) UINT MMDRV_GetNum(UINT type)
{ {
TRACE("(%04x)\n", type);
assert(type < MMDRV_MAX); assert(type < MMDRV_MAX);
return llTypes[type].wMaxId; return llTypes[type].wMaxId;
} }
...@@ -294,6 +297,8 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, ...@@ -294,6 +297,8 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
{ {
LPWINE_MLD mld; LPWINE_MLD mld;
UINT i; 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); mld = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
if (!mld) return NULL; if (!mld) return NULL;
...@@ -338,6 +343,8 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags, ...@@ -338,6 +343,8 @@ LPWINE_MLD MMDRV_Alloc(UINT size, UINT type, LPHANDLE hndl, DWORD* dwFlags,
*/ */
void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld) void MMDRV_Free(HANDLE hndl, LPWINE_MLD mld)
{ {
TRACE("(%p, %p)\n", hndl, mld);
if ((UINT)hndl & 0x8000) { if ((UINT)hndl & 0x8000) {
unsigned idx = (UINT)hndl & ~0x8000; unsigned idx = (UINT)hndl & ~0x8000;
if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) { if (idx < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0])) {
...@@ -357,6 +364,7 @@ DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags) ...@@ -357,6 +364,7 @@ DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags)
DWORD dwRet = MMSYSERR_BADDEVICEID; DWORD dwRet = MMSYSERR_BADDEVICEID;
DWORD dwInstance; DWORD dwInstance;
WINE_LLTYPE* llType = &llTypes[mld->type]; WINE_LLTYPE* llType = &llTypes[mld->type];
TRACE("(%p, %04x, 0x%08lx, 0x%08lx)\n", mld, wMsg, dwParam1, dwFlags);
mld->dwDriverInstance = (DWORD)&dwInstance; mld->dwDriverInstance = (DWORD)&dwInstance;
...@@ -398,6 +406,7 @@ DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags) ...@@ -398,6 +406,7 @@ DWORD MMDRV_Open(LPWINE_MLD mld, UINT wMsg, DWORD dwParam1, DWORD dwFlags)
*/ */
DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg) DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
{ {
TRACE("(%p, %04x)\n", mld, wMsg);
return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE); return MMDRV_Message(mld, wMsg, 0L, 0L, TRUE);
} }
...@@ -406,6 +415,7 @@ DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg) ...@@ -406,6 +415,7 @@ DWORD MMDRV_Close(LPWINE_MLD mld, UINT wMsg)
*/ */
LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type) LPWINE_MLD MMDRV_GetByID(UINT uDevID, UINT type)
{ {
TRACE("(%04x, %04x)\n", uDevID, type);
if (uDevID < llTypes[type].wMaxId) if (uDevID < llTypes[type].wMaxId)
return &llTypes[type].lpMlds[uDevID]; return &llTypes[type].lpMlds[uDevID];
if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1) if ((uDevID == (UINT16)-1 || uDevID == (UINT)-1) && llTypes[type].nMapper != -1)
...@@ -420,6 +430,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID) ...@@ -420,6 +430,7 @@ LPWINE_MLD MMDRV_Get(HANDLE _hndl, UINT type, BOOL bCanBeID)
{ {
LPWINE_MLD mld = NULL; LPWINE_MLD mld = NULL;
UINT hndl = (UINT)_hndl; UINT hndl = (UINT)_hndl;
TRACE("(%p, %04x, %c)\n", _hndl, type, bCanBeID ? 'Y' : 'N');
assert(type < MMDRV_MAX); assert(type < MMDRV_MAX);
...@@ -448,6 +459,8 @@ LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType, ...@@ -448,6 +459,8 @@ LPWINE_MLD MMDRV_GetRelated(HANDLE hndl, UINT srcType,
BOOL bSrcCanBeID, UINT dstType) BOOL bSrcCanBeID, UINT dstType)
{ {
LPWINE_MLD mld; LPWINE_MLD mld;
TRACE("(%p, %04x, %c, %04x)\n",
hndl, srcType, bSrcCanBeID ? 'Y' : 'N', dstType);
if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) { if ((mld = MMDRV_Get(hndl, srcType, bSrcCanBeID)) != NULL) {
WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType]; WINE_MM_DRIVER_PART* part = &MMDrvs[mld->mmdIndex].parts[dstType];
...@@ -518,6 +531,7 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg) ...@@ -518,6 +531,7 @@ static BOOL MMDRV_InitPerType(LPWINE_MM_DRIVER lpDrv, UINT type, UINT wMsg)
DWORD ret; DWORD ret;
UINT count = 0; UINT count = 0;
int i, k; int i, k;
TRACE("(%p, %04x, %04x)\n", lpDrv, type, wMsg);
part->nIDMin = part->nIDMax = 0; part->nIDMin = part->nIDMax = 0;
...@@ -707,6 +721,7 @@ static BOOL MMDRV_InitFromRegistry(void) ...@@ -707,6 +721,7 @@ static BOOL MMDRV_InitFromRegistry(void)
char* p2; char* p2;
DWORD type, size; DWORD type, size;
BOOL ret = FALSE; BOOL ret = FALSE;
TRACE("()\n");
if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) { if (RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config\\WinMM", &hKey)) {
TRACE("Cannot open WinMM config key\n"); TRACE("Cannot open WinMM config key\n");
...@@ -742,6 +757,7 @@ static BOOL MMDRV_InitFromRegistry(void) ...@@ -742,6 +757,7 @@ static BOOL MMDRV_InitFromRegistry(void)
*/ */
static BOOL MMDRV_InitHardcoded(void) static BOOL MMDRV_InitHardcoded(void)
{ {
TRACE("()\n");
/* first load hardware drivers */ /* first load hardware drivers */
MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE); MMDRV_Install("wineoss.drv", "wineoss.drv", FALSE);
...@@ -757,6 +773,7 @@ static BOOL MMDRV_InitHardcoded(void) ...@@ -757,6 +773,7 @@ static BOOL MMDRV_InitHardcoded(void)
*/ */
BOOL MMDRV_Init(void) BOOL MMDRV_Init(void)
{ {
TRACE("()\n");
/* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */ /* FIXME: MMDRV_InitFromRegistry shall be MMDRV_Init in a near future */
return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded(); return MMDRV_InitFromRegistry() || MMDRV_InitHardcoded();
} }
...@@ -770,6 +787,7 @@ static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type) ...@@ -770,6 +787,7 @@ static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type)
{ {
WINE_MM_DRIVER_PART* part = &lpDrv->parts[type]; WINE_MM_DRIVER_PART* part = &lpDrv->parts[type];
DWORD ret; DWORD ret;
TRACE("(%p, %04x)\n", lpDrv, type);
if (lpDrv->bIs32 && part->u.fnMessage32) { if (lpDrv->bIs32 && part->u.fnMessage32) {
#if 0 #if 0
...@@ -802,6 +820,7 @@ static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type) ...@@ -802,6 +820,7 @@ static BOOL MMDRV_ExitPerType(LPWINE_MM_DRIVER lpDrv, UINT type)
void MMDRV_Exit(void) void MMDRV_Exit(void)
{ {
int i; int i;
TRACE("()\n");
for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++) for (i = 0; i < sizeof(MM_MLDrvs) / sizeof(MM_MLDrvs[0]); i++)
{ {
......
...@@ -2425,19 +2425,29 @@ UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType, ...@@ -2425,19 +2425,29 @@ UINT WAVE_Open(HANDLE* lphndl, UINT uDeviceID, UINT uType,
lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback, lphndl, (int)uDeviceID, (uType==MMDRV_WAVEOUT)?"Out":"In", lpFormat, dwCallback,
dwInstance, dwFlags, bFrom32?32:16); 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 (lpFormat == NULL) {
if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1)) WARN("bad format\n");
return WAVERR_BADFORMAT;
}
if ((dwFlags & WAVE_MAPPED) && (uDeviceID == (UINT)-1)) {
WARN("invalid parameter\n");
return MMSYSERR_INVALPARAM; 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->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, 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; return MMSYSERR_NOMEM;
}
wod.hWave = handle; wod.hWave = handle;
wod.lpFormat = lpFormat; /* should the struct be copied iso pointer? */ wod.lpFormat = lpFormat; /* should the struct be copied iso pointer? */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment