Commit 72f7170e authored by Alex Villacís Lasso's avatar Alex Villacís Lasso Committed by Alexandre Julliard

MSACM: acmDriverAddW skeleton, implementation of ACM_DRIVERADDF_NAME.

- Rework acmDriverAddA to call acmDriverAddW. - Implement stub for acmDriverAddW with switch for the 3 known cases of driver add. - Implementation for case ACM_DRIVERADDF_NAME, which loads driver name & alias from registry (similar to msacm32 load).
parent cb37c43d
...@@ -49,6 +49,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msacm); ...@@ -49,6 +49,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(msacm);
MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule, MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd) LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
{ {
MMRESULT resultW;
WCHAR * driverW = NULL;
LPARAM lParamW = lParam;
TRACE("(%p, %p, %08lx, %08lx, %08lx)\n", TRACE("(%p, %p, %08lx, %08lx, %08lx)\n",
phadid, hinstModule, lParam, dwPriority, fdwAdd); phadid, hinstModule, lParam, dwPriority, fdwAdd);
...@@ -72,30 +76,95 @@ MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule, ...@@ -72,30 +76,95 @@ MMRESULT WINAPI acmDriverAddA(PHACMDRIVERID phadid, HINSTANCE hinstModule,
return MMSYSERR_INVALFLAG; return MMSYSERR_INVALFLAG;
} }
/* FIXME: in fact, should GetModuleFileName(hinstModule) and do a /* A->W translation of name */
* LoadDriver on it, to be sure we can call SendDriverMessage on the if ((fdwAdd & ACM_DRIVERADDF_TYPEMASK) == ACM_DRIVERADDF_NAME) {
* hDrvr handle. unsigned long len;
*/
*phadid = (HACMDRIVERID) MSACM_RegisterDriver(NULL, NULL, hinstModule); if (lParam == 0) return MMSYSERR_INVALPARAM;
len = MultiByteToWideChar(CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0);
/* FIXME: lParam, dwPriority and fdwAdd ignored */ driverW = HeapAlloc(MSACM_hHeap, 0, len * sizeof(WCHAR));
if (!driverW) return MMSYSERR_NOMEM;
MultiByteToWideChar(CP_ACP, 0, (LPSTR)lParam, -1, driverW, len);
lParamW = (LPARAM)driverW;
}
return MMSYSERR_NOERROR; resultW = acmDriverAddW(phadid, hinstModule, lParamW, dwPriority, fdwAdd);
HeapFree(MSACM_hHeap, 0, driverW);
return resultW;
} }
/*********************************************************************** /***********************************************************************
* acmDriverAddW (MSACM32.@) * acmDriverAddW (MSACM32.@)
* FIXME *
* Not implemented
*/ */
MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule, MMRESULT WINAPI acmDriverAddW(PHACMDRIVERID phadid, HINSTANCE hinstModule,
LPARAM lParam, DWORD dwPriority, DWORD fdwAdd) LPARAM lParam, DWORD dwPriority, DWORD fdwAdd)
{ {
FIXME("(%p, %p, %ld, %ld, %ld): stub\n", TRACE("(%p, %p, %08lx, %08lx, %08lx)\n",
phadid, hinstModule, lParam, dwPriority, fdwAdd); phadid, hinstModule, lParam, dwPriority, fdwAdd);
if (!phadid) {
WARN("invalid parameter\n");
return MMSYSERR_INVALPARAM;
}
/* Check if any unknown flags */
if (fdwAdd &
~(ACM_DRIVERADDF_FUNCTION|ACM_DRIVERADDF_NOTIFYHWND|
ACM_DRIVERADDF_GLOBAL)) {
WARN("invalid flag\n");
return MMSYSERR_INVALFLAG;
}
/* Check if any incompatible flags */
if ((fdwAdd & ACM_DRIVERADDF_FUNCTION) &&
(fdwAdd & ACM_DRIVERADDF_NOTIFYHWND)) {
WARN("invalid flag\n");
return MMSYSERR_INVALFLAG;
}
switch (fdwAdd & ACM_DRIVERADDF_TYPEMASK) {
case ACM_DRIVERADDF_NAME:
/*
hInstModule (unused)
lParam name of value in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
dwPriority (unused, set to 0)
*/
*phadid = (HACMDRIVERID) MSACM_RegisterDriverFromRegistry((LPCWSTR)lParam);
if (!*phadid) {
ERR("Unable to register driver via ACM_DRIVERADDF_NAME\n");
return MMSYSERR_INVALPARAM;
}
break;
case ACM_DRIVERADDF_FUNCTION:
/*
hInstModule Handle of module which contains driver entry proc
lParam Driver function address
dwPriority (unused, set to 0)
*/
fdwAdd &= ~ACM_DRIVERADDF_TYPEMASK;
*phadid = 0;
FIXME("(%p, %p, %ld, %ld, %ld): ACM_DRIVERADDF_FUNCTION: stub\n", phadid, hinstModule, lParam, dwPriority, fdwAdd);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return MMSYSERR_ERROR;
case ACM_DRIVERADDF_NOTIFYHWND:
/*
hInstModule (unused)
lParam Handle of notification window
dwPriority Window message to send for notification broadcasts
*/
*phadid = 0;
FIXME("(%p, %p, %ld, %ld, %ld): ACM_DRIVERADDF_NOTIFYHWND: stub\n", phadid, hinstModule, lParam, dwPriority, fdwAdd);
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return MMSYSERR_ERROR;
default:
ERR("invalid flag value 0x%08lx for fdwAdd\n", fdwAdd & ACM_DRIVERADDF_TYPEMASK);
return MMSYSERR_INVALFLAG;
}
SetLastError(ERROR_CALL_NOT_IMPLEMENTED); MSACM_BroadcastNotification();
return MMSYSERR_ERROR; return MMSYSERR_NOERROR;
} }
/*********************************************************************** /***********************************************************************
......
...@@ -51,6 +51,43 @@ static BOOL MSACM_pendingBroadcast = FALSE; ...@@ -51,6 +51,43 @@ static BOOL MSACM_pendingBroadcast = FALSE;
static void MSACM_ReorderDriversByPriority(void); static void MSACM_ReorderDriversByPriority(void);
/***********************************************************************
* MSACM_RegisterDriverFromRegistry()
*/
PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry)
{
static const WCHAR msacmW[] = {'M','S','A','C','M','.'};
static const WCHAR drvkey[] = {'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\',
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
'D','r','i','v','e','r','s','3','2','\0'};
WCHAR buf[2048];
DWORD bufLen, lRet;
HKEY hKey;
PWINE_ACMDRIVERID padid = NULL;
/* The requested registry entry must have the format msacm.XXXXX in order to
be recognized in any future sessions of msacm
*/
if (0 == strncmpiW(buf, msacmW, sizeof(msacmW)/sizeof(WCHAR))) {
lRet = RegOpenKeyExW(HKEY_LOCAL_MACHINE, drvkey, 0, KEY_QUERY_VALUE, &hKey);
if (lRet != ERROR_SUCCESS) {
WARN("unable to open registry key - 0x%08lx\n", lRet);
} else {
bufLen = sizeof(buf);
lRet = RegQueryValueExW(hKey, pszRegEntry, NULL, NULL, (LPBYTE)buf, &bufLen);
if (lRet != ERROR_SUCCESS) {
WARN("unable to query requested subkey %s - 0x%08lx\n", debugstr_w(pszRegEntry), lRet);
} else {
MSACM_RegisterDriver(pszRegEntry, buf, 0);
}
RegCloseKey( hKey );
}
}
return padid;
}
#if 0 #if 0
/*********************************************************************** /***********************************************************************
* MSACM_DumpCache * MSACM_DumpCache
......
...@@ -354,6 +354,8 @@ extern void MSACM_BroadcastNotification(void); ...@@ -354,6 +354,8 @@ extern void MSACM_BroadcastNotification(void);
extern void MSACM_DisableNotifications(void); extern void MSACM_DisableNotifications(void);
extern void MSACM_EnableNotifications(void); extern void MSACM_EnableNotifications(void);
extern PWINE_ACMDRIVERID MSACM_RegisterDriverFromRegistry(LPCWSTR pszRegEntry);
/* From msacm32.c */ /* From msacm32.c */
extern HINSTANCE MSACM_hInstance32; extern HINSTANCE MSACM_hInstance32;
......
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