Commit 0415030f authored by Dimitrie O. Paun's avatar Dimitrie O. Paun Committed by Alexandre Julliard

Lookup driver information in registry and system.ini.

Make the code inspect the registry/system.ini at call time, rather then initialization time. Code cleanups.
parent 225cd594
...@@ -29,12 +29,15 @@ ...@@ -29,12 +29,15 @@
#include "wingdi.h" #include "wingdi.h"
#include "winuser.h" #include "winuser.h"
#include "winnls.h" #include "winnls.h"
#include "winreg.h"
#include "mmddk.h" #include "mmddk.h"
#include "winemm.h" #include "winemm.h"
#include "wine/debug.h" #include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(driver); WINE_DEFAULT_DEBUG_CHANNEL(driver);
#define HKLM_BASE "Software\\Microsoft\\Windows NT\\CurrentVersion"
static LPWINE_DRIVER lpDrvItemList /* = NULL */; static LPWINE_DRIVER lpDrvItemList /* = NULL */;
WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */; WINE_MMTHREAD* (*pFnGetMMThread16)(UINT16 h) /* = NULL */;
...@@ -206,7 +209,21 @@ static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lPar ...@@ -206,7 +209,21 @@ static BOOL DRIVER_AddToList(LPWINE_DRIVER lpNewDrv, LPARAM lParam1, LPARAM lPar
*/ */
BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz) BOOL DRIVER_GetLibName(LPCSTR keyName, LPCSTR sectName, LPSTR buf, int sz)
{ {
/* should also do some registry diving */ HKEY hKey, hSecKey;
DWORD bufLen, lRet;
lRet = RegOpenKeyExA(HKEY_LOCAL_MACHINE, HKLM_BASE, 0, KEY_QUERY_VALUE, &hKey);
if (lRet == ERROR_SUCCESS) {
lRet = RegOpenKeyExA(hKey, sectName, 0, KEY_QUERY_VALUE, &hSecKey);
if (lRet == ERROR_SUCCESS) {
lRet = RegQueryValueExA(hSecKey, keyName, 0, 0, buf, &bufLen);
RegCloseKey( hSecKey );
}
RegCloseKey( hKey );
}
if (lRet == ERROR_SUCCESS) return TRUE;
/* default to system.ini if we can't find it in the registry,
* to support native installations where system.ini is still used */
return GetPrivateProfileStringA(sectName, keyName, "", buf, sz, "SYSTEM.INI"); return GetPrivateProfileStringA(sectName, keyName, "", buf, sz, "SYSTEM.INI");
} }
......
...@@ -57,9 +57,6 @@ ...@@ -57,9 +57,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(mci); WINE_DEFAULT_DEBUG_CHANNEL(mci);
static int MCI_InstalledCount;
static LPSTR MCI_lpInstallNames /* = NULL */;
WINMM_MapType (*pFnMciMapMsg16To32A) (WORD,WORD,DWORD*) /* = NULL */; WINMM_MapType (*pFnMciMapMsg16To32A) (WORD,WORD,DWORD*) /* = NULL */;
WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD) /* = NULL */; WINMM_MapType (*pFnMciUnMapMsg16To32A)(WORD,WORD,DWORD) /* = NULL */;
WINMM_MapType (*pFnMciMapMsg32ATo16) (WORD,WORD,DWORD,DWORD*) /* = NULL */; WINMM_MapType (*pFnMciMapMsg32ATo16) (WORD,WORD,DWORD,DWORD*) /* = NULL */;
...@@ -68,6 +65,9 @@ WINMM_MapType (*pFnMciUnMapMsg32ATo16)(WORD,WORD,DWORD,DWORD) /* = NULL */; ...@@ -68,6 +65,9 @@ WINMM_MapType (*pFnMciUnMapMsg32ATo16)(WORD,WORD,DWORD,DWORD) /* = NULL */;
/* First MCI valid device ID (0 means error) */ /* First MCI valid device ID (0 means error) */
#define MCI_MAGIC 0x0001 #define MCI_MAGIC 0x0001
/* MCI settings */
#define HKLM_MCI "Software\\Microsoft\\Windows NT\\CurrentVersion\\MCI"
/* dup a string and uppercase it */ /* dup a string and uppercase it */
inline static LPSTR str_dup_upper( LPCSTR str ) inline static LPSTR str_dup_upper( LPCSTR str )
{ {
...@@ -1435,8 +1435,10 @@ DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr) ...@@ -1435,8 +1435,10 @@ DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr)
*/ */
static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParms) static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParms)
{ {
DWORD ret = MCIERR_INVALID_DEVICE_ID; DWORD ret = MCIERR_INVALID_DEVICE_ID, cnt = 0;
CHAR buf[2048], *s = buf, *p;
LPWINE_MCIDRIVER wmd; LPWINE_MCIDRIVER wmd;
HKEY hKey;
if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK; if (lpParms == NULL) return MCIERR_NULL_PARAMETER_BLOCK;
...@@ -1445,11 +1447,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm ...@@ -1445,11 +1447,7 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
switch (dwFlags & ~MCI_SYSINFO_OPEN) { switch (dwFlags & ~MCI_SYSINFO_OPEN) {
case MCI_SYSINFO_QUANTITY: case MCI_SYSINFO_QUANTITY:
{ if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST || lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
DWORD cnt = 0;
if (lpParms->wDeviceType < MCI_DEVTYPE_FIRST ||
lpParms->wDeviceType > MCI_DEVTYPE_LAST) {
if (dwFlags & MCI_SYSINFO_OPEN) { if (dwFlags & MCI_SYSINFO_OPEN) {
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n"); TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers\n");
EnterCriticalSection(&WINMM_IData->cs); EnterCriticalSection(&WINMM_IData->cs);
...@@ -1459,27 +1457,29 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm ...@@ -1459,27 +1457,29 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
LeaveCriticalSection(&WINMM_IData->cs); LeaveCriticalSection(&WINMM_IData->cs);
} else { } else {
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n"); TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers\n");
cnt = MCI_InstalledCount; if (RegOpenKeyExA( HKEY_LOCAL_MACHINE, HKLM_MCI,
0, KEY_QUERY_VALUE, &hKey ) == ERROR_SUCCESS) {
RegQueryInfoKeyA( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
RegCloseKey( hKey );
}
if (GetPrivateProfileStringA("mci", 0, "", buf, sizeof(buf), "system.ini"))
for(s = buf; *s; s += strlen(s) + 1) cnt++;
} }
} else { } else {
if (dwFlags & MCI_SYSINFO_OPEN) { if (dwFlags & MCI_SYSINFO_OPEN) {
TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", TRACE("MCI_SYSINFO_QUANTITY: # of open MCI drivers of type %u\n", lpParms->wDeviceType);
lpParms->wDeviceType);
EnterCriticalSection(&WINMM_IData->cs); EnterCriticalSection(&WINMM_IData->cs);
for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) { for (wmd = WINMM_IData->lpMciDrvs; wmd; wmd = wmd->lpNext) {
if (wmd->wType == lpParms->wDeviceType) if (wmd->wType == lpParms->wDeviceType) cnt++;
cnt++;
} }
LeaveCriticalSection(&WINMM_IData->cs); LeaveCriticalSection(&WINMM_IData->cs);
} else { } else {
TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", TRACE("MCI_SYSINFO_QUANTITY: # of installed MCI drivers of type %u\n", lpParms->wDeviceType);
lpParms->wDeviceType);
FIXME("Don't know how to get # of MCI devices of a given type\n"); FIXME("Don't know how to get # of MCI devices of a given type\n");
cnt = 1; cnt = 1;
} }
} }
*(DWORD*)lpParms->lpstrReturn = cnt; *(DWORD*)lpParms->lpstrReturn = cnt;
}
TRACE("(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn); TRACE("(%ld) => '%ld'\n", lpParms->dwNumber, *(DWORD*)lpParms->lpstrReturn);
ret = MCI_INTEGER_RETURNED; ret = MCI_INTEGER_RETURNED;
break; break;
...@@ -1499,14 +1499,30 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm ...@@ -1499,14 +1499,30 @@ static DWORD MCI_SysInfo(UINT uDevID, DWORD dwFlags, LPMCI_SYSINFO_PARMSA lpParm
if (dwFlags & MCI_SYSINFO_OPEN) { if (dwFlags & MCI_SYSINFO_OPEN) {
FIXME("Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n"); FIXME("Don't handle MCI_SYSINFO_NAME|MCI_SYSINFO_OPEN (yet)\n");
ret = MCIERR_UNRECOGNIZED_COMMAND; ret = MCIERR_UNRECOGNIZED_COMMAND;
} else if (lpParms->dwNumber > MCI_InstalledCount) {
ret = MCIERR_OUTOFRANGE;
} else { } else {
DWORD count = lpParms->dwNumber; DWORD lRet;
LPSTR ptr = MCI_lpInstallNames; s = 0;
lRet = RegOpenKeyExA( HKEY_LOCAL_MACHINE, HKLM_MCI, 0, KEY_QUERY_VALUE, &hKey );
while (--count > 0) ptr += strlen(ptr) + 1; if (lRet == ERROR_SUCCESS) {
ret = MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, ptr); lRet = RegQueryInfoKeyA( hKey, 0, 0, 0, &cnt, 0, 0, 0, 0, 0, 0, 0);
if (lRet == ERROR_SUCCESS && lpParms->dwNumber <= cnt) {
DWORD bufLen = sizeof(buf);
lRet = RegEnumKeyExA(hKey, lpParms->dwNumber - 1, buf, &bufLen, 0, 0, 0, 0);
if (lRet == ERROR_SUCCESS) s = buf;
}
RegCloseKey( hKey );
}
if (!s) {
if (GetPrivateProfileStringA("mci", 0, "", buf, sizeof(buf), "system.ini")) {
for(p = buf; *p; p += strlen(s) + 1, cnt++) {
if (cnt == lpParms->dwNumber - 1) {
s = p;
break;
}
}
}
}
ret = s ? MCI_WriteString(lpParms->lpstrReturn, lpParms->dwRetSize, s) : MCIERR_OUTOFRANGE;
} }
TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn); TRACE("(%ld) => '%s'\n", lpParms->dwNumber, lpParms->lpstrReturn);
break; break;
...@@ -1724,54 +1740,3 @@ LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2) ...@@ -1724,54 +1740,3 @@ LRESULT MCI_CleanUp(LRESULT dwRet, UINT wMsg, DWORD dwParam2)
} }
return LOWORD(dwRet); return LOWORD(dwRet);
} }
/**************************************************************************
* MCI_Init [internal]
*
* Initializes the MCI internal variables.
*
*/
BOOL MCI_Init(void)
{
LPSTR ptr1, ptr2;
HKEY hWineConf;
HKEY hkey;
DWORD err;
DWORD type;
DWORD count = 2048;
MCI_InstalledCount = 0;
ptr1 = MCI_lpInstallNames = HeapAlloc(GetProcessHeap(), 0, count);
if (!MCI_lpInstallNames)
return FALSE;
/* FIXME: should do also some registry diving here ? */
if (!(err = RegOpenKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine\\Wine\\Config", &hWineConf)) &&
!(err = RegOpenKeyA(hWineConf, "options", &hkey))) {
err = RegQueryValueExA(hkey, "mci", 0, &type, MCI_lpInstallNames, &count);
RegCloseKey(hkey);
}
if (!err) {
TRACE("Wine => '%s' \n", ptr1);
while ((ptr2 = strchr(ptr1, ':')) != 0) {
*ptr2++ = 0;
TRACE("---> '%s' \n", ptr1);
MCI_InstalledCount++;
ptr1 = ptr2;
}
MCI_InstalledCount++;
TRACE("---> '%s' \n", ptr1);
ptr1 += strlen(ptr1) + 1;
} else {
GetPrivateProfileStringA("mci", NULL, "", MCI_lpInstallNames, count, "SYSTEM.INI");
while (strlen(ptr1) > 0) {
TRACE("---> '%s' \n", ptr1);
ptr1 += strlen(ptr1) + 1;
MCI_InstalledCount++;
}
}
RegCloseKey(hWineConf);
return TRUE;
}
...@@ -243,7 +243,6 @@ BOOL MMDRV_Is32(unsigned int); ...@@ -243,7 +243,6 @@ BOOL MMDRV_Is32(unsigned int);
void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, void MMDRV_InstallMap(unsigned int, MMDRV_MAPFUNC, MMDRV_UNMAPFUNC,
MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK); MMDRV_MAPFUNC, MMDRV_UNMAPFUNC, LPDRVCALLBACK);
BOOL MCI_Init(void);
WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID); WINE_MCIDRIVER* MCI_GetDriver(UINT16 uDevID);
UINT MCI_GetDriverFromString(LPCSTR str); UINT MCI_GetDriverFromString(LPCSTR str);
DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr); DWORD MCI_WriteString(LPSTR lpDstStr, DWORD dstSize, LPCSTR lpSrcStr);
......
...@@ -182,7 +182,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad) ...@@ -182,7 +182,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID fImpLoad)
if (!WINMM_CreateIData(hInstDLL)) if (!WINMM_CreateIData(hInstDLL))
return FALSE; return FALSE;
if (!MCI_Init() || !MMDRV_Init()) { if (!MMDRV_Init()) {
WINMM_DeleteIData(); WINMM_DeleteIData();
return FALSE; return FALSE;
} }
......
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