Author: cfinck
Date: Mon Jun 26 15:16:46 2017
New Revision: 75207
URL:
http://svn.reactos.org/svn/reactos?rev=75207&view=rev
Log:
[PRINTING]
- Create the actual generic handle in _LocalOpenPrinterHandle.
- Fix _RpcClosePrinter call.
- Enable many more tests in winspool_apitest, GetPrinterData.
- Bail out with ERROR_INVALID_PARAMETER for empty strings in _MakePrinterSubKey as well.
- Add the Name registry value for "Dummy Printer on LPT1" to make a test
succeed.
This fixes many basic things.. which only got unnoticed, because Printing is only used in
the form of API Tests so far.
CORE-13458
CORE-13459
Modified:
trunk/reactos/boot/bootdata/hivesft.inf
trunk/reactos/win32ss/printing/base/winspool/printers.c
trunk/reactos/win32ss/printing/providers/localspl/printerdata.c
trunk/reactos/win32ss/printing/providers/localspl/printers.c
trunk/rostests/apitests/winspool/GetPrinterData.c
Modified: trunk/reactos/boot/bootdata/hivesft.inf
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/hivesft.inf?…
==============================================================================
--- trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/hivesft.inf [iso-8859-1] Mon Jun 26 15:16:46 2017
@@ -444,6 +444,7 @@
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,\
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Dummy Printer On
LPT1","Location",,"At Home"
+HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Dummy Printer On
LPT1","Name",,"Dummy Printer On LPT1"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Dummy Printer On
LPT1","Port",,"LPT1:"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Dummy Printer On
LPT1","Print Processor",,"winprint"
HKLM,"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\Dummy Printer On
LPT1","Printer Driver",,"Dummy Printer Driver"
Modified: trunk/reactos/win32ss/printing/base/winspool/printers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/wins…
==============================================================================
--- trunk/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/printing/base/winspool/printers.c [iso-8859-1] Mon Jun 26
15:16:46 2017
@@ -235,7 +235,7 @@
// Do the RPC call.
RpcTryExcept
{
- dwErrorCode = _RpcClosePrinter(pHandle->hPrinter);
+ dwErrorCode = _RpcClosePrinter(&pHandle->hPrinter);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
Modified: trunk/reactos/win32ss/printing/providers/localspl/printerdata.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
==============================================================================
--- trunk/reactos/win32ss/printing/providers/localspl/printerdata.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/printing/providers/localspl/printerdata.c [iso-8859-1] Mon Jun
26 15:16:46 2017
@@ -25,7 +25,7 @@
PWSTR p;
// Sanity check
- if (!pKeyName)
+ if (!pKeyName || !*pKeyName)
return ERROR_INVALID_PARAMETER;
// Allocate a buffer for the subkey "PrinterName\KeyName".
@@ -204,7 +204,7 @@
dwErrorCode = DsRoleGetPrimaryDomainInformation(NULL,
DsRolePrimaryDomainInfoBasic, (PBYTE*)&pInfo);
if (dwErrorCode != ERROR_SUCCESS)
{
- ERR("DsRoleGetPrimaryDomainInformation failed with error %lu!\n",
GetLastError());
+ ERR("DsRoleGetPrimaryDomainInformation failed with error %lu!\n",
dwErrorCode);
return dwErrorCode;
}
@@ -216,9 +216,9 @@
else if (wcsicmp(pValueName, SPLREG_DS_PRESENT_FOR_USER) == 0)
{
DWORD cch;
- PWSTR pwszUserSam;
PWSTR p;
WCHAR wszComputerName[MAX_COMPUTERNAME_LENGTH + 1];
+ WCHAR wszUserSam[UNLEN + 1];
// We want to store a REG_DWORD value.
*pType = REG_DWORD;
@@ -230,47 +230,30 @@
cch = MAX_COMPUTERNAME_LENGTH + 1;
if (!GetComputerNameW(wszComputerName, &cch))
{
- ERR("GetComputerNameW failed with error %lu!\n", GetLastError());
- return GetLastError();
+ dwErrorCode = GetLastError();
+ ERR("GetComputerNameW failed with error %lu!\n", dwErrorCode);
+ return dwErrorCode;
}
// Get the User Name in the SAM format.
// This could either be:
// COMPUTERNAME\User
// DOMAINNAME\User
- cch = 0;
- GetUserNameExW(NameSamCompatible, NULL, &cch);
- dwErrorCode = GetLastError();
- if (dwErrorCode != ERROR_MORE_DATA)
- {
- ERR("GetUserNameExW failed with error %lu!\n", dwErrorCode);
- return dwErrorCode;
- }
-
- pwszUserSam = DllAllocSplMem(cch * sizeof(WCHAR));
- if (!pwszUserSam)
- {
- dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
- ERR("DllAllocSplMem failed!\n");
- return dwErrorCode;
- }
-
- if (!GetUserNameExW(NameSamCompatible, pwszUserSam, &cch))
+ cch = UNLEN + 1;
+ if (!GetUserNameExW(NameSamCompatible, wszUserSam, &cch))
{
dwErrorCode = GetLastError();
ERR("GetUserNameExW failed with error %lu!\n", dwErrorCode);
- DllFreeSplMem(pwszUserSam);
return dwErrorCode;
}
// Terminate the SAM-formatted User Name at the backslash.
- p = wcschr(pwszUserSam, L'\\');
+ p = wcschr(wszUserSam, L'\\');
*p = 0;
// Compare it with the Computer Name.
// If they differ, this User is part of a domain.
- *((PDWORD)pData) = (wcscmp(pwszUserSam, wszComputerName) != 0);
- DllFreeSplMem(pwszUserSam);
+ *((PDWORD)pData) = (wcscmp(wszUserSam, wszComputerName) != 0);
return ERROR_SUCCESS;
}
else if (wcsicmp(pValueName, SPLREG_REMOTE_FAX) == 0)
@@ -328,6 +311,7 @@
DWORD WINAPI
LocalGetPrinterDataEx(HANDLE hPrinter, PCWSTR pKeyName, PCWSTR pValueName, PDWORD pType,
PBYTE pData, DWORD nSize, PDWORD pcbNeeded)
{
+ BYTE Temp;
DWORD dwErrorCode;
DWORD dwTemp;
PLOCAL_HANDLE pHandle = (PLOCAL_HANDLE)hPrinter;
@@ -337,6 +321,12 @@
// Ensure here that it is always set to simplify the code later.
if (!pType)
pType = &dwTemp;
+
+ // pData is later fed to RegQueryValueExW in many cases. When calling it with zero
buffer size, RegQueryValueExW returns a
+ // different error code based on whether pData is NULL or something else.
+ // Ensure here that ERROR_MORE_DATA is always returned.
+ if (!pData)
+ pData = &Temp;
if (!pHandle)
{
Modified: trunk/reactos/win32ss/printing/providers/localspl/printers.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/providers…
==============================================================================
--- trunk/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/printing/providers/localspl/printers.c [iso-8859-1] Mon Jun 26
15:16:46 2017
@@ -1106,6 +1106,15 @@
goto Failure;
}
+ // Create a new generic handle.
+ pHandle = DllAllocSplMem(sizeof(LOCAL_HANDLE));
+ if (!pHandle)
+ {
+ dwErrorCode = ERROR_NOT_ENOUGH_MEMORY;
+ ERR("DllAllocSplMem failed!\n");
+ goto Failure;
+ }
+
// Create a new LOCAL_PRINTER_HANDLE.
pPrinterHandle = DllAllocSplMem(sizeof(LOCAL_PRINTER_HANDLE));
if (!pPrinterHandle)
@@ -1192,7 +1201,7 @@
pPrinterHandle->pJob = pJob;
}
- // Make the generic handle a Port handle.
+ // Make the generic handle a Printer handle.
pHandle->HandleType = HandleType_Printer;
pHandle->pSpecificHandle = pPrinterHandle;
Modified: trunk/rostests/apitests/winspool/GetPrinterData.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/winspool/GetPrin…
==============================================================================
--- trunk/rostests/apitests/winspool/GetPrinterData.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/winspool/GetPrinterData.c [iso-8859-1] Mon Jun 26 15:16:46
2017
@@ -28,7 +28,6 @@
SPLREG_VALUE, *PSPLREG_VALUE;
SPLREG_VALUE SplRegValues[] = {
-#if 0
{ "DefaultSpoolDirectory", L"DefaultSpoolDirectory", REG_SZ,
0xFFFFFFFF, TRUE },
{ "PortThreadPriorityDefault", L"PortThreadPriorityDefault",
REG_NONE, 4, FALSE },
{ "PortThreadPriority", L"PortThreadPriority", REG_DWORD, 4, TRUE
},
@@ -50,6 +49,7 @@
{ "Architecture", L"Architecture", REG_NONE, 0xFFFFFFFF, FALSE
},
{ "OSVersion", L"OSVersion", REG_NONE, sizeof(OSVERSIONINFOA),
FALSE },
{ "OSVersionEx", L"OSVersionEx", REG_NONE,
sizeof(OSVERSIONINFOEXA), FALSE },
+#if 0
{ "DsPresent", L"DsPresent", REG_DWORD, 4, FALSE },
{ "DsPresentForUser", L"DsPresentForUser", REG_DWORD, 4, FALSE
},
#endif