All driver functions are now properly separated.
This commit is contained in:
parent
74b20fb8d8
commit
b4df16b3b2
|
@ -25,16 +25,20 @@
|
|||
#include <string.h>
|
||||
#include "heap.h"
|
||||
#include "windef.h"
|
||||
#include "wingdi.h"
|
||||
#include "winuser.h"
|
||||
#include "mmddk.h"
|
||||
#include "winemm.h"
|
||||
#include "wine/winbase16.h"
|
||||
#include "wine/debug.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(driver);
|
||||
|
||||
static LPWINE_DRIVER lpDrvItemList = NULL;
|
||||
static LPWINE_DRIVER lpDrvItemList /* = NULL */;
|
||||
|
||||
WINE_MMTHREAD* (*pFnGetMMThread16)(HANDLE16 h) /* = NULL */;
|
||||
LPWINE_DRIVER (*pFnOpenDriver16)(LPCSTR,LPCSTR,LPARAM) /* = NULL */;
|
||||
LRESULT (*pFnCloseDriver16)(HDRVR16,LPARAM,LPARAM) /* = NULL */;
|
||||
LRESULT (*pFnSendMessage16)(HDRVR16,UINT,LPARAM,LPARAM) /* = NULL */;
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_GetNumberOfModuleRefs [internal]
|
||||
|
@ -79,24 +83,21 @@ LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
|
|||
static LRESULT inline DRIVER_SendMessage(LPWINE_DRIVER lpDrv, UINT msg,
|
||||
LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
if (lpDrv->dwFlags & WINE_GDF_16BIT) {
|
||||
LRESULT ret;
|
||||
int map = 0;
|
||||
TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
|
||||
LRESULT ret = 0;
|
||||
|
||||
if ((map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) >= 0) {
|
||||
ret = SendDriverMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
|
||||
if (map == 1)
|
||||
DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
|
||||
if (lpDrv->dwFlags & WINE_GDF_16BIT) {
|
||||
/* no need to check mmsystem presence: the driver must have been opened as a 16 bit one,
|
||||
*/
|
||||
if (pFnSendMessage16)
|
||||
ret = pFnSendMessage16(lpDrv->d.d16.hDriver16, msg, lParam1, lParam2);
|
||||
} else {
|
||||
ret = 0;
|
||||
TRACE("Before call32 proc=%p drvrID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
ret = lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
TRACE("After call32 proc=%p drvrID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx => %08lx\n",
|
||||
lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%08x wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
lpDrv->d.d32.lpDrvProc, lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
return lpDrv->d.d32.lpDrvProc(lpDrv->d.d32.dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
@ -274,40 +275,6 @@ LPWINE_DRIVER DRIVER_TryOpenDriver32(LPCSTR fn, LPARAM lParam2)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_TryOpenDriver16 [internal]
|
||||
*
|
||||
* Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
|
||||
*/
|
||||
static LPWINE_DRIVER DRIVER_TryOpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = NULL;
|
||||
LPCSTR cause = 0;
|
||||
|
||||
TRACE("(%s, %08lX);\n", debugstr_a(sn), lParam2);
|
||||
|
||||
lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
|
||||
if (lpDrv == NULL) {cause = "OOM"; goto exit;}
|
||||
|
||||
/* FIXME: shall we do some black magic here on sn ?
|
||||
* drivers32 => drivers
|
||||
* mci32 => mci
|
||||
* ...
|
||||
*/
|
||||
lpDrv->d.d16.hDriver16 = OpenDriver16(fn, sn, lParam2);
|
||||
if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;}
|
||||
lpDrv->dwFlags = WINE_GDF_16BIT;
|
||||
|
||||
if (!DRIVER_AddToList(lpDrv, 0, lParam2)) {cause = "load failed"; goto exit;}
|
||||
|
||||
TRACE("=> %p\n", lpDrv);
|
||||
return lpDrv;
|
||||
exit:
|
||||
HeapFree(GetProcessHeap(), 0, lpDrv);
|
||||
TRACE("Unable to load 32 bit module %s: %s\n", debugstr_a(fn), cause);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* OpenDriverA [WINMM.@]
|
||||
* DrvOpenA [WINMM.@]
|
||||
|
@ -334,8 +301,20 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
|
|||
(lpDrv = DRIVER_TryOpenDriver32(libName, lParam2)))
|
||||
goto the_end;
|
||||
|
||||
if (!(lpDrv = DRIVER_TryOpenDriver16(lpDriverName, lpSectionName, lParam2)))
|
||||
/* now we will try a 16 bit driver (and add all the glue to make it work... which
|
||||
* is located in our mmsystem implementation)
|
||||
* so ensure, we can load our mmsystem, otherwise just fail
|
||||
*/
|
||||
WINMM_CheckForMMSystem();
|
||||
if (pFnOpenDriver16 &&
|
||||
(lpDrv = pFnOpenDriver16(lpDriverName, lpSectionName, lParam2)))
|
||||
{
|
||||
if (DRIVER_AddToList(lpDrv, 0, lParam2)) goto the_end;
|
||||
HeapFree(GetProcessHeap(), 0, lpDrv);
|
||||
}
|
||||
TRACE("Failed to open driver %s from system.ini file, section %s\n", debugstr_a(lpDriverName), debugstr_a(lpSectionName));
|
||||
return 0;
|
||||
|
||||
the_end:
|
||||
if (lpDrv) TRACE("=> %08lx\n", (DWORD)lpDrv);
|
||||
return (HDRVR)lpDrv;
|
||||
|
@ -369,7 +348,10 @@ LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
|
|||
if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL)
|
||||
{
|
||||
if (lpDrv->dwFlags & WINE_GDF_16BIT)
|
||||
CloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
|
||||
{
|
||||
if (pFnCloseDriver16)
|
||||
pFnCloseDriver16(lpDrv->d.d16.hDriver16, lParam1, lParam2);
|
||||
}
|
||||
else
|
||||
{
|
||||
DRIVER_SendMessage(lpDrv, DRV_CLOSE, lParam1, lParam2);
|
||||
|
@ -464,3 +446,64 @@ LRESULT WINAPI DefDriverProc(DWORD dwDriverIdentifier, HDRVR hDrv,
|
|||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DriverCallback [WINMM.@]
|
||||
*/
|
||||
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
|
||||
UINT wMsg, DWORD dwUser, DWORD dwParam1,
|
||||
DWORD dwParam2)
|
||||
{
|
||||
TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
|
||||
dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
|
||||
|
||||
switch (uFlags & DCB_TYPEMASK) {
|
||||
case DCB_NULL:
|
||||
TRACE("Null !\n");
|
||||
if (dwCallBack)
|
||||
WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
|
||||
break;
|
||||
case DCB_WINDOW:
|
||||
TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
|
||||
PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
|
||||
break;
|
||||
case DCB_TASK: /* aka DCB_THREAD */
|
||||
TRACE("Task(%04lx) !\n", dwCallBack);
|
||||
PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
|
||||
break;
|
||||
case DCB_FUNCTION:
|
||||
TRACE("Function (32 bit) !\n");
|
||||
((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
|
||||
break;
|
||||
case DCB_EVENT:
|
||||
TRACE("Event(%08lx) !\n", dwCallBack);
|
||||
SetEvent((HANDLE)dwCallBack);
|
||||
break;
|
||||
case 6: /* I would dub it DCB_MMTHREADSIGNAL */
|
||||
/* this is an undocumented DCB_ value used for mmThreads
|
||||
* loword of dwCallBack contains the handle of the lpMMThd block
|
||||
* which dwSignalCount has to be incremented
|
||||
*/
|
||||
if (pFnGetMMThread16)
|
||||
{
|
||||
WINE_MMTHREAD* lpMMThd = pFnGetMMThread16(LOWORD(dwCallBack));
|
||||
|
||||
TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
|
||||
/* same as mmThreadSignal16 */
|
||||
InterlockedIncrement(&lpMMThd->dwSignalCount);
|
||||
SetEvent(lpMMThd->hEvent);
|
||||
/* some other stuff on lpMMThd->hVxD */
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case 4:
|
||||
/* this is an undocumented DCB_ value for... I don't know */
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
|
||||
return FALSE;
|
||||
}
|
||||
TRACE("Done\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,9 @@ extern LONG CALLBACK MMSYSTEM_CallTo16_long_lwll (LPMMIOPROC16,LONG,WORD,LONG,LO
|
|||
/* ### stop build ### */
|
||||
|
||||
static WINE_MMTHREAD* WINMM_GetmmThread(HANDLE16);
|
||||
static LPWINE_DRIVER DRIVER_OpenDriver16(LPCSTR, LPCSTR, LPARAM);
|
||||
static LRESULT DRIVER_CloseDriver16(HDRVR16, LPARAM, LPARAM);
|
||||
static LRESULT DRIVER_SendMessage16(HDRVR16, UINT, LPARAM, LPARAM);
|
||||
static LRESULT MMIO_Callback16(SEGPTR, LPMMIOINFO, UINT, LPARAM, LPARAM);
|
||||
|
||||
/* ###################################################
|
||||
|
@ -81,11 +84,17 @@ BOOL WINAPI MMSYSTEM_LibMain(DWORD fdwReason, HINSTANCE hinstDLL, WORD ds,
|
|||
WINMM_IData->hWinMM16Instance = hinstDLL;
|
||||
/* hook in our 16 bit function pointers */
|
||||
pFnGetMMThread16 = WINMM_GetmmThread;
|
||||
pFnOpenDriver16 = DRIVER_OpenDriver16;
|
||||
pFnCloseDriver16 = DRIVER_CloseDriver16;
|
||||
pFnSendMessage16 = DRIVER_SendMessage16;
|
||||
pFnMmioCallback16 = MMIO_Callback16;
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
WINMM_IData->hWinMM16Instance = 0;
|
||||
pFnGetMMThread16 = NULL;
|
||||
pFnOpenDriver16 = NULL;
|
||||
pFnCloseDriver16 = NULL;
|
||||
pFnSendMessage16 = NULL;
|
||||
pFnMmioCallback16 = NULL;
|
||||
break;
|
||||
case DLL_THREAD_ATTACH:
|
||||
|
@ -2187,7 +2196,7 @@ void WINAPI WMMMidiRunOnce16(void)
|
|||
*
|
||||
* Map a 32 bit driver message to a 16 bit driver message.
|
||||
*/
|
||||
WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
static WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
{
|
||||
WINMM_MapType ret = WINMM_MAP_MSGERROR;
|
||||
|
||||
|
@ -2255,7 +2264,7 @@ WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
|||
*
|
||||
* UnMap a 32 bit driver message to a 16 bit driver message.
|
||||
*/
|
||||
WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
static WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
{
|
||||
WINMM_MapType ret = WINMM_MAP_MSGERROR;
|
||||
|
||||
|
@ -2296,6 +2305,74 @@ WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_TryOpenDriver16 [internal]
|
||||
*
|
||||
* Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
|
||||
*/
|
||||
static LPWINE_DRIVER DRIVER_OpenDriver16(LPCSTR fn, LPCSTR sn, LPARAM lParam2)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = NULL;
|
||||
LPCSTR cause = 0;
|
||||
|
||||
TRACE("(%s, %08lX);\n", debugstr_a(sn), lParam2);
|
||||
|
||||
lpDrv = HeapAlloc(GetProcessHeap(), 0, sizeof(WINE_DRIVER));
|
||||
if (lpDrv == NULL) {cause = "OOM"; goto exit;}
|
||||
|
||||
/* FIXME: shall we do some black magic here on sn ?
|
||||
* drivers32 => drivers
|
||||
* mci32 => mci
|
||||
* ...
|
||||
*/
|
||||
lpDrv->d.d16.hDriver16 = OpenDriver16(fn, sn, lParam2);
|
||||
if (lpDrv->d.d16.hDriver16 == 0) {cause = "Not a 16 bit driver"; goto exit;}
|
||||
lpDrv->dwFlags = WINE_GDF_16BIT;
|
||||
|
||||
TRACE("=> %p\n", lpDrv);
|
||||
return lpDrv;
|
||||
exit:
|
||||
HeapFree(GetProcessHeap(), 0, lpDrv);
|
||||
TRACE("Unable to load 16 bit module %s: %s\n", debugstr_a(fn), cause);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* DRIVER_SendMessage16
|
||||
*
|
||||
*
|
||||
*/
|
||||
static LRESULT DRIVER_SendMessage16(HDRVR16 hDrv16, UINT msg,
|
||||
LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
LRESULT ret = 0;
|
||||
WINMM_MapType map;
|
||||
|
||||
TRACE("Before sdm16 call hDrv=%04x wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
hDrv16, msg, lParam1, lParam2);
|
||||
|
||||
switch (map = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2)) {
|
||||
case WINMM_MAP_OKMEM:
|
||||
case WINMM_MAP_OK:
|
||||
ret = SendDriverMessage16(hDrv16, msg, lParam1, lParam2);
|
||||
if (map == WINMM_MAP_OKMEM)
|
||||
DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* DRIVER_CloseDriver16
|
||||
*
|
||||
*
|
||||
*/
|
||||
static LRESULT DRIVER_CloseDriver16(HDRVR16 hDrv16, LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
return CloseDriver16(hDrv16, lParam1, lParam2);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DrvOpen [MMSYSTEM.1100]
|
||||
*/
|
||||
|
|
|
@ -505,63 +505,3 @@ UINT WINAPI mmsystemGetVersion(void)
|
|||
TRACE("3.10 (Win95?)\n");
|
||||
return 0x030a;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DriverCallback [WINMM.@]
|
||||
*/
|
||||
BOOL WINAPI DriverCallback(DWORD dwCallBack, UINT uFlags, HDRVR hDev,
|
||||
UINT wMsg, DWORD dwUser, DWORD dwParam1,
|
||||
DWORD dwParam2)
|
||||
{
|
||||
TRACE("(%08lX, %04X, %04X, %04X, %08lX, %08lX, %08lX); !\n",
|
||||
dwCallBack, uFlags, hDev, wMsg, dwUser, dwParam1, dwParam2);
|
||||
|
||||
switch (uFlags & DCB_TYPEMASK) {
|
||||
case DCB_NULL:
|
||||
TRACE("Null !\n");
|
||||
if (dwCallBack)
|
||||
WARN("uFlags=%04X has null DCB value, but dwCallBack=%08lX is not null !\n", uFlags, dwCallBack);
|
||||
break;
|
||||
case DCB_WINDOW:
|
||||
TRACE("Window(%04lX) handle=%04X!\n", dwCallBack, hDev);
|
||||
PostMessageA((HWND)dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
|
||||
break;
|
||||
case DCB_TASK: /* aka DCB_THREAD */
|
||||
TRACE("Task(%04lx) !\n", dwCallBack);
|
||||
PostThreadMessageA(dwCallBack, wMsg, (WPARAM)hDev, dwParam1);
|
||||
break;
|
||||
case DCB_FUNCTION:
|
||||
TRACE("Function (32 bit) !\n");
|
||||
((LPDRVCALLBACK)dwCallBack)(hDev, wMsg, dwUser, dwParam1, dwParam2);
|
||||
break;
|
||||
case DCB_EVENT:
|
||||
TRACE("Event(%08lx) !\n", dwCallBack);
|
||||
SetEvent((HANDLE)dwCallBack);
|
||||
break;
|
||||
case 6: /* I would dub it DCB_MMTHREADSIGNAL */
|
||||
/* this is an undocumented DCB_ value used for mmThreads
|
||||
* loword of dwCallBack contains the handle of the lpMMThd block
|
||||
* which dwSignalCount has to be incremented
|
||||
*/
|
||||
{
|
||||
WINE_MMTHREAD* lpMMThd = MapSL( MAKESEGPTR(LOWORD(dwCallBack), 0) );
|
||||
|
||||
TRACE("mmThread (%04x, %p) !\n", LOWORD(dwCallBack), lpMMThd);
|
||||
/* same as mmThreadSignal16 */
|
||||
InterlockedIncrement(&lpMMThd->dwSignalCount);
|
||||
SetEvent(lpMMThd->hEvent);
|
||||
/* some other stuff on lpMMThd->hVxD */
|
||||
}
|
||||
break;
|
||||
#if 0
|
||||
case 4:
|
||||
/* this is an undocumented DCB_ value for... I don't know */
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
WARN("Unknown callback type %d\n", uFlags & DCB_TYPEMASK);
|
||||
return FALSE;
|
||||
}
|
||||
TRACE("Done\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -290,8 +290,6 @@ void TIME_MMTimeStart(void);
|
|||
void TIME_MMTimeStop(void);
|
||||
|
||||
/* temporary definitions */
|
||||
WINMM_MapType DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2);
|
||||
WINMM_MapType DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2);
|
||||
WINMM_MapType MCI_MapMsg16To32A (WORD uDevType, WORD wMsg, DWORD* lParam);
|
||||
WINMM_MapType MCI_UnMapMsg16To32A(WORD uDevType, WORD wMsg, DWORD lParam);
|
||||
WINMM_MapType MCI_MapMsg32ATo16 (WORD uDevType, WORD wMsg, DWORD dwFlags, DWORD* lParam);
|
||||
|
@ -343,6 +341,9 @@ extern LPWINE_MM_IDATA WINMM_IData;
|
|||
* NULL otherwise
|
||||
*/
|
||||
extern LRESULT (*pFnMmioCallback16)(SEGPTR,LPMMIOINFO,UINT,LPARAM,LPARAM);
|
||||
extern LPWINE_DRIVER (*pFnOpenDriver16)(LPCSTR,LPCSTR,LPARAM);
|
||||
extern LRESULT (*pFnCloseDriver16)(HDRVR16,LPARAM,LPARAM);
|
||||
extern LRESULT (*pFnSendMessage16)(HDRVR16,UINT,LPARAM,LPARAM);
|
||||
extern WINE_MMTHREAD* (*pFnGetMMThread16)(HANDLE16);
|
||||
|
||||
/* HANDLE16 -> HANDLE conversions */
|
||||
|
|
Loading…
Reference in New Issue