/************************************************************************** * mmioOpen [MMSYSTEM.1210] */ HMMIO16 WINAPI mmioOpen16(LPSTR szFileName, MMIOINFO16* lpmmioinfo16, DWORD dwOpenFlags) { HMMIO ret; if (lpmmioinfo16) { MMIOINFO mmioinfo; struct mmio_thunk* thunk = NULL; memset(&mmioinfo, 0, sizeof(mmioinfo)); EnterCriticalSection(&mmio_cs); if (!(thunk = MMIO_AddThunk(lpmmioinfo16->pIOProc, lpmmioinfo16->pchBuffer))) { LeaveCriticalSection(&mmio_cs); return 0; } mmioinfo.dwFlags = lpmmioinfo16->dwFlags; mmioinfo.fccIOProc = lpmmioinfo16->fccIOProc; mmioinfo.pIOProc = lpmmioinfo16->pIOProc ? (LPMMIOPROC)thunk : 0; mmioinfo.cchBuffer = lpmmioinfo16->cchBuffer; mmioinfo.pchBuffer = MapSL((DWORD)lpmmioinfo16->pchBuffer); mmioinfo.adwInfo[0] = lpmmioinfo16->adwInfo[0]; /* if we don't have a file name, it's likely a passed open file descriptor */ if (!szFileName) mmioinfo.adwInfo[0] = (DWORD)DosFileHandleToWin32Handle(mmioinfo.adwInfo[0]); mmioinfo.adwInfo[1] = lpmmioinfo16->adwInfo[1]; mmioinfo.adwInfo[2] = lpmmioinfo16->adwInfo[2]; ret = mmioOpenA(szFileName, &mmioinfo, dwOpenFlags); if (!ret || (dwOpenFlags & (MMIO_PARSE|MMIO_EXIST))) { thunk->pfn16 = NULL; thunk->hMmio = NULL; } else thunk->hMmio = ret; if (ret && (dwOpenFlags & MMIO_ALLOCBUF)) { MMIOINFO m; if (lpmmioinfo16->pchBuffer) FIXME("ooch\n"); /* FIXME: check whether mmioOpen should set pchBuffer */ mmioGetInfo(ret, &m, 0); thunk->segbuffer = MapLS(m.pchBuffer); } LeaveCriticalSection(&mmio_cs); lpmmioinfo16->wErrorRet = mmioinfo.wErrorRet; lpmmioinfo16->hmmio = HMMIO_16(mmioinfo.hmmio); } else { ret = mmioOpenA(szFileName, NULL, dwOpenFlags); } return HMMIO_16(ret); }
/************************************************************************** * mmioGetInfo [MMSYSTEM.1215] */ MMRESULT16 WINAPI mmioGetInfo16(HMMIO16 hmmio, MMIOINFO16* lpmmioinfo, UINT16 uFlags) { MMIOINFO mmioinfo; MMRESULT ret; struct mmio_thunk* thunk; TRACE("(0x%04x,%p,0x%08x)\n", hmmio, lpmmioinfo, uFlags); EnterCriticalSection(&mmio_cs); if ((thunk = MMIO_HasThunk(HMMIO_32(hmmio))) == NULL) { LeaveCriticalSection(&mmio_cs); return MMSYSERR_INVALHANDLE; } ret = mmioGetInfo(HMMIO_32(hmmio), &mmioinfo, uFlags); if (ret != MMSYSERR_NOERROR) { LeaveCriticalSection(&mmio_cs); return ret; } lpmmioinfo->dwFlags = mmioinfo.dwFlags; lpmmioinfo->fccIOProc = mmioinfo.fccIOProc; lpmmioinfo->pIOProc = thunk->pfn16; lpmmioinfo->wErrorRet = mmioinfo.wErrorRet; lpmmioinfo->hTask = HTASK_16(mmioinfo.hTask); lpmmioinfo->cchBuffer = mmioinfo.cchBuffer; lpmmioinfo->pchBuffer = (void*)thunk->segbuffer; lpmmioinfo->pchNext = (void*)(thunk->segbuffer + (mmioinfo.pchNext - mmioinfo.pchBuffer)); lpmmioinfo->pchEndRead = (void*)(thunk->segbuffer + (mmioinfo.pchEndRead - mmioinfo.pchBuffer)); lpmmioinfo->pchEndWrite = (void*)(thunk->segbuffer + (mmioinfo.pchEndWrite - mmioinfo.pchBuffer)); lpmmioinfo->lBufOffset = mmioinfo.lBufOffset; lpmmioinfo->lDiskOffset = mmioinfo.lDiskOffset; lpmmioinfo->adwInfo[0] = mmioinfo.adwInfo[0]; lpmmioinfo->adwInfo[1] = mmioinfo.adwInfo[1]; lpmmioinfo->adwInfo[2] = mmioinfo.adwInfo[2]; lpmmioinfo->dwReserved1 = 0; lpmmioinfo->dwReserved2 = 0; lpmmioinfo->hmmio = HMMIO_16(mmioinfo.hmmio); LeaveCriticalSection(&mmio_cs); return MMSYSERR_NOERROR; }