serialui: Fix return type for drvGetDefaultCommConfig.
This commit is contained in:
parent
fa86532354
commit
59e816d82c
|
@ -49,6 +49,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(comm);
|
||||||
|
|
||||||
static HMODULE SERIALUI_hModule;
|
static HMODULE SERIALUI_hModule;
|
||||||
|
|
||||||
|
static const WCHAR comW[] = {'c','o','m',0 };
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* DllMain [Internal] Initializes the internal 'SERIALUI.DLL'.
|
* DllMain [Internal] Initializes the internal 'SERIALUI.DLL'.
|
||||||
*
|
*
|
||||||
|
@ -535,7 +537,7 @@ BOOL WINAPI drvSetDefaultCommConfigA(
|
||||||
* FIXME: uses the wrong registry key... should use a digit, not
|
* FIXME: uses the wrong registry key... should use a digit, not
|
||||||
* the comm port name.
|
* the comm port name.
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI drvGetDefaultCommConfigW(
|
DWORD WINAPI drvGetDefaultCommConfigW(
|
||||||
LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize)
|
LPCWSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize)
|
||||||
{
|
{
|
||||||
HKEY hKeyReg, hKeyPort;
|
HKEY hKeyReg, hKeyPort;
|
||||||
|
@ -543,16 +545,25 @@ BOOL WINAPI drvGetDefaultCommConfigW(
|
||||||
DWORD r,dwSize,dwType;
|
DWORD r,dwSize,dwType;
|
||||||
static const WCHAR fmt[] = {'%','s','\\','%','s',0 };
|
static const WCHAR fmt[] = {'%','s','\\','%','s',0 };
|
||||||
|
|
||||||
TRACE("%p %p %p\n",lpszDevice,lpCommConfig,lpdwSize);
|
TRACE("(%s, %p, %p) *lpdwSize: %u\n", debugstr_w(lpszDevice), lpCommConfig, lpdwSize, lpdwSize ? *lpdwSize : 0);
|
||||||
|
|
||||||
if(!lpCommConfig)
|
if ((!lpszDevice) || (!lpCommConfig) || (!lpdwSize)) {
|
||||||
return FALSE;
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
if(!lpdwSize)
|
if (*lpdwSize < sizeof (COMMCONFIG)) {
|
||||||
return FALSE;
|
*lpdwSize = sizeof (COMMCONFIG);
|
||||||
|
return ERROR_INSUFFICIENT_BUFFER;
|
||||||
|
}
|
||||||
|
|
||||||
if(*lpdwSize < sizeof (COMMCONFIG))
|
/* only "com1" - "com9" is allowed */
|
||||||
return FALSE;
|
r = sizeof(comW) / sizeof(WCHAR); /* len of "com\0" */
|
||||||
|
lstrcpynW(szKeyName, lpszDevice, r); /* simulate a lstrcmpnW */
|
||||||
|
r--;
|
||||||
|
if( lstrcmpW(szKeyName, comW) ||
|
||||||
|
(lpszDevice[r] < '1') || (lpszDevice[r] > '9') || lpszDevice[r+1]) {
|
||||||
|
return ERROR_BADKEY;
|
||||||
|
}
|
||||||
|
|
||||||
*lpdwSize = sizeof (COMMCONFIG);
|
*lpdwSize = sizeof (COMMCONFIG);
|
||||||
memset(lpCommConfig, 0 , sizeof (COMMCONFIG));
|
memset(lpCommConfig, 0 , sizeof (COMMCONFIG));
|
||||||
|
@ -560,8 +571,7 @@ BOOL WINAPI drvGetDefaultCommConfigW(
|
||||||
lpCommConfig->wVersion = 1;
|
lpCommConfig->wVersion = 1;
|
||||||
|
|
||||||
r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg);
|
r = RegConnectRegistryW(NULL, HKEY_LOCAL_MACHINE, &hKeyReg);
|
||||||
if(r != ERROR_SUCCESS)
|
if(r != ERROR_SUCCESS) return r;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
snprintfW(szKeyName, sizeof(szKeyName)/sizeof(WCHAR), fmt, lpszCommKey ,lpszDevice);
|
snprintfW(szKeyName, sizeof(szKeyName)/sizeof(WCHAR), fmt, lpszCommKey ,lpszDevice);
|
||||||
r = RegOpenKeyW(hKeyReg, szKeyName, &hKeyPort);
|
r = RegOpenKeyW(hKeyReg, szKeyName, &hKeyPort);
|
||||||
|
@ -571,12 +581,13 @@ BOOL WINAPI drvGetDefaultCommConfigW(
|
||||||
dwType = 0;
|
dwType = 0;
|
||||||
r = RegQueryValueExW( hKeyPort, lpszDCB, NULL,
|
r = RegQueryValueExW( hKeyPort, lpszDCB, NULL,
|
||||||
&dwType, (LPBYTE)&lpCommConfig->dcb, &dwSize);
|
&dwType, (LPBYTE)&lpCommConfig->dcb, &dwSize);
|
||||||
if ((r==ERROR_SUCCESS) && (dwType != REG_BINARY))
|
|
||||||
r = 1;
|
|
||||||
if ((r==ERROR_SUCCESS) && (dwSize != sizeof(DCB)))
|
|
||||||
r = 1;
|
|
||||||
|
|
||||||
RegCloseKey(hKeyPort);
|
RegCloseKey(hKeyPort);
|
||||||
|
if ((r!=ERROR_SUCCESS) || (dwType != REG_BINARY) || (dwSize != sizeof(DCB))) {
|
||||||
|
RegCloseKey(hKeyReg);
|
||||||
|
return ERROR_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -589,22 +600,22 @@ BOOL WINAPI drvGetDefaultCommConfigW(
|
||||||
lpCommConfig->dcb.ByteSize = 8;
|
lpCommConfig->dcb.ByteSize = 8;
|
||||||
lpCommConfig->dcb.Parity = NOPARITY;
|
lpCommConfig->dcb.Parity = NOPARITY;
|
||||||
lpCommConfig->dcb.StopBits = ONESTOPBIT;
|
lpCommConfig->dcb.StopBits = ONESTOPBIT;
|
||||||
return TRUE;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hKeyReg);
|
RegCloseKey(hKeyReg);
|
||||||
|
|
||||||
return (r==ERROR_SUCCESS);
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* drvGetDefaultCommConfigA (SERIALUI.@)
|
* drvGetDefaultCommConfigA (SERIALUI.@)
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI drvGetDefaultCommConfigA(
|
DWORD WINAPI drvGetDefaultCommConfigA(
|
||||||
LPCSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize)
|
LPCSTR lpszDevice, LPCOMMCONFIG lpCommConfig, LPDWORD lpdwSize)
|
||||||
{
|
{
|
||||||
LPWSTR strW = SERIALUI_strdup( lpszDevice );
|
LPWSTR strW = SERIALUI_strdup( lpszDevice );
|
||||||
BOOL r = drvGetDefaultCommConfigW( strW, lpCommConfig, lpdwSize );
|
DWORD r = drvGetDefaultCommConfigW( strW, lpCommConfig, lpdwSize );
|
||||||
SERIALUI_strfree( strW );
|
SERIALUI_strfree( strW );
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue