Commit 4f81c3ea authored by Eric Pouech's avatar Eric Pouech Committed by Alexandre Julliard

Replaced Wine specific DRIVER_GetType by a correct implementation of

GetDriverFlag.
parent 7be462dd
......@@ -2249,7 +2249,7 @@ static BOOL MMDRV_Install(LPCSTR name, int num, BOOL bIsMapper)
{ lpDrv->parts[_w].u.fnMessage##_y = func; count++; \
TRACE("Got %d bit func '%s'\n", _y, #_x); }
if ((DRIVER_GetType(lpDrv->hDrvr) & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_32) {
if ((GetDriverFlags(lpDrv->hDrvr) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) == WINE_GDF_EXIST) {
WINEMM_msgFunc32 func;
lpDrv->bIs32 = TRUE;
......
......@@ -1920,8 +1920,8 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
if (!wmd) {
dwRet = MCIERR_INVALID_DEVICE_ID;
} else {
switch (DRIVER_GetType(wmd->hDrv)) {
case WINE_DI_TYPE_16:
switch (GetDriverFlags(wmd->hDrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) {
case WINE_GDF_EXIST|WINE_GDF_16BIT:
{
MCI_MapType res;
......@@ -1946,11 +1946,11 @@ DWORD MCI_SendCommandFrom32(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
}
}
break;
case WINE_DI_TYPE_32:
case WINE_GDF_EXIST:
dwRet = SendDriverMessage(wmd->hDrv, wMsg, dwParam1, dwParam2);
break;
default:
WARN("Unknown driver type=%u\n", DRIVER_GetType(wmd->hDrv));
WARN("Unknown driver %u\n", wmd->hDrv);
dwRet = MCIERR_DRIVER_INTERNAL;
}
}
......@@ -1970,11 +1970,11 @@ DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
} else {
MCI_MapType res;
switch (DRIVER_GetType(wmd->hDrv)) {
case WINE_DI_TYPE_16:
switch (GetDriverFlags(wmd->hDrv) & (WINE_GDF_EXIST|WINE_GDF_16BIT)) {
case WINE_GDF_EXIST|WINE_GDF_16BIT:
dwRet = SendDriverMessage16(wmd->hDrv, wMsg, dwParam1, dwParam2);
break;
case WINE_DI_TYPE_32:
case WINE_GDF_EXIST:
switch (res = MCI_MapMsg16To32A(wmd->wType, wMsg, &dwParam2)) {
case MCI_MAP_MSGERROR:
TRACE("Not handled yet (%s)\n", MCI_MessageToString(wMsg));
......@@ -1996,7 +1996,7 @@ DWORD MCI_SendCommandFrom16(UINT wDevID, UINT16 wMsg, DWORD dwParam1, DWORD dwPa
}
break;
default:
WARN("Unknown driver type=%u\n", DRIVER_GetType(wmd->hDrv));
WARN("Unknown driver %u\n", wmd->hDrv);
dwRet = MCIERR_DRIVER_INTERNAL;
}
}
......
......@@ -88,48 +88,13 @@ HMODULE WINAPI GetDriverModuleHandle(HDRVR hDriver);
HDRVR16 WINAPI GetNextDriver16(HDRVR16, DWORD);
BOOL16 WINAPI GetDriverInfo16(HDRVR16, DRIVERINFOSTRUCT16 *);
DWORD WINAPI GetDriverFlags( HDRVR hDriver );
#ifdef __WINE__
/* The following definitions are WINE internals */
/* FIXME: This is a WINE internal struct and should be moved in include/wine directory
* Please note that WINE shares 16 and 32 bit drivers on a single list...
* Basically, we maintain an external double view on drivers, so that a 16 bit drivers
* can be loaded/used... by 32 functions transparently
/* this call (GetDriverFlags) is not documented, nor the flags returned.
* here are Wine only definitions
*/
/* Who said goofy boy ? */
#define WINE_DI_MAGIC 0x900F1B01
typedef struct tagWINE_DRIVER
{
DWORD dwMagic;
char szAliasName[128];
/* as usual LPWINE_DRIVER == hDriver32 */
HDRVR16 hDriver16;
union {
struct {
HMODULE16 hModule;
DRIVERPROC16 lpDrvProc;
} d16;
struct {
HMODULE hModule;
DRIVERPROC lpDrvProc;
} d32;
} d;
DWORD dwDriverID;
DWORD dwFlags;
struct tagWINE_DRIVER* lpPrevItem;
struct tagWINE_DRIVER* lpNextItem;
} WINE_DRIVER, *LPWINE_DRIVER;
/* values for dwFlags */
#define WINE_DI_TYPE_MASK 0x00000007ul
#define WINE_DI_TYPE_16 0x00000001ul
#define WINE_DI_TYPE_32 0x00000002ul
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR, HMODULE16, DRIVERPROC16, LPARAM, BOOL);
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR, HMODULE, DRIVERPROC, LPARAM, BOOL);
int DRIVER_GetType(HDRVR);
#endif /* __WINE__ */
#define WINE_GDF_EXIST 0x80000000
#define WINE_GDF_16BIT 0x10000000
#endif
#endif /* __WINE_DRIVER_H */
......@@ -19,13 +19,47 @@
DEFAULT_DEBUG_CHANNEL(driver)
/* The following definitions are WINE internals */
/* FIXME: This is a WINE internal struct and should be moved in include/wine directory
* Please note that WINE shares 16 and 32 bit drivers on a single list...
* Basically, we maintain an external double view on drivers, so that a 16 bit drivers
* can be loaded/used... by 32 functions transparently
*/
/* Who said goofy boy ? */
#define WINE_DI_MAGIC 0x900F1B01
typedef struct tagWINE_DRIVER
{
DWORD dwMagic;
char szAliasName[128];
/* as usual LPWINE_DRIVER == hDriver32 */
HDRVR16 hDriver16;
union {
struct {
HMODULE16 hModule;
DRIVERPROC16 lpDrvProc;
} d16;
struct {
HMODULE hModule;
DRIVERPROC lpDrvProc;
} d32;
} d;
DWORD dwDriverID;
DWORD dwFlags;
struct tagWINE_DRIVER* lpPrevItem;
struct tagWINE_DRIVER* lpNextItem;
} WINE_DRIVER, *LPWINE_DRIVER;
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR, HMODULE16, DRIVERPROC16, LPARAM, BOOL);
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR, HMODULE, DRIVERPROC, LPARAM, BOOL);
static LPWINE_DRIVER lpDrvItemList = NULL;
/* TODO list :
* - LoadModule count and clean up is not handled correctly (it's not a
* problem as long as FreeLibrary is not working correctly)
* - shoudln't the allocations be done on a per process basis ?
* - get rid of external function "int DRIVER_GetType(HDRVR hDrvr)"
* - split 16/32 bit functions between DLLs as windows do (16 bit in USER, 32 bit in WINMM)
*/
......@@ -63,23 +97,16 @@ static void WINE_UNUSED DRIVER_LoadStartupDrivers(void)
static WORD DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)
{
LPWINE_DRIVER lpDrv;
DWORD type = lpNewDrv->dwFlags & WINE_DI_TYPE_MASK;
WORD count = 0;
for (lpDrv = lpDrvItemList; lpDrv; lpDrv = lpDrv->lpNextItem) {
if ((lpDrv->dwFlags & WINE_DI_TYPE_MASK) == type) {
switch (type) {
case WINE_DI_TYPE_16:
if (lpDrv->d.d16.hModule == lpNewDrv->d.d16.hModule)
if (lpDrv->dwFlags & WINE_GDF_16BIT) {
if (lpDrv->d.d16.hModule == lpNewDrv->d.d16.hModule) {
count++;
break;
case WINE_DI_TYPE_32:
if (lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule)
}
} else {
if (lpDrv->d.d32.hModule == lpNewDrv->d.d32.hModule) {
count++;
break;
default:
FIXME("Unsupported driver type: %ld\n", type);
break;
}
}
}
......@@ -118,18 +145,6 @@ static LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
}
/**************************************************************************
* DRIVER_GetType [internal]
*
* From a hDrvr (being 16 or 32 bits), returns TRUE the flags for the driver.
*/
int DRIVER_GetType(HDRVR hDrvr)
{
LPWINE_DRIVER lpDrv = DRIVER_FindFromHDrvr(hDrvr);
return (lpDrv) ? (lpDrv->dwFlags & WINE_DI_TYPE_MASK) : 0;
}
/**************************************************************************
* DRIVER_MapMsg16To32 [internal]
*
* Map a 16 bit driver message to a 32 bit driver message.
......@@ -475,14 +490,12 @@ LRESULT WINAPI SendDriverMessage16(HDRVR16 hDriver, UINT16 msg, LPARAM lParam1,
lpDrv = DRIVER_FindFromHDrvr16(hDriver);
if (lpDrv != NULL && lpDrv->hDriver16 == hDriver) {
switch (lpDrv->dwFlags & WINE_DI_TYPE_MASK) {
case WINE_DI_TYPE_16:
if (lpDrv->dwFlags & WINE_GDF_16BIT) {
TRACE("Before CallDriverProc proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID, hDriver, msg, lParam1, lParam2);
retval = DRIVER_CallTo16_long_lwwll((FARPROC16)lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID,
hDriver, msg, lParam1, lParam2);
break;
case WINE_DI_TYPE_32:
} else {
mapRet = DRIVER_MapMsg16To32(msg, &lParam1, &lParam2);
if (mapRet >= 0) {
TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
......@@ -494,10 +507,6 @@ LRESULT WINAPI SendDriverMessage16(HDRVR16 hDriver, UINT16 msg, LPARAM lParam1,
} else {
retval = 0;
}
break;
default:
FIXME("Unknown driver type %08lx\n", lpDrv->dwFlags);
break;
}
} else {
WARN("Bad driver handle %u\n", hDriver);
......@@ -522,8 +531,7 @@ LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
lpDrv = DRIVER_FindFromHDrvr(hDriver);
if (lpDrv != NULL) {
switch (lpDrv->dwFlags & WINE_DI_TYPE_MASK) {
case WINE_DI_TYPE_16:
if (lpDrv->dwFlags & WINE_GDF_16BIT) {
mapRet = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2);
if (mapRet >= 0) {
TRACE("Before CallDriverProc proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
......@@ -536,15 +544,10 @@ LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
} else {
retval = 0;
}
break;
case WINE_DI_TYPE_32:
} else {
TRACE("Before func32 call proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
lpDrv->d.d32.lpDrvProc, lpDrv->dwDriverID, hDriver, msg, lParam1, lParam2);
retval = lpDrv->d.d32.lpDrvProc(lpDrv->dwDriverID, hDriver, msg, lParam1, lParam2);
break;
default:
FIXME("Unknown driver type %08lx\n", lpDrv->dwFlags);
break;
}
} else {
WARN("Bad driver handle %u\n", hDriver);
......@@ -671,7 +674,7 @@ LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR lpName, HMODULE16 hModule, DRIVERPR
lpDrv = HeapAlloc(SystemHeap, 0, sizeof(WINE_DRIVER));
if (lpDrv != NULL) {
lpDrv->dwFlags = WINE_DI_TYPE_16;
lpDrv->dwFlags = WINE_GDF_EXIST|WINE_GDF_16BIT;
lpDrv->dwDriverID = 0;
lpDrv->hDriver16 = DRIVER_CreateDrvr16();
lstrcpynA(lpDrv->szAliasName, lpName, sizeof(lpDrv->szAliasName));
......@@ -699,7 +702,7 @@ LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR lpName, HMODULE hModule, DRIVERPROC
lpDrv = HeapAlloc(SystemHeap, 0, sizeof(WINE_DRIVER));
if (lpDrv != NULL) {
lpDrv->dwFlags = WINE_DI_TYPE_32;
lpDrv->dwFlags = WINE_GDF_EXIST;
lpDrv->dwDriverID = 0;
lpDrv->hDriver16 = DRIVER_CreateDrvr16();
lstrcpynA(lpDrv->szAliasName, lpName, sizeof(lpDrv->szAliasName));
......@@ -908,8 +911,7 @@ HMODULE16 WINAPI GetDriverModuleHandle16(HDRVR16 hDrvr)
TRACE("(%04x);\n", hDrvr);
lpDrv = DRIVER_FindFromHDrvr16(hDrvr);
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr &&
(lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_16) {
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr && (lpDrv->dwFlags & WINE_GDF_16BIT)) {
hModule = lpDrv->d.d16.hModule;
}
TRACE("=> %d\n", hModule);
......@@ -918,12 +920,24 @@ HMODULE16 WINAPI GetDriverModuleHandle16(HDRVR16 hDrvr)
/**************************************************************************
* GetDriverFlags [WINMM.13]
* [in] hDrvr handle to the driver
*
* Returns:
* 0x00000000 if hDrvr is an invalid handle
* 0x80000000 if hDrvr is a valid 32 bit driver
* 0x90000000 if hDrvr is a valid 16 bit driver
*/
DWORD WINAPI GetDriverFlags(HDRVR hDrvr)
{
FIXME("(%04x); stub!\n", hDrvr);
/* should I merge it with DRIVER_GetType() ? */
return 0;
LPWINE_DRIVER lpDrv;
DWORD ret = 0;
TRACE("(%04x)\n", hDrvr);
if ((lpDrv = DRIVER_FindFromHDrvr(hDrvr)) != NULL) {
ret = lpDrv->dwFlags;
}
return ret;
}
/**************************************************************************
......@@ -937,7 +951,7 @@ HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
TRACE("(%04x);\n", hDrvr);
lpDrv = DRIVER_FindFromHDrvr(hDrvr);
if (lpDrv != NULL && (lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_32) {
if (lpDrv != NULL && !(lpDrv->dwFlags & WINE_GDF_16BIT)) {
hModule = lpDrv->d.d32.hModule;
}
TRACE("=> %d\n", hModule);
......@@ -989,7 +1003,7 @@ BOOL16 WINAPI GetDriverInfo16(HDRVR16 hDrvr, LPDRIVERINFOSTRUCT16 lpDrvInfo)
lpDrv = DRIVER_FindFromHDrvr16(hDrvr);
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr &&
(lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_16) {
(lpDrv->dwFlags & WINE_GDF_16BIT)) {
lpDrvInfo->hDriver = lpDrv->hDriver16;
lpDrvInfo->hModule = lpDrv->d.d16.hModule;
lstrcpynA(lpDrvInfo->szAliasName, lpDrv->szAliasName, sizeof(lpDrvInfo->szAliasName));
......
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