Author: cfinck
Date: Tue Jun 27 07:25:04 2017
New Revision: 75215
URL:
http://svn.reactos.org/svn/reactos?rev=75215&view=rev
Log:
[PRINTING]
Fix all EnumPrintProcessorDatatypes API tests.
Modified:
trunk/reactos/win32ss/printing/base/spoolss/printprocessors.c
trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c
trunk/reactos/win32ss/printing/base/winspool/printprocessors.c
trunk/reactos/win32ss/printing/processors/winprint/main.c
Modified: trunk/reactos/win32ss/printing/base/spoolss/printprocessors.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
==============================================================================
--- trunk/reactos/win32ss/printing/base/spoolss/printprocessors.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/printing/base/spoolss/printprocessors.c [iso-8859-1] Tue Jun 27
07:25:04 2017
@@ -2,7 +2,7 @@
* PROJECT: ReactOS Spooler Router
* LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software
Foundation
* PURPOSE: Functions related to Print Processors
- * COPYRIGHT: Copyright 2015-2016 Colin Finck <colin(a)reactos.org>
+ * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org>
*/
#include "precomp.h"
@@ -10,8 +10,17 @@
BOOL WINAPI
EnumPrintProcessorDatatypesW(PWSTR pName, PWSTR pPrintProcessorName, DWORD Level, PBYTE
pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
{
+ PSPOOLSS_PRINT_PROVIDER pPrintProvider;
+
+ // Sanity checks
+ if (cbBuf && !pDatatypes)
+ {
+ SetLastError(ERROR_INVALID_USER_BUFFER);
+ return FALSE;
+ }
+
// Always call this function on the Local Spooler.
- PSPOOLSS_PRINT_PROVIDER pPrintProvider = CONTAINING_RECORD(PrintProviderList.Flink,
SPOOLSS_PRINT_PROVIDER, Entry);
+ pPrintProvider = CONTAINING_RECORD(PrintProviderList.Flink, SPOOLSS_PRINT_PROVIDER,
Entry);
return pPrintProvider->PrintProvider.fpEnumPrintProcessorDatatypes(pName,
pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
}
Modified: trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/spoo…
==============================================================================
--- trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/printing/base/spoolsv/printprocessors.c [iso-8859-1] Tue Jun 27
07:25:04 2017
@@ -8,17 +8,21 @@
#include "precomp.h"
static void
-_MarshallDownDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1)
+_MarshallDownDatatypesInfo(PDATATYPES_INFO_1W* ppDatatypesInfo1)
{
// Replace absolute pointer addresses in the output by relative offsets.
+ PDATATYPES_INFO_1W pDatatypesInfo1 = *ppDatatypesInfo1;
pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName -
(ULONG_PTR)pDatatypesInfo1);
+ *ppDatatypesInfo1 += sizeof(DATATYPES_INFO_1W);
}
static void
-_MarshallDownPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1)
+_MarshallDownPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W* ppPrintProcessorInfo1)
{
// Replace absolute pointer addresses in the output by relative offsets.
+ PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1 = *ppPrintProcessorInfo1;
pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName -
(ULONG_PTR)pPrintProcessorInfo1);
+ *ppPrintProcessorInfo1 += sizeof(PRINTPROCESSOR_INFO_1W);
}
DWORD
@@ -39,8 +43,7 @@
_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD
Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
{
DWORD dwErrorCode;
- DWORD i;
- PBYTE p = pDatatypes;
+ PBYTE pDatatypesAligned;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
@@ -49,20 +52,25 @@
return dwErrorCode;
}
- EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypes, cbBuf,
pcbNeeded, pcReturned);
- dwErrorCode = GetLastError();
+ pDatatypesAligned = AlignRpcPtr(pDatatypes, &cbBuf);
- if (dwErrorCode == ERROR_SUCCESS)
+ if (EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level,
pDatatypesAligned, cbBuf, pcbNeeded, pcReturned))
{
// Replace absolute pointer addresses in the output by relative offsets.
+ DWORD i;
+ PDATATYPES_INFO_1W p = (PDATATYPES_INFO_1W)pDatatypesAligned;
+
for (i = 0; i < *pcReturned; i++)
- {
- _MarshallDownDatatypesInfo((PDATATYPES_INFO_1W)p);
- p += sizeof(DATATYPES_INFO_1W);
- }
+ _MarshallDownDatatypesInfo(&p);
+ }
+ else
+ {
+ dwErrorCode = GetLastError();
}
RpcRevertToSelf();
+ UndoAlignRpcPtr(pDatatypes, pDatatypesAligned, cbBuf, pcbNeeded);
+
return dwErrorCode;
}
@@ -70,8 +78,6 @@
_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE*
pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
{
DWORD dwErrorCode;
- DWORD i;
- PBYTE p = pPrintProcessorInfo;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
@@ -86,11 +92,11 @@
if (dwErrorCode == ERROR_SUCCESS)
{
// Replace absolute pointer addresses in the output by relative offsets.
+ DWORD i;
+ PPRINTPROCESSOR_INFO_1W p = (PPRINTPROCESSOR_INFO_1W)pPrintProcessorInfo;
+
for (i = 0; i < *pcReturned; i++)
- {
- _MarshallDownPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p);
- p += sizeof(PRINTPROCESSOR_INFO_1W);
- }
+ _MarshallDownPrintProcessorInfo(&p);
}
RpcRevertToSelf();
Modified: trunk/reactos/win32ss/printing/base/winspool/printprocessors.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/base/wins…
==============================================================================
--- trunk/reactos/win32ss/printing/base/winspool/printprocessors.c [iso-8859-1]
(original)
+++ trunk/reactos/win32ss/printing/base/winspool/printprocessors.c [iso-8859-1] Tue Jun 27
07:25:04 2017
@@ -9,17 +9,21 @@
#include <prtprocenv.h>
static void
-_MarshallUpDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1)
+_MarshallUpDatatypesInfo(PDATATYPES_INFO_1W* ppDatatypesInfo1)
{
// Replace relative offset addresses in the output by absolute pointers.
+ PDATATYPES_INFO_1W pDatatypesInfo1 = *ppDatatypesInfo1;
pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName +
(ULONG_PTR)pDatatypesInfo1);
+ *ppDatatypesInfo1 += sizeof(DATATYPES_INFO_1W);
}
static void
-_MarshallUpPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1)
+_MarshallUpPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W* ppPrintProcessorInfo1)
{
// Replace relative offset addresses in the output by absolute pointers.
+ PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1 = *ppPrintProcessorInfo1;
pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName +
(ULONG_PTR)pPrintProcessorInfo1);
+ *ppPrintProcessorInfo1 += sizeof(PRINTPROCESSOR_INFO_1W);
}
BOOL WINAPI
@@ -47,8 +51,13 @@
EnumPrintProcessorDatatypesW(PWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, PBYTE
pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
{
DWORD dwErrorCode;
- DWORD i;
- PBYTE p = pDatatypes;
+
+ // Sanity checks
+ if (Level != 1)
+ {
+ dwErrorCode = ERROR_INVALID_LEVEL;
+ goto Cleanup;
+ }
// Do the RPC call
RpcTryExcept
@@ -64,14 +73,14 @@
if (dwErrorCode == ERROR_SUCCESS)
{
- // Replace relative offset addresses in the output by absolute pointers.
+ DWORD i;
+ PDATATYPES_INFO_1W p = (PDATATYPES_INFO_1W)pDatatypes;
+
for (i = 0; i < *pcReturned; i++)
- {
- _MarshallUpDatatypesInfo((PDATATYPES_INFO_1W)p);
- p += sizeof(DATATYPES_INFO_1W);
- }
- }
-
+ _MarshallUpDatatypesInfo(&p);
+ }
+
+Cleanup:
SetLastError(dwErrorCode);
return (dwErrorCode == ERROR_SUCCESS);
}
@@ -80,8 +89,6 @@
EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE
pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
{
DWORD dwErrorCode;
- DWORD i;
- PBYTE p = pPrintProcessorInfo;
// Choose our current environment if the caller didn't give any.
if (!pEnvironment)
@@ -100,12 +107,11 @@
if (dwErrorCode == ERROR_SUCCESS)
{
- // Replace relative offset addresses in the output by absolute pointers.
+ DWORD i;
+ PPRINTPROCESSOR_INFO_1W p = (PPRINTPROCESSOR_INFO_1W)pPrintProcessorInfo;
+
for (i = 0; i < *pcReturned; i++)
- {
- _MarshallUpPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p);
- p += sizeof(PRINTPROCESSOR_INFO_1W);
- }
+ _MarshallUpPrintProcessorInfo(&p);
}
SetLastError(dwErrorCode);
Modified: trunk/reactos/win32ss/printing/processors/winprint/main.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/printing/processor…
==============================================================================
--- trunk/reactos/win32ss/printing/processors/winprint/main.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/printing/processors/winprint/main.c [iso-8859-1] Tue Jun 27
07:25:04 2017
@@ -2,7 +2,7 @@
* PROJECT: ReactOS Standard Print Processor
* LICENSE: GNU LGPL v2.1 or any later version as published by the Free Software
Foundation
* PURPOSE: Main functions
- * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ * COPYRIGHT: Copyright 2015-2017 Colin Finck <colin(a)reactos.org>
*/
#include "precomp.h"
@@ -112,7 +112,6 @@
{
DWORD cbDatatype;
DWORD dwDatatypeCount = 0;
- DWORD dwErrorCode;
DWORD dwOffsets[_countof(_pwszDatatypes)];
PWSTR* pCurrentDatatype;
PDWORD pCurrentOffset = dwOffsets;
@@ -121,10 +120,7 @@
// Sanity checks
if (Level != 1 || !pcbNeeded || !pcReturned)
- {
- dwErrorCode = ERROR_INVALID_PARAMETER;
- goto Cleanup;
- }
+ return FALSE;
// Count the required buffer size and the number of datatypes.
*pcbNeeded = 0;
@@ -145,15 +141,15 @@
// Check if the supplied buffer is large enough.
if (cbBuf < *pcbNeeded)
{
- dwErrorCode = ERROR_INSUFFICIENT_BUFFER;
- goto Cleanup;
+ SetLastError(ERROR_INSUFFICIENT_BUFFER);
+ return FALSE;
}
// Check if a buffer was supplied at all.
if (!pDatatypes)
{
- dwErrorCode = ERROR_INVALID_PARAMETER;
- goto Cleanup;
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
}
// Copy over all datatypes.
@@ -161,11 +157,7 @@
PackStrings(_pwszDatatypes, pDatatypes, dwOffsets, &pDatatypes[*pcbNeeded]);
*pcReturned = dwDatatypeCount;
- dwErrorCode = ERROR_SUCCESS;
-
-Cleanup:
- SetLastError(dwErrorCode);
- return (dwErrorCode == ERROR_SUCCESS);
+ return TRUE;
}