Commit a2daf754 authored by Detlef Riekenberg's avatar Detlef Riekenberg Committed by Alexandre Julliard

winspool: Enable all levels for EnumPrinterDrivers + GetPrinterDriver.

parent 4b53154f
...@@ -245,6 +245,10 @@ static const WCHAR LPR_Port[] = {'L','P','R',':',0}; ...@@ -245,6 +245,10 @@ static const WCHAR LPR_Port[] = {'L','P','R',':',0};
static const WCHAR default_doc_title[] = {'L','o','c','a','l',' ','D','o','w','n','l','e','v','e','l',' ', static const WCHAR default_doc_title[] = {'L','o','c','a','l',' ','D','o','w','n','l','e','v','e','l',' ',
'D','o','c','u','m','e','n','t',0}; 'D','o','c','u','m','e','n','t',0};
static const DWORD di_sizeof[] = {0, sizeof(DRIVER_INFO_1W), sizeof(DRIVER_INFO_2W),
sizeof(DRIVER_INFO_3W), sizeof(DRIVER_INFO_4W),
sizeof(DRIVER_INFO_5W), sizeof(DRIVER_INFO_6W),
0, sizeof(DRIVER_INFO_8W)};
/****************************************************************** /******************************************************************
* validate the user-supplied printing-environment [internal] * validate the user-supplied printing-environment [internal]
...@@ -4371,6 +4375,8 @@ static BOOL WINSPOOL_GetDriverInfoFromReg( ...@@ -4371,6 +4375,8 @@ static BOOL WINSPOOL_GetDriverInfoFromReg(
debugstr_w(DriverName), env, debugstr_w(DriverName), env,
Level, di, pDriverStrings, cbBuf, unicode); Level, di, pDriverStrings, cbBuf, unicode);
if (di) ZeroMemory(di, di_sizeof[Level]);
if (unicode) { if (unicode) {
*pcbNeeded = (lstrlenW(DriverName) + 1) * sizeof(WCHAR); *pcbNeeded = (lstrlenW(DriverName) + 1) * sizeof(WCHAR);
if (*pcbNeeded <= cbBuf) if (*pcbNeeded <= cbBuf)
...@@ -4540,14 +4546,13 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPCWSTR pEnvironment, ...@@ -4540,14 +4546,13 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPCWSTR pEnvironment,
TRACE("(%p,%s,%d,%p,%d,%p)\n",hPrinter,debugstr_w(pEnvironment), TRACE("(%p,%s,%d,%p,%d,%p)\n",hPrinter,debugstr_w(pEnvironment),
Level,pDriverInfo,cbBuf, pcbNeeded); Level,pDriverInfo,cbBuf, pcbNeeded);
ZeroMemory(pDriverInfo, cbBuf);
if (!(name = get_opened_printer_name(hPrinter))) { if (!(name = get_opened_printer_name(hPrinter))) {
SetLastError(ERROR_INVALID_HANDLE); SetLastError(ERROR_INVALID_HANDLE);
return FALSE; return FALSE;
} }
if(Level < 1 || Level > 6) { if (Level < 1 || Level == 7 || Level > 8) {
SetLastError(ERROR_INVALID_LEVEL); SetLastError(ERROR_INVALID_LEVEL);
return FALSE; return FALSE;
} }
...@@ -4584,36 +4589,12 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPCWSTR pEnvironment, ...@@ -4584,36 +4589,12 @@ static BOOL WINSPOOL_GetPrinterDriver(HANDLE hPrinter, LPCWSTR pEnvironment,
return FALSE; return FALSE;
} }
switch(Level) { size = di_sizeof[Level];
case 1: if ((size <= cbBuf) && pDriverInfo)
size = sizeof(DRIVER_INFO_1W);
break;
case 2:
size = sizeof(DRIVER_INFO_2W);
break;
case 3:
size = sizeof(DRIVER_INFO_3W);
break;
case 4:
size = sizeof(DRIVER_INFO_4W);
break;
case 5:
size = sizeof(DRIVER_INFO_5W);
break;
case 6:
size = sizeof(DRIVER_INFO_6W);
break;
default:
ERR("Invalid level\n");
return FALSE;
}
if(size <= cbBuf)
ptr = pDriverInfo + size; ptr = pDriverInfo + size;
if(!WINSPOOL_GetDriverInfoFromReg(hkeyDrivers, DriverName, if(!WINSPOOL_GetDriverInfoFromReg(hkeyDrivers, DriverName,
env, Level, pDriverInfo, env, Level, pDriverInfo, ptr,
(cbBuf < size) ? NULL : ptr,
(cbBuf < size) ? 0 : cbBuf - size, (cbBuf < size) ? 0 : cbBuf - size,
&needed, unicode)) { &needed, unicode)) {
RegCloseKey(hkeyDrivers); RegCloseKey(hkeyDrivers);
...@@ -5044,8 +5025,7 @@ static BOOL WINSPOOL_EnumPrinterDrivers(LPWSTR pName, LPCWSTR pEnvironment, ...@@ -5044,8 +5025,7 @@ static BOOL WINSPOOL_EnumPrinterDrivers(LPWSTR pName, LPCWSTR pEnvironment,
if (!env) return FALSE; /* SetLastError() is in validate_envW */ if (!env) return FALSE; /* SetLastError() is in validate_envW */
/* check input parameter */ /* check input parameter */
if((Level < 1) || (Level > 3)) { if ((Level < 1) || (Level == 7) || (Level > 8)) {
ERR("unsupported level %d\n", Level);
SetLastError(ERROR_INVALID_LEVEL); SetLastError(ERROR_INVALID_LEVEL);
return FALSE; return FALSE;
} }
...@@ -5073,17 +5053,7 @@ static BOOL WINSPOOL_EnumPrinterDrivers(LPWSTR pName, LPCWSTR pEnvironment, ...@@ -5073,17 +5053,7 @@ static BOOL WINSPOOL_EnumPrinterDrivers(LPWSTR pName, LPCWSTR pEnvironment,
/* get size of single struct /* get size of single struct
* unicode and ascii structure have the same size * unicode and ascii structure have the same size
*/ */
switch (Level) { size = di_sizeof[Level];
case 1:
size = sizeof(DRIVER_INFO_1A);
break;
case 2:
size = sizeof(DRIVER_INFO_2A);
break;
case 3:
size = sizeof(DRIVER_INFO_3A);
break;
}
/* calculate required buffer size */ /* calculate required buffer size */
*pcbNeeded = size * number; *pcbNeeded = size * number;
......
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