Author: cfinck
Date: Fri Jun 5 18:16:51 2015
New Revision: 68025
URL:
http://svn.reactos.org/svn/reactos?rev=68025&view=rev
Log:
[PRINTING]
Add an include directory for all printing components containing definitions not found in
the public headers.
For now, that's just PackStrings in spoolss.h.
[SPOOLSS_APITEST]
Use the new spoolss.h header.
[WINPRINT_APITEST]
Add an API-Test for the winprint Print Processor, so far for its
EnumPrintProcessorDatatypesW function. Tests succeed in Windows Server 2003.
winspool.drv also provides functions that go into winprint.dll, but as these tests show,
they behave slightly different in terms of error codes due to the involved RPC and
routing.
Windows Server 2003 has winprint functions in localspl.dll, so you have to copy its
localspl.dll to winprint.dll for testing.
[WINPRINT]
- Use PackStrings to simplify the code.
- Fix test failures.
Added:
branches/colins-printing-for-freedom/reactos/win32ss/printing/include/ (with props)
branches/colins-printing-for-freedom/reactos/win32ss/printing/include/spoolss.h
(with props)
branches/colins-printing-for-freedom/rostests/apitests/winprint/ (with props)
branches/colins-printing-for-freedom/rostests/apitests/winprint/CMakeLists.txt (with
props)
branches/colins-printing-for-freedom/rostests/apitests/winprint/EnumPrintProcessorDatatypesW.c
(with props)
branches/colins-printing-for-freedom/rostests/apitests/winprint/testlist.c (with
props)
Modified:
branches/colins-printing-for-freedom/reactos/win32ss/printing/CMakeLists.txt
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/CMakeLists.txt
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/main.c
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/precomp.h
branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt
branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt
branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c
Modified: branches/colins-printing-for-freedom/reactos/win32ss/printing/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
---
branches/colins-printing-for-freedom/reactos/win32ss/printing/CMakeLists.txt [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/reactos/win32ss/printing/CMakeLists.txt [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -1,3 +1,5 @@
+include_directories(include)
+
add_subdirectory(base)
#add_subdirectory(drivers)
add_subdirectory(monitors)
Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/include/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Fri Jun 5 18:16:51 2015
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/include/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/include/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Propchange: branches/colins-printing-for-freedom/reactos/win32ss/printing/include/
------------------------------------------------------------------------------
tsvn:logminsize = 10
Added: branches/colins-printing-for-freedom/reactos/win32ss/printing/include/spoolss.h
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
---
branches/colins-printing-for-freedom/reactos/win32ss/printing/include/spoolss.h (added)
+++
branches/colins-printing-for-freedom/reactos/win32ss/printing/include/spoolss.h [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -0,0 +1,14 @@
+/*
+ * PROJECT: ReactOS Printing Include files
+ * LICENSE: GNU LGPLv2 or any later version as published by the Free Software
Foundation
+ * PURPOSE: Undocumented APIs of the Spooler Router "spoolss.dll"
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#ifndef _REACTOS_SPOOLSS_H
+#define _REACTOS_SPOOLSS_H
+
+PBYTE WINAPI
+PackStrings(PCWSTR* pSource, PBYTE pDest, PDWORD DestOffsets, PBYTE pEnd);
+
+#endif
Propchange:
branches/colins-printing-for-freedom/reactos/win32ss/printing/include/spoolss.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
---
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/CMakeLists.txt [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/CMakeLists.txt [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -13,6 +13,6 @@
set_module_type(winprint win32dll UNICODE)
target_link_libraries(winprint wine)
-add_importlibs(winprint kernel32 msvcrt ntdll)
+add_importlibs(winprint spoolss msvcrt kernel32 ntdll)
add_pch(winprint precomp.h SOURCE)
add_cd_file(TARGET winprint DESTINATION reactos/system32/spool/prtprocs/w32x86 FOR all)
Modified:
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/main.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
---
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/main.c [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/main.c [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -48,18 +48,14 @@
BOOL WINAPI
EnumPrintProcessorDatatypesW(LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level,
LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
{
- DATATYPES_INFO_1W DatatypesInfo1;
DWORD cbDatatype;
- PBYTE pCurrentOutputDatatype;
- PBYTE pCurrentOutputDatatypeInfo;
+ DWORD dwOffsets[_countof(pwszDatatypes)];
PCWSTR* pCurrentDatatype;
+ PDWORD pCurrentOffset = dwOffsets;
// Sanity checks
if (Level != 1 || !pcbNeeded || !pcReturned)
- {
- SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
- }
// Count the required buffer size and the number of datatypes.
*pcbNeeded = 0;
@@ -69,7 +65,12 @@
{
cbDatatype = (wcslen(*pCurrentDatatype) + 1) * sizeof(WCHAR);
*pcbNeeded += sizeof(DATATYPES_INFO_1W) + cbDatatype;
+
+ // Also calculate the offset in the output buffer of the pointer to this datatype
string.
+ *pCurrentOffset = *pcReturned * sizeof(DATATYPES_INFO_1W) +
FIELD_OFFSET(DATATYPES_INFO_1W, pName);
+
*pcReturned++;
+ pCurrentOffset++;
}
// Check if the supplied buffer is large enough.
@@ -79,25 +80,16 @@
return FALSE;
}
- // Put the datatype strings right after the last DATATYPES_INFO_1W structure.
- pCurrentOutputDatatypeInfo = pDatatypes;
- pCurrentOutputDatatype = pDatatypes + *pcReturned * sizeof(DATATYPES_INFO_1W);
+ // Check if a buffer was supplied at all.
+ if (!pDatatypes)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
// Copy over all datatypes.
- for (pCurrentDatatype = pwszDatatypes; *pCurrentDatatype; pCurrentDatatype++)
- {
- // Copy the datatype string into the output buffer.
- cbDatatype = (wcslen(*pCurrentDatatype) + 1) * sizeof(WCHAR);
- CopyMemory(pCurrentOutputDatatype, *pCurrentDatatype, cbDatatype);
-
- // Fill and copy the DATATYPES_INFO_1W structure belonging to this datatype.
- DatatypesInfo1.pName = (PWSTR)pCurrentOutputDatatype;
- CopyMemory(pCurrentOutputDatatypeInfo, &DatatypesInfo1,
sizeof(DATATYPES_INFO_1W));
-
- // Advance to the next DATATYPES_INFO_1W location and string location in the
output buffer.
- pCurrentOutputDatatype += cbDatatype;
- pCurrentOutputDatatypeInfo += sizeof(DATATYPES_INFO_1W);
- }
+ *pCurrentOffset = MAXDWORD;
+ PackStrings(pwszDatatypes, pDatatypes, dwOffsets, &pDatatypes[*pcbNeeded]);
return TRUE;
}
Modified:
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/precomp.h
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/rea…
==============================================================================
---
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/precomp.h [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/reactos/win32ss/printing/processors/winprint/precomp.h [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -9,6 +9,7 @@
#define _PRECOMP_H
#define WIN32_NO_STATUS
+#include <stdlib.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
@@ -16,6 +17,8 @@
#include <winspool.h>
#include <winsplp.h>
+#include <spoolss.h>
+
#include <wine/debug.h>
WINE_DEFAULT_DEBUG_CHANNEL(winprint);
Modified: branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt [iso-8859-1]
(original)
+++ branches/colins-printing-for-freedom/rostests/apitests/CMakeLists.txt [iso-8859-1] Fri
Jun 5 18:16:51 2015
@@ -25,5 +25,6 @@
endif()
add_subdirectory(winhttp)
add_subdirectory(wininet)
+add_subdirectory(winprint)
add_subdirectory(winspool)
add_subdirectory(ws2_32)
Modified: branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/rostests/apitests/spoolss/CMakeLists.txt [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -1,3 +1,5 @@
+
+include_directories(${REACTOS_SOURCE_DIR}/win32ss/printing/include)
list(APPEND SOURCE
PackStrings.c
Modified: branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c [iso-8859-1]
(original)
+++
branches/colins-printing-for-freedom/rostests/apitests/spoolss/PackStrings.c [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -10,8 +10,7 @@
#define WIN32_NO_STATUS
#include <windef.h>
#include <winbase.h>
-
-PBYTE WINAPI PackStrings(PCWSTR*, PBYTE, PDWORD, PBYTE);
+#include <spoolss.h>
typedef struct _EXAMPLE_STRUCT
{
Propchange: branches/colins-printing-for-freedom/rostests/apitests/winprint/
------------------------------------------------------------------------------
--- bugtraq:logregex (added)
+++ bugtraq:logregex Fri Jun 5 18:16:51 2015
@@ -0,0 +1,2 @@
+([Ii]ssue|[Bb]ug)s? #?(\d+)(,? ?#?(\d+))*(,? ?(and |or )?#?(\d+))?
+(\d+)
Propchange: branches/colins-printing-for-freedom/rostests/apitests/winprint/
------------------------------------------------------------------------------
bugtraq:message = See issue #%BUGID% for more details.
Propchange: branches/colins-printing-for-freedom/rostests/apitests/winprint/
------------------------------------------------------------------------------
bugtraq:url =
http://www.reactos.org/bugzilla/show_bug.cgi?id=%BUGID%
Added: branches/colins-printing-for-freedom/rostests/apitests/winprint/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winprint/CMakeLists.txt (added)
+++
branches/colins-printing-for-freedom/rostests/apitests/winprint/CMakeLists.txt [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -0,0 +1,10 @@
+
+list(APPEND SOURCE
+ EnumPrintProcessorDatatypesW.c
+ testlist.c)
+
+add_executable(winprint_apitest ${SOURCE})
+target_link_libraries(winprint_apitest wine ${PSEH_LIB})
+set_module_type(winprint_apitest win32cui)
+add_importlibs(winprint_apitest winprint msvcrt kernel32 ntdll)
+add_cd_file(TARGET winprint_apitest DESTINATION reactos/bin FOR all)
Propchange:
branches/colins-printing-for-freedom/rostests/apitests/winprint/CMakeLists.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added:
branches/colins-printing-for-freedom/rostests/apitests/winprint/EnumPrintProcessorDatatypesW.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
---
branches/colins-printing-for-freedom/rostests/apitests/winprint/EnumPrintProcessorDatatypesW.c (added)
+++
branches/colins-printing-for-freedom/rostests/apitests/winprint/EnumPrintProcessorDatatypesW.c [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -0,0 +1,81 @@
+/*
+ * PROJECT: ReactOS Standard Print Processor API Tests
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software
Foundation
+ * PURPOSE: Tests for EnumPrintProcessorDatatypesW
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+#define WIN32_NO_STATUS
+#include <windef.h>
+#include <winbase.h>
+#include <wingdi.h>
+#include <winspool.h>
+
+START_TEST(EnumPrintProcessorDatatypesW)
+{
+ DWORD cbNeeded;
+ DWORD cbTemp;
+ DWORD dwReturned;
+ PDATATYPES_INFO_1W pDatatypesInfo1;
+
+ // Try with an invalid level. The error needs to be set by winspool, but not by the
Print Processor.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 0, NULL, 0, NULL, NULL),
"EnumPrintProcessorDatatypesW returns TRUE!\n");
+ ok(GetLastError() == 0xDEADBEEF, "EnumPrintProcessorDatatypesW returns error
%lu!\n", GetLastError());
+
+ // Now try with valid level, but no pcbNeeded and no pcReturned. The error needs to
be set by RPC.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, 0, NULL, NULL),
"EnumPrintProcessorDatatypesW returns TRUE!\n");
+ ok(GetLastError() == 0xDEADBEEF, "EnumPrintProcessorDatatypesW returns error
%lu!\n", GetLastError());
+
+ // Now try with pcbNeeded and pcReturned, but give no Print Processor. Show that
winprint actually ignores the given Print Processor.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, 0, &cbNeeded,
&dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
+ ok(cbNeeded > 0, "cbNeeded is 0!\n");
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // Same error has to occur when looking for an invalid Print Processor.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, L"invalid", 1, NULL, 0,
&cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns
TRUE!\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
+ ok(cbNeeded > 0, "cbNeeded is 0!\n");
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // Now get the required buffer size by supplying all information. This needs to fail
with ERROR_INSUFFICIENT_BUFFER.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, L"winprint", 1, NULL, 0,
&cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns
TRUE!\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
+ ok(cbNeeded > 0, "cbNeeded is 0!\n");
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // Same error has to occur with a size to small.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, L"winprint", 1, NULL, 1,
&cbNeeded, &dwReturned), "EnumPrintProcessorDatatypesW returns
TRUE!\n");
+ ok(GetLastError() == ERROR_INSUFFICIENT_BUFFER, "EnumPrintersW returns error
%lu!\n", GetLastError());
+ ok(cbNeeded > 0, "cbNeeded is 0!\n");
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // Now provide the demanded size, but no buffer. Show that winprint returns a
different error than the same function in winspool.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, L"winprint", 1, NULL, cbNeeded,
&cbTemp, &dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
+ ok(cbTemp == cbNeeded, "cbTemp is %lu!\n", cbTemp);
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // This also has to fail the same way when no Print Processor was given at all.
+ SetLastError(0xDEADBEEF);
+ ok(!EnumPrintProcessorDatatypesW(NULL, NULL, 1, NULL, cbNeeded, &cbTemp,
&dwReturned), "EnumPrintProcessorDatatypesW returns TRUE!\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER, "EnumPrintProcessorDatatypesW
returns error %lu!\n", GetLastError());
+ ok(cbTemp == cbNeeded, "cbTemp is %lu!\n", cbTemp);
+ ok(dwReturned == 0, "dwReturned is %lu!\n", dwReturned);
+
+ // Finally use the function as intended and aim for success! Show that winprint
doesn't modify the error code at all.
+ pDatatypesInfo1 = HeapAlloc(GetProcessHeap(), 0, cbNeeded);
+ SetLastError(0xDEADBEEF);
+ ok(EnumPrintProcessorDatatypesW(NULL, L"winprint", 1,
(PBYTE)pDatatypesInfo1, cbNeeded, &cbNeeded, &dwReturned),
"EnumPrintProcessorDatatypesW returns FALSE!\n");
+ ok(GetLastError() == 0xDEADBEEF, "EnumPrintProcessorDatatypesW returns error
%lu!\n", GetLastError());
+ HeapFree(GetProcessHeap(), 0, pDatatypesInfo1);
+}
Propchange:
branches/colins-printing-for-freedom/rostests/apitests/winprint/EnumPrintProcessorDatatypesW.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: branches/colins-printing-for-freedom/rostests/apitests/winprint/testlist.c
URL:
http://svn.reactos.org/svn/reactos/branches/colins-printing-for-freedom/ros…
==============================================================================
--- branches/colins-printing-for-freedom/rostests/apitests/winprint/testlist.c (added)
+++
branches/colins-printing-for-freedom/rostests/apitests/winprint/testlist.c [iso-8859-1]
Fri Jun 5 18:16:51 2015
@@ -0,0 +1,32 @@
+/*
+ * PROJECT: ReactOS Standard Print Processor API Tests
+ * LICENSE: GNU GPLv2 or any later version as published by the Free Software
Foundation
+ * PURPOSE: Test list
+ * COPYRIGHT: Copyright 2015 Colin Finck <colin(a)reactos.org>
+ */
+
+/*
+ * These tests are developed and tested against the Windows Server 2003 counterpart of
winprint.
+ * While ReactOS implements the Standard Print Processor in a separate module
winprint.dll,
+ * Windows Server 2003 puts it into the Local Print Spooler localspl.dll.
+ *
+ * To test against Windows, simply run these tests under Windows Server 2003, but copy
its
+ * localspl.dll to winprint.dll in advance.
+ *
+ * winspool.drv also provides functions that go into winprint.dll, but as these tests
show,
+ * they behave slightly different in terms of error codes due to the involved RPC and
routing.
+ */
+
+#define __ROS_LONG64__
+
+#define STANDALONE
+#include <apitest.h>
+
+extern void func_EnumPrintProcessorDatatypesW(void);
+
+const struct test winetest_testlist[] =
+{
+ { "EnumPrintProcessorDatatypesW", func_EnumPrintProcessorDatatypesW },
+
+ { 0, 0 }
+};
Propchange: branches/colins-printing-for-freedom/rostests/apitests/winprint/testlist.c
------------------------------------------------------------------------------
svn:eol-style = native