mirror of
https://github.com/reactos/wine.git
synced 2024-11-28 22:20:26 +00:00
Better 16/32 bit driver messages mapping and handling.
Better protection against bad handles.
This commit is contained in:
parent
7f95bb7f75
commit
3fb2f4289f
@ -87,13 +87,18 @@ HDRVR16 WINAPI GetNextDriver16(HDRVR16, DWORD);
|
||||
BOOL16 WINAPI GetDriverInfo16(HDRVR16, DRIVERINFOSTRUCT16 *);
|
||||
|
||||
/* 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
|
||||
/* 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;
|
||||
@ -118,8 +123,9 @@ typedef struct tagWINE_DRIVER
|
||||
#define WINE_DI_TYPE_16 0x00000001ul
|
||||
#define WINE_DI_TYPE_32 0x00000002ul
|
||||
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR, HMODULE16, DRIVERPROC16, LPARAM);
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR, HMODULE, DRIVERPROC, LPARAM);
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR, HMODULE16, DRIVERPROC16, LPARAM, BOOL);
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR, HMODULE, DRIVERPROC, LPARAM, BOOL);
|
||||
int DRIVER_GetType(HDRVR);
|
||||
|
||||
#if 0
|
||||
#errro "it's never used"
|
||||
|
441
windows/driver.c
441
windows/driver.c
@ -8,6 +8,7 @@
|
||||
* Copyright 1999 Eric Pouech
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include "wine/winuser16.h"
|
||||
#include "heap.h"
|
||||
#include "callback.h"
|
||||
@ -15,13 +16,13 @@
|
||||
#include "ldt.h"
|
||||
#include "module.h"
|
||||
#include "debug.h"
|
||||
#include <string.h>
|
||||
#include "mmsystem.h"
|
||||
|
||||
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
|
||||
* long as FreeLibrary is not working correctly)
|
||||
* - msacm has some FIXME related to new code here...
|
||||
*/
|
||||
|
||||
@ -33,12 +34,12 @@ static void WINE_UNUSED DRIVER_LoadStartupDrivers(void)
|
||||
HDRVR16 hDrv;
|
||||
char str[256];
|
||||
LPSTR ptr;
|
||||
|
||||
|
||||
if (GetPrivateProfileStringA("drivers", NULL, "", str, sizeof(str), "SYSTEM.INI") < 2) {
|
||||
ERR(driver,"Can't find drivers section in system.ini\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
for (ptr = str; lstrlenA(ptr) != 0; ptr += lstrlenA(ptr) + 1) {
|
||||
TRACE(driver, "str='%s'\n", ptr);
|
||||
hDrv = OpenDriver16(ptr, "drivers", 0L);
|
||||
@ -79,6 +80,11 @@ static WORD DRIVER_GetNumberOfModuleRefs(LPWINE_DRIVER lpNewDrv)
|
||||
return count;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_FindFromHDrvr16 [internal]
|
||||
*
|
||||
* From a hDrvr being 16 bits, returns the WINE internal structure.
|
||||
*/
|
||||
static LPWINE_DRIVER DRIVER_FindFromHDrvr16(HDRVR16 hDrvr)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
@ -91,6 +97,27 @@ static LPWINE_DRIVER DRIVER_FindFromHDrvr16(HDRVR16 hDrvr)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_FindFromHDrvr [internal]
|
||||
*
|
||||
* From a hDrvr (being 16 or 32 bits), returns the WINE internal structure.
|
||||
*/
|
||||
static LPWINE_DRIVER DRIVER_FindFromHDrvr(HDRVR hDrvr)
|
||||
{
|
||||
if (!IsBadWritePtr((void*)hDrvr, sizeof(DWORD)) &&
|
||||
((LPWINE_DRIVER)hDrvr)->dwMagic == WINE_DI_MAGIC) {
|
||||
return (LPWINE_DRIVER)hDrvr;
|
||||
}
|
||||
return DRIVER_FindFromHDrvr16(hDrvr);
|
||||
}
|
||||
|
||||
int DRIVER_GetType(HDRVR hDrvr)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = DRIVER_FindFromHDrvr(hDrvr);
|
||||
|
||||
return (lpDrv) ? (lpDrv->dwFlags & WINE_DI_TYPE_MASK) : 0;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_MapMsg16To32 [internal]
|
||||
*
|
||||
@ -103,7 +130,7 @@ static LPWINE_DRIVER DRIVER_FindFromHDrvr16(HDRVR16 hDrvr)
|
||||
int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
||||
switch (wMsg) {
|
||||
case DRV_LOAD:
|
||||
case DRV_ENABLE:
|
||||
@ -119,10 +146,27 @@ int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
break;
|
||||
case DRV_OPEN:
|
||||
case DRV_CLOSE:
|
||||
/* lParam1 is a NULL terminated string, lParam2 is unknown => may lead to some problem */
|
||||
/* lParam1 is a NULL terminated string */
|
||||
/* lParam2 is a pointer to an MCI_OPEN_DRIVER_PARMS for an MCI device */
|
||||
if (*lParam1)
|
||||
*lParam1 = (DWORD)PTR_SEG_TO_LIN(*lParam1);
|
||||
ret = 0;
|
||||
if (*lParam2 && wMsg == DRV_OPEN) {
|
||||
LPMCI_OPEN_DRIVER_PARMS16 modp16 = PTR_SEG_TO_LIN(*lParam2);
|
||||
char* ptr = HeapAlloc(SystemHeap, 0, sizeof(LPMCI_OPEN_DRIVER_PARMS16) + sizeof(MCI_OPEN_DRIVER_PARMSA));
|
||||
LPMCI_OPEN_DRIVER_PARMSA modp32;
|
||||
|
||||
if (ptr) {
|
||||
*(LPMCI_OPEN_DRIVER_PARMS16*)ptr = modp16;
|
||||
modp32 = (LPMCI_OPEN_DRIVER_PARMSA)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSA));
|
||||
|
||||
modp32->wDeviceID = modp16->wDeviceID;
|
||||
modp32->lpstrParams = PTR_SEG_TO_LIN(modp16->lpstrParams);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
*lParam2 = (DWORD)modp32;
|
||||
}
|
||||
ret = 1;
|
||||
break;
|
||||
case DRV_CONFIGURE:
|
||||
case DRV_INSTALL:
|
||||
@ -130,7 +174,7 @@ int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
if (*lParam2) {
|
||||
LPDRVCONFIGINFO dci32 = HeapAlloc(SystemHeap, 0, sizeof(DRVCONFIGINFO));
|
||||
LPDRVCONFIGINFO16 dci16 = PTR_SEG_TO_LIN(*lParam2);
|
||||
|
||||
|
||||
if (dci32) {
|
||||
dci32->dwDCISize = sizeof(DRVCONFIGINFO);
|
||||
dci32->lpszDCISectionName = HEAP_strdupAtoW(SystemHeap, 0, PTR_SEG_TO_LIN(dci16->lpszDCISectionName));
|
||||
@ -147,7 +191,15 @@ int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
if (wMsg >= 0x800 && wMsg < 0x900) {
|
||||
/* FIXME: another hack to handle MCI messages...
|
||||
* should find a *NICE* way to integrate DRIVER_ and
|
||||
* MCI_ mapping/unmapping functions
|
||||
*/
|
||||
ret = 0;
|
||||
} else {
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -163,7 +215,7 @@ int DRIVER_MapMsg16To32(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
int DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
||||
switch (wMsg) {
|
||||
case DRV_LOAD:
|
||||
case DRV_ENABLE:
|
||||
@ -177,7 +229,17 @@ int DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
/* lParam1 and lParam2 are not used */
|
||||
case DRV_OPEN:
|
||||
case DRV_CLOSE:
|
||||
/* lParam1 is a NULL terminated string, lParam2 is unknown => may lead to some problem */
|
||||
/* lParam1 is a NULL terminated string */
|
||||
/* lParam2 is a pointer to an MCI_OPEN_DRIVER_PARMS for an MCI device */
|
||||
if (lParam2 && wMsg == DRV_OPEN) {
|
||||
LPMCI_OPEN_DRIVER_PARMSA modp32 = (LPMCI_OPEN_DRIVER_PARMSA)lParam2;
|
||||
LPMCI_OPEN_DRIVER_PARMS16 modp16 = *(LPMCI_OPEN_DRIVER_PARMS16*)(lParam2 - sizeof(LPMCI_OPEN_DRIVER_PARMSA));
|
||||
|
||||
modp16->wCustomCommandTable = modp32->wCustomCommandTable;
|
||||
modp16->wType = modp32->wType;
|
||||
if (!HeapFree(SystemHeap, 0, modp32))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DRV_CONFIGURE:
|
||||
@ -185,14 +247,25 @@ int DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
/* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
|
||||
if (lParam2) {
|
||||
LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)lParam2;
|
||||
HeapFree(SystemHeap, 0, (LPVOID)dci32->lpszDCISectionName);
|
||||
HeapFree(SystemHeap, 0, (LPVOID)dci32->lpszDCIAliasName);
|
||||
HeapFree(SystemHeap, 0, dci32);
|
||||
if (!HeapFree(SystemHeap, 0, (LPVOID)dci32->lpszDCISectionName))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
if (!HeapFree(SystemHeap, 0, (LPVOID)dci32->lpszDCIAliasName))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
if (!HeapFree(SystemHeap, 0, dci32))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
if (wMsg >= 0x800 && wMsg < 0x900) {
|
||||
/* FIXME: another hack to handle MCI messages...
|
||||
* should find a *NICE* way to integrate DRIVER_ and
|
||||
* MCI_ mapping/unmapping functions
|
||||
*/
|
||||
ret = 0;
|
||||
} else {
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -209,7 +282,7 @@ int DRIVER_UnMapMsg16To32(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
||||
switch (wMsg) {
|
||||
case DRV_LOAD:
|
||||
case DRV_ENABLE:
|
||||
@ -225,7 +298,8 @@ int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
break;
|
||||
case DRV_OPEN:
|
||||
case DRV_CLOSE:
|
||||
/* lParam1 is a NULL terminated string, lParam2 is unknown => may lead to some problem */
|
||||
/* lParam1 is a NULL terminated string */
|
||||
/* lParam2 is a pointer to an MCI_OPEN_DRIVER_PARMS for an MCI device */
|
||||
if (*lParam1) {
|
||||
LPSTR str = SEGPTR_STRDUP((LPSTR)*lParam1);
|
||||
if (str) {
|
||||
@ -237,6 +311,23 @@ int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
} else {
|
||||
ret = 0;
|
||||
}
|
||||
if (*lParam2 && wMsg == DRV_OPEN) {
|
||||
LPMCI_OPEN_DRIVER_PARMS16 modp16;
|
||||
char* ptr = SEGPTR_ALLOC(sizeof(LPMCI_OPEN_DRIVER_PARMSA) + sizeof(MCI_OPEN_DRIVER_PARMS16));
|
||||
LPMCI_OPEN_DRIVER_PARMSA modp32 = (LPMCI_OPEN_DRIVER_PARMSA)(*lParam2);
|
||||
|
||||
if (ptr) {
|
||||
*(LPMCI_OPEN_DRIVER_PARMSA*)ptr = modp32;
|
||||
modp16 = (LPMCI_OPEN_DRIVER_PARMS16)(ptr + sizeof(LPMCI_OPEN_DRIVER_PARMSA));
|
||||
|
||||
modp16->wDeviceID = modp32->wDeviceID;
|
||||
modp16->lpstrParams = PTR_SEG_TO_LIN(modp32->lpstrParams);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
*lParam2 = (DWORD)SEGPTR_GET(modp16);
|
||||
ret = 1;
|
||||
}
|
||||
break;
|
||||
case DRV_CONFIGURE:
|
||||
case DRV_INSTALL:
|
||||
@ -244,23 +335,25 @@ int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
if (*lParam2) {
|
||||
LPDRVCONFIGINFO16 dci16 = (LPDRVCONFIGINFO16)SEGPTR_ALLOC(sizeof(DRVCONFIGINFO16));
|
||||
LPDRVCONFIGINFO dci32 = (LPDRVCONFIGINFO)lParam2;
|
||||
|
||||
|
||||
if (dci16) {
|
||||
LPSTR str1, str2;
|
||||
|
||||
|
||||
dci16->dwDCISize = sizeof(DRVCONFIGINFO16);
|
||||
|
||||
|
||||
if ((str1 = HEAP_strdupWtoA(SystemHeap, 0, dci32->lpszDCISectionName)) != NULL &&
|
||||
(str2 = SEGPTR_STRDUP(str1)) != NULL) {
|
||||
dci16->lpszDCISectionName = (LPSTR)SEGPTR_GET(str2);
|
||||
HeapFree(SystemHeap, 0, str1);
|
||||
if (!HeapFree(SystemHeap, 0, str1))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
if ((str1 = HEAP_strdupWtoA(SystemHeap, 0, dci32->lpszDCIAliasName)) != NULL &&
|
||||
(str2 = SEGPTR_STRDUP(str1)) != NULL) {
|
||||
dci16->lpszDCIAliasName = (LPSTR)SEGPTR_GET(str2);
|
||||
HeapFree(SystemHeap, 0, str1);
|
||||
if (!HeapFree(SystemHeap, 0, str1))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
} else {
|
||||
return -2;
|
||||
}
|
||||
@ -274,13 +367,21 @@ int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
}
|
||||
break;
|
||||
default:
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
if (wMsg >= 0x800 && wMsg < 0x900) {
|
||||
/* FIXME: another hack to handle MCI messages...
|
||||
* should find a *NICE* way to integrate DRIVER_ and
|
||||
* MCI_ mapping/unmapping functions
|
||||
*/
|
||||
ret = 0;
|
||||
} else {
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_MapMsg32To16 [internal]
|
||||
* DRIVER_UnMapMsg32To16 [internal]
|
||||
*
|
||||
* UnMap a 32 bit driver message to a 16 bit driver message.
|
||||
* 0 : ok
|
||||
@ -290,7 +391,7 @@ int DRIVER_MapMsg32To16(WORD wMsg, DWORD* lParam1, DWORD* lParam2)
|
||||
int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
|
||||
switch (wMsg) {
|
||||
case DRV_LOAD:
|
||||
case DRV_ENABLE:
|
||||
@ -305,7 +406,19 @@ int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
case DRV_OPEN:
|
||||
case DRV_CLOSE:
|
||||
/* lParam1 is a NULL terminated string, lParam2 is unknown => may lead to some problem */
|
||||
if (lParam1) SEGPTR_FREE(PTR_SEG_TO_LIN(lParam1));
|
||||
/* lParam2 is a pointer to an MCI_OPEN_DRIVER_PARMS for an MCI device */
|
||||
if (lParam1) if (!SEGPTR_FREE(PTR_SEG_TO_LIN(lParam1)))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
|
||||
if (lParam2 && wMsg == DRV_OPEN) {
|
||||
LPMCI_OPEN_DRIVER_PARMS16 modp16 = (LPMCI_OPEN_DRIVER_PARMS16)PTR_SEG_TO_LIN(lParam2);
|
||||
LPMCI_OPEN_DRIVER_PARMSA modp32 = *(LPMCI_OPEN_DRIVER_PARMSA*)((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA));
|
||||
|
||||
modp32->wCustomCommandTable = modp16->wCustomCommandTable;
|
||||
modp32->wType = modp16->wType;
|
||||
if (!SEGPTR_FREE((char*)modp16 - sizeof(LPMCI_OPEN_DRIVER_PARMSA)))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
case DRV_CONFIGURE:
|
||||
@ -313,15 +426,26 @@ int DRIVER_UnMapMsg32To16(WORD wMsg, DWORD lParam1, DWORD lParam2)
|
||||
/* lParam1 is a handle to a window (or not used), lParam2 is a pointer to DRVCONFIGINFO, lParam2 */
|
||||
if (lParam2) {
|
||||
LPDRVCONFIGINFO16 dci16 = (LPDRVCONFIGINFO16)PTR_SEG_TO_LIN(lParam2);
|
||||
|
||||
SEGPTR_FREE(PTR_SEG_TO_LIN(dci16->lpszDCISectionName));
|
||||
SEGPTR_FREE(PTR_SEG_TO_LIN(dci16->lpszDCIAliasName));
|
||||
SEGPTR_FREE(dci16);
|
||||
|
||||
if (!SEGPTR_FREE(PTR_SEG_TO_LIN(dci16->lpszDCISectionName)))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
if (!SEGPTR_FREE(PTR_SEG_TO_LIN(dci16->lpszDCIAliasName)))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
if (!SEGPTR_FREE(dci16))
|
||||
FIXME(driver, "bad free line=%d\n", __LINE__);
|
||||
}
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
if (wMsg >= 0x800 && wMsg < 0x900) {
|
||||
/* FIXME: another hack to handle MCI messages...
|
||||
* should find a *NICE* way to integrate DRIVER_ and
|
||||
* MCI_ mapping/unmapping functions
|
||||
*/
|
||||
ret = 0;
|
||||
} else {
|
||||
FIXME(driver, "Unknown message 0x%04x\n", wMsg);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -335,21 +459,25 @@ LRESULT WINAPI SendDriverMessage16(HDRVR16 hDriver, UINT16 msg, LPARAM lParam1,
|
||||
LPWINE_DRIVER lpDrv;
|
||||
LRESULT retval = 0;
|
||||
int mapRet;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
|
||||
|
||||
lpDrv = (LPWINE_DRIVER)DRIVER_FindFromHDrvr16(hDriver);
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr16(hDriver);
|
||||
if (lpDrv != NULL && lpDrv->hDriver16 == hDriver) {
|
||||
switch (lpDrv->dwFlags & WINE_DI_TYPE_MASK) {
|
||||
case WINE_DI_TYPE_16:
|
||||
TRACE(driver, "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 = Callbacks->CallDriverProc(lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID, hDriver,
|
||||
msg, lParam1, lParam2);
|
||||
break;
|
||||
case WINE_DI_TYPE_32:
|
||||
mapRet = DRIVER_MapMsg16To32(msg, &lParam1, &lParam2);
|
||||
if (mapRet >= 0) {
|
||||
retval = lpDrv->d.d32.lpDrvProc(lpDrv->dwDriverID, hDriver, msg, lParam1, lParam2);
|
||||
if (mapRet > 1) {
|
||||
TRACE(driver, "Before func32 call proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
lpDrv->d.d32.lpDrvProc, lpDrv->dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
retval = lpDrv->d.d32.lpDrvProc(lpDrv->dwDriverID, (HDRVR)lpDrv, msg, lParam1, lParam2);
|
||||
if (mapRet >= 1) {
|
||||
DRIVER_UnMapMsg16To32(msg, lParam1, lParam2);
|
||||
}
|
||||
} else {
|
||||
@ -360,8 +488,10 @@ LRESULT WINAPI SendDriverMessage16(HDRVR16 hDriver, UINT16 msg, LPARAM lParam1,
|
||||
FIXME(driver, "Unknown driver type %08lx\n", lpDrv->dwFlags);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
WARN(driver, "Bad driver handle %u\n", hDriver);
|
||||
}
|
||||
|
||||
|
||||
TRACE(driver, "retval = %ld\n", retval);
|
||||
return retval;
|
||||
}
|
||||
@ -370,22 +500,26 @@ LRESULT WINAPI SendDriverMessage16(HDRVR16 hDriver, UINT16 msg, LPARAM lParam1,
|
||||
* SendDriverMessage [WINMM.19]
|
||||
*/
|
||||
LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
|
||||
LPARAM lParam2)
|
||||
LPARAM lParam2)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = (LPWINE_DRIVER)hDriver;
|
||||
LPWINE_DRIVER lpDrv;
|
||||
LRESULT retval = 0;
|
||||
int mapRet;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x, %04X, %08lX, %08lX)\n", hDriver, msg, lParam1, lParam2);
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr(hDriver);
|
||||
|
||||
if (lpDrv != NULL) {
|
||||
switch (lpDrv->dwFlags & WINE_DI_TYPE_MASK) {
|
||||
case WINE_DI_TYPE_16:
|
||||
mapRet = DRIVER_MapMsg32To16(msg, &lParam1, &lParam2);
|
||||
if (mapRet >= 0) {
|
||||
retval = Callbacks->CallDriverProc(lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID, hDriver,
|
||||
TRACE(driver, "Before CallDriverProc proc=%p driverID=%08lx hDrv=%u wMsg=%04x p1=%08lx p2=%08lx\n",
|
||||
lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID, lpDrv->hDriver16, msg, lParam1, lParam2);
|
||||
retval = Callbacks->CallDriverProc(lpDrv->d.d16.lpDrvProc, lpDrv->dwDriverID, lpDrv->hDriver16,
|
||||
msg, lParam1, lParam2);
|
||||
if (mapRet > 1) {
|
||||
if (mapRet >= 1) {
|
||||
DRIVER_UnMapMsg32To16(msg, lParam1, lParam2);
|
||||
}
|
||||
} else {
|
||||
@ -393,26 +527,54 @@ LRESULT WINAPI SendDriverMessage(HDRVR hDriver, UINT msg, LPARAM lParam1,
|
||||
}
|
||||
break;
|
||||
case WINE_DI_TYPE_32:
|
||||
TRACE(driver, "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(driver, "Unknown driver type %08lx\n", lpDrv->dwFlags);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
WARN(driver, "Bad driver handle %u\n", hDriver);
|
||||
}
|
||||
TRACE(driver, "retval = %ld\n", retval);
|
||||
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_RemoveFromList [internal]
|
||||
*
|
||||
* Generates all the logic to handle driver closure / deletion
|
||||
* Removes a driver struct to the list of open drivers.
|
||||
*/
|
||||
static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv)
|
||||
{
|
||||
lpDrv->dwDriverID = 0;
|
||||
if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) {
|
||||
SendDriverMessage((HDRVR)lpDrv, DRV_DISABLE, 0L, 0L);
|
||||
SendDriverMessage((HDRVR)lpDrv, DRV_FREE, 0L, 0L);
|
||||
|
||||
if (lpDrv->lpPrevItem)
|
||||
lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
|
||||
else
|
||||
lpDrvItemList = lpDrv->lpNextItem;
|
||||
if (lpDrv->lpNextItem)
|
||||
lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_AddToList [internal]
|
||||
*
|
||||
* Adds a driver struct to the list of open drivers.
|
||||
* Generates all the logic to handle driver creation / open.
|
||||
*/
|
||||
static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam)
|
||||
static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam, BOOL bCallFrom32)
|
||||
{
|
||||
lpNewDrv->dwMagic = WINE_DI_MAGIC;
|
||||
/* First driver to be loaded for this module, need to load correctly the module */
|
||||
if (DRIVER_GetNumberOfModuleRefs(lpNewDrv) == 0) {
|
||||
if (SendDriverMessage((HDRVR)lpNewDrv, DRV_LOAD, 0L, 0L) != DRV_SUCCESS) {
|
||||
@ -424,18 +586,6 @@ static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/* Now just open a new instance of a driver on this module */
|
||||
/* Handle of this lParam is rather touchy :
|
||||
* + we know here if it comes from 16 or 32 bit from lpDrv->dwFlags
|
||||
* + but we don't know its content...
|
||||
* + and we send it through SendDriverMessage32 as a 32 bit value...
|
||||
* => so we might have trouble with this little guy (FIXME ???)
|
||||
*/
|
||||
lpNewDrv->dwDriverID = SendDriverMessage((HDRVR)lpNewDrv, DRV_OPEN, (DWORD)lpNewDrv->szAliasName, lParam);
|
||||
if (lpNewDrv->dwDriverID == 0) {
|
||||
TRACE(driver, "DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
lpNewDrv->lpNextItem = NULL;
|
||||
if (lpDrvItemList == NULL) {
|
||||
@ -445,42 +595,35 @@ static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam)
|
||||
LPWINE_DRIVER lpDrv = lpDrvItemList; /* find end of list */
|
||||
while (lpDrv->lpNextItem != NULL)
|
||||
lpDrv = lpDrv->lpNextItem;
|
||||
|
||||
|
||||
lpDrv->lpNextItem = lpNewDrv;
|
||||
lpNewDrv->lpPrevItem = lpDrv;
|
||||
}
|
||||
|
||||
/* Now just open a new instance of a driver on this module */
|
||||
if (bCallFrom32) {
|
||||
lpNewDrv->dwDriverID = SendDriverMessage((HDRVR)lpNewDrv, DRV_OPEN, 0L, lParam);
|
||||
} else {
|
||||
lpNewDrv->dwDriverID = SendDriverMessage16(lpNewDrv->hDriver16, DRV_OPEN, 0L, lParam);
|
||||
}
|
||||
if (lpNewDrv->dwDriverID == 0) {
|
||||
TRACE(driver, "DRV_OPEN failed on driver 0x%08lx\n", (DWORD)lpNewDrv);
|
||||
DRIVER_RemoveFromList(lpNewDrv);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_RemoveFromList [internal]
|
||||
* DRIVER_CreateDrvr16 [internal]
|
||||
*
|
||||
* Generates all the logic to handle driver closure / deletion
|
||||
* Removes a driver struct to the list of open drivers.
|
||||
* Creates unique ID for 16 bit drivers.
|
||||
*/
|
||||
static BOOL DRIVER_RemoveFromList(LPWINE_DRIVER lpDrv, LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
SendDriverMessage((HDRVR)lpDrv, DRV_CLOSE, lParam1, lParam2);
|
||||
|
||||
lpDrv->dwDriverID = 0;
|
||||
if (DRIVER_GetNumberOfModuleRefs(lpDrv) == 1) {
|
||||
SendDriverMessage16((HDRVR)lpDrv, DRV_DISABLE, 0L, 0L);
|
||||
SendDriverMessage16((HDRVR)lpDrv, DRV_FREE, 0L, 0L);
|
||||
|
||||
if (lpDrv->lpPrevItem)
|
||||
lpDrv->lpPrevItem->lpNextItem = lpDrv->lpNextItem;
|
||||
else
|
||||
lpDrvItemList = lpDrv->lpNextItem;
|
||||
if (lpDrv->lpNextItem)
|
||||
lpDrv->lpNextItem->lpPrevItem = lpDrv->lpPrevItem;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static HDRVR16 DRIVER_CreateDrvr16()
|
||||
{
|
||||
static WORD DRIVER_hDrvr16Counter = 0;
|
||||
|
||||
|
||||
while (DRIVER_FindFromHDrvr16(++DRIVER_hDrvr16Counter));
|
||||
return DRIVER_hDrvr16Counter;
|
||||
}
|
||||
@ -491,10 +634,11 @@ static HDRVR16 DRIVER_CreateDrvr16()
|
||||
* Creates all the WINE internal representations for a 16 bit driver.
|
||||
* The driver is also open by sending the correct messages.
|
||||
*/
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR lpName, HMODULE16 hModule, DRIVERPROC16 lpProc, LPARAM lParam)
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR lpName, HMODULE16 hModule, DRIVERPROC16 lpProc,
|
||||
LPARAM lParam, BOOL bCallFrom32)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
|
||||
lpDrv = HeapAlloc(SystemHeap, 0, sizeof(WINE_DRIVER));
|
||||
if (lpDrv != NULL) {
|
||||
lpDrv->dwFlags = WINE_DI_TYPE_16;
|
||||
@ -504,7 +648,7 @@ LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR lpName, HMODULE16 hModule, DRIVERPR
|
||||
lpDrv->d.d16.hModule = hModule;
|
||||
lpDrv->d.d16.lpDrvProc = lpProc;
|
||||
|
||||
if (!DRIVER_AddToList(lpDrv, lParam)) {
|
||||
if (!DRIVER_AddToList(lpDrv, lParam, bCallFrom32)) {
|
||||
HeapFree(SystemHeap, 0, lpDrv);
|
||||
lpDrv = NULL;
|
||||
}
|
||||
@ -518,10 +662,11 @@ LPWINE_DRIVER DRIVER_RegisterDriver16(LPCSTR lpName, HMODULE16 hModule, DRIVERPR
|
||||
* Creates all the WINE internal representations for a 32 bit driver.
|
||||
* The driver is also open by sending the correct messages.
|
||||
*/
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR lpName, HMODULE hModule, DRIVERPROC lpProc, LPARAM lParam)
|
||||
LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR lpName, HMODULE hModule, DRIVERPROC lpProc,
|
||||
LPARAM lParam, BOOL bCallFrom32)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
|
||||
lpDrv = HeapAlloc(SystemHeap, 0, sizeof(WINE_DRIVER));
|
||||
if (lpDrv != NULL) {
|
||||
lpDrv->dwFlags = WINE_DI_TYPE_32;
|
||||
@ -531,7 +676,7 @@ LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR lpName, HMODULE hModule, DRIVERPROC
|
||||
lpDrv->d.d32.hModule = hModule;
|
||||
lpDrv->d.d32.lpDrvProc = lpProc;
|
||||
|
||||
if (!DRIVER_AddToList(lpDrv, lParam)) {
|
||||
if (!DRIVER_AddToList(lpDrv, lParam, bCallFrom32)) {
|
||||
HeapFree(SystemHeap, 0, lpDrv);
|
||||
lpDrv = NULL;
|
||||
}
|
||||
@ -540,33 +685,33 @@ LPWINE_DRIVER DRIVER_RegisterDriver32(LPCSTR lpName, HMODULE hModule, DRIVERPROC
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* DRIVER_TryOpenDriver32 [internal]
|
||||
* DRIVER_TryOpenDriver16 [internal]
|
||||
*
|
||||
* Tries to load a 16 bit driver whose DLL's (module) name is lpFileName.
|
||||
*/
|
||||
static HDRVR16 DRIVER_TryOpenDriver16(LPCSTR lpFileName, LPARAM lParam)
|
||||
static HDRVR16 DRIVER_TryOpenDriver16(LPCSTR lpFileName, LPARAM lParam, BOOL bCallFrom32)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = NULL;
|
||||
LPCSTR lpSFN;
|
||||
HMODULE16 hModule;
|
||||
DRIVERPROC16 lpProc;
|
||||
|
||||
|
||||
TRACE(driver,"('%s', %08lX);\n", lpFileName, lParam);
|
||||
|
||||
|
||||
if (lstrlenA(lpFileName) < 1)
|
||||
return 0;
|
||||
|
||||
|
||||
lpSFN = strrchr(lpFileName, '\\');
|
||||
lpSFN = (lpSFN) ? (lpSFN + 1) : lpFileName;
|
||||
|
||||
|
||||
if ((hModule = LoadModule16(lpFileName, (LPVOID)-1)) != 0) {
|
||||
if ((lpProc = (DRIVERPROC16)WIN32_GetProcAddress16(hModule, "DRIVERPROC")) != NULL) {
|
||||
lpDrv = DRIVER_RegisterDriver16(lpSFN, hModule, lpProc, lParam);
|
||||
lpDrv = DRIVER_RegisterDriver16(lpSFN, hModule, lpProc, lParam, bCallFrom32);
|
||||
} else {
|
||||
TRACE(driver, "No DriverProc found\n");
|
||||
}
|
||||
} else {
|
||||
TRACE(driver, "Unable to load module (%s)\n", lpFileName);
|
||||
TRACE(driver, "Unable to load 16 bit module (%s)\n", lpFileName);
|
||||
}
|
||||
return lpDrv ? lpDrv->hDriver16 : 0;
|
||||
}
|
||||
@ -576,30 +721,31 @@ static HDRVR16 DRIVER_TryOpenDriver16(LPCSTR lpFileName, LPARAM lParam)
|
||||
*
|
||||
* Tries to load a 32 bit driver whose DLL's (module) name is lpFileName.
|
||||
*/
|
||||
static HDRVR DRIVER_TryOpenDriver32(LPCSTR lpFileName, LPARAM lParam)
|
||||
static HDRVR DRIVER_TryOpenDriver32(LPCSTR lpFileName, LPARAM lParam, BOOL bCallFrom32)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = NULL;
|
||||
LPCSTR lpSFN;
|
||||
HMODULE hModule;
|
||||
DRIVERPROC lpProc;
|
||||
|
||||
DRIVERPROC lpProc;
|
||||
|
||||
TRACE(driver,"('%s', %08lX);\n", lpFileName, lParam);
|
||||
|
||||
|
||||
if (lstrlenA(lpFileName) < 1)
|
||||
return 0;
|
||||
|
||||
|
||||
lpSFN = strrchr(lpFileName, '\\');
|
||||
lpSFN = (lpSFN) ? (lpSFN + 1) : lpFileName;
|
||||
|
||||
|
||||
if ((hModule = LoadLibraryA(lpFileName)) != 0) {
|
||||
if ((lpProc = GetProcAddress(hModule, "DriverProc")) != NULL) {
|
||||
lpDrv = DRIVER_RegisterDriver32(lpSFN, hModule, lpProc, lParam);
|
||||
lpDrv = DRIVER_RegisterDriver32(lpSFN, hModule, lpProc, lParam, bCallFrom32);
|
||||
} else {
|
||||
TRACE(driver, "No DriverProc found\n");
|
||||
}
|
||||
} else {
|
||||
TRACE(driver, "Unable to load module (%s)\n", lpFileName);
|
||||
TRACE(driver, "Unable to load 32 bit module \"%s\"\n", lpFileName);
|
||||
}
|
||||
TRACE(driver, "=> %p\n", lpDrv);
|
||||
return (HDRVR)lpDrv;
|
||||
}
|
||||
|
||||
@ -610,19 +756,19 @@ HDRVR16 WINAPI OpenDriver16(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lP
|
||||
{
|
||||
HDRVR16 hDriver = 0;
|
||||
char drvName[128];
|
||||
|
||||
|
||||
TRACE(driver,"('%s', '%s', %08lX);\n", lpDriverName, lpSectionName, lParam);
|
||||
|
||||
|
||||
if (lpSectionName == NULL) {
|
||||
hDriver = DRIVER_TryOpenDriver16(lpDriverName, lParam);
|
||||
hDriver = DRIVER_TryOpenDriver16(lpDriverName, lParam, FALSE);
|
||||
if (!hDriver) {
|
||||
/* in case hDriver is NULL, search in Drivers32 section */
|
||||
lpSectionName = "Drivers";
|
||||
}
|
||||
}
|
||||
if (!hDriver && GetPrivateProfileStringA(lpSectionName, lpDriverName, "",
|
||||
drvName, sizeof(drvName), "SYSTEM.INI") > 0) {
|
||||
hDriver = DRIVER_TryOpenDriver16(drvName, lParam);
|
||||
drvName, sizeof(drvName), "SYSTEM.INI") > 0) {
|
||||
hDriver = DRIVER_TryOpenDriver16(drvName, lParam, FALSE);
|
||||
}
|
||||
return hDriver;
|
||||
}
|
||||
@ -639,35 +785,36 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
|
||||
char drvName[128];
|
||||
|
||||
TRACE(driver,"('%s', '%s', %08lX);\n", lpDriverName, lpSectionName, lParam);
|
||||
|
||||
|
||||
if (lpSectionName == NULL) {
|
||||
strncpy(drvName, lpDriverName, sizeof(drvName));
|
||||
hDriver = DRIVER_TryOpenDriver32(lpDriverName, lParam);
|
||||
hDriver = DRIVER_TryOpenDriver32(lpDriverName, lParam, TRUE);
|
||||
if (!hDriver) {
|
||||
/* FIXME what has to be done on lParam ?? */
|
||||
hDriver = DRIVER_TryOpenDriver16(lpDriverName, lParam);
|
||||
hDriver = DRIVER_TryOpenDriver16(lpDriverName, lParam, TRUE);
|
||||
}
|
||||
if (!hDriver) {
|
||||
if (GetPrivateProfileStringA("Drivers32", lpDriverName, "", drvName,
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver32(drvName, lParam);
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver32(drvName, lParam, TRUE);
|
||||
|
||||
}
|
||||
}
|
||||
if (!hDriver) {
|
||||
if (GetPrivateProfileStringA("Drivers", lpDriverName, "", drvName,
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver16(drvName, lParam);
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver16(drvName, lParam, TRUE);
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (GetPrivateProfileStringA(lpSectionName, lpDriverName, "", drvName,
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver32(drvName, lParam);
|
||||
sizeof(drvName), "SYSTEM.INI")) {
|
||||
hDriver = DRIVER_TryOpenDriver32(drvName, lParam, TRUE);
|
||||
if (!hDriver) {
|
||||
hDriver = DRIVER_TryOpenDriver16(drvName, lParam, TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(driver, "retval='%08x'\n", hDriver);
|
||||
return hDriver;
|
||||
}
|
||||
@ -677,10 +824,10 @@ HDRVR WINAPI OpenDriverA(LPCSTR lpDriverName, LPCSTR lpSectionName, LPARAM lPara
|
||||
*/
|
||||
HDRVR WINAPI OpenDriverW(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lParam)
|
||||
{
|
||||
LPSTR dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName);
|
||||
LPSTR sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName);
|
||||
HDRVR ret = OpenDriverA(dn, sn, lParam);
|
||||
|
||||
LPSTR dn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpDriverName);
|
||||
LPSTR sn = HEAP_strdupWtoA(GetProcessHeap(), 0, lpSectionName);
|
||||
HDRVR ret = OpenDriverA(dn, sn, lParam);
|
||||
|
||||
if (dn) HeapFree(GetProcessHeap(), 0, dn);
|
||||
if (sn) HeapFree(GetProcessHeap(), 0, sn);
|
||||
return ret;
|
||||
@ -691,31 +838,36 @@ HDRVR WINAPI OpenDriverW(LPCWSTR lpDriverName, LPCWSTR lpSectionName, LPARAM lPa
|
||||
*/
|
||||
LRESULT WINAPI CloseDriver16(HDRVR16 hDrvr, LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
TRACE(driver, "(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
|
||||
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr16(hDrvr);
|
||||
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr) {
|
||||
if (DRIVER_RemoveFromList(lpDrv, lParam1, lParam2)) {
|
||||
if (lpDrv != NULL) {
|
||||
SendDriverMessage((HDRVR)lpDrv, DRV_CLOSE, lParam1, lParam2);
|
||||
|
||||
if (DRIVER_RemoveFromList(lpDrv)) {
|
||||
TRACE(driver, "hDrvr=%04x closed !\n", hDrvr);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* CloseDriver32 [WINMM.4]
|
||||
*/
|
||||
LRESULT WINAPI CloseDriver(HDRVR hDrvr, LPARAM lParam1, LPARAM lParam2)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
TRACE(driver, "(%04x, %08lX, %08lX);\n", hDrvr, lParam1, lParam2);
|
||||
|
||||
lpDrv = (LPWINE_DRIVER)hDrvr;
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr(hDrvr);
|
||||
if (lpDrv != NULL) {
|
||||
if (DRIVER_RemoveFromList(lpDrv, lParam1, lParam2)) {
|
||||
SendDriverMessage((HDRVR)lpDrv, DRV_CLOSE, lParam1, lParam2);
|
||||
|
||||
if (DRIVER_RemoveFromList(lpDrv)) {
|
||||
TRACE(driver, "hDrvr=%08x closed !\n", hDrvr);
|
||||
return TRUE;
|
||||
}
|
||||
@ -730,9 +882,9 @@ HMODULE16 WINAPI GetDriverModuleHandle16(HDRVR16 hDrvr)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
HMODULE16 hModule = 0;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x);\n", hDrvr);
|
||||
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr16(hDrvr);
|
||||
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr &&
|
||||
(lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_16) {
|
||||
@ -746,11 +898,12 @@ HMODULE16 WINAPI GetDriverModuleHandle16(HDRVR16 hDrvr)
|
||||
*/
|
||||
HMODULE WINAPI GetDriverModuleHandle(HDRVR hDrvr)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv = (LPWINE_DRIVER)hDrvr;
|
||||
LPWINE_DRIVER lpDrv;
|
||||
HMODULE hModule = 0;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x);\n", hDrvr);
|
||||
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr(hDrvr);
|
||||
if (lpDrv != NULL && (lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_32) {
|
||||
hModule = lpDrv->d.d32.hModule;
|
||||
}
|
||||
@ -785,12 +938,12 @@ BOOL16 WINAPI GetDriverInfo16(HDRVR16 hDrvr, LPDRIVERINFOSTRUCT16 lpDrvInfo)
|
||||
{
|
||||
LPWINE_DRIVER lpDrv;
|
||||
BOOL16 ret = FALSE;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x, %p);\n", hDrvr, lpDrvInfo);
|
||||
|
||||
|
||||
if (lpDrvInfo == NULL ||
|
||||
lpDrvInfo->length != sizeof(DRIVERINFOSTRUCT16)) return FALSE;
|
||||
|
||||
|
||||
lpDrv = DRIVER_FindFromHDrvr16(hDrvr);
|
||||
if (lpDrv != NULL && lpDrv->hDriver16 == hDrvr &&
|
||||
(lpDrv->dwFlags & WINE_DI_TYPE_MASK) == WINE_DI_TYPE_16) {
|
||||
@ -799,7 +952,7 @@ BOOL16 WINAPI GetDriverInfo16(HDRVR16 hDrvr, LPDRIVERINFOSTRUCT16 lpDrvInfo)
|
||||
strncpy(lpDrvInfo->szAliasName, lpDrv->szAliasName, sizeof(lpDrvInfo->szAliasName));
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -810,9 +963,9 @@ HDRVR16 WINAPI GetNextDriver16(HDRVR16 hDrvr, DWORD dwFlags)
|
||||
{
|
||||
HDRVR16 hRetDrv = 0;
|
||||
LPWINE_DRIVER lpDrv;
|
||||
|
||||
|
||||
TRACE(driver, "(%04x, %08lX);\n", hDrvr, dwFlags);
|
||||
|
||||
|
||||
if (hDrvr == 0) {
|
||||
if (lpDrvItemList == NULL) {
|
||||
FIXME(driver, "drivers list empty !\n");
|
||||
@ -836,7 +989,7 @@ HDRVR16 WINAPI GetNextDriver16(HDRVR16 hDrvr, DWORD dwFlags)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hRetDrv = (lpDrv) ? lpDrv->hDriver16 : (HDRVR16)0;
|
||||
TRACE(driver, "return %04x !\n", hRetDrv);
|
||||
return hRetDrv;
|
||||
|
Loading…
Reference in New Issue
Block a user