[SPOOLSV, WINSPOOL]
authorColin Finck <colin@reactos.org>
Fri, 17 Jul 2015 10:57:10 +0000 (10:57 +0000)
committerColin Finck <colin@reactos.org>
Fri, 17 Jul 2015 10:57:10 +0000 (10:57 +0000)
- Add RPC calls, proper marshalling and exports for all implemented functions.
- Move the spoolsv stubs into categories, so that future implementations in winspool, spoolsv, spoolss and localspl can follow a consistent naming scheme.

svn path=/branches/colins-printing-for-freedom/; revision=68408

19 files changed:
reactos/win32ss/printing/base/spoolsv/CMakeLists.txt
reactos/win32ss/printing/base/spoolsv/forms.c [new file with mode: 0644]
reactos/win32ss/printing/base/spoolsv/monitors.c
reactos/win32ss/printing/base/spoolsv/notifications.c [new file with mode: 0644]
reactos/win32ss/printing/base/spoolsv/ports.c
reactos/win32ss/printing/base/spoolsv/printerdata.c [new file with mode: 0644]
reactos/win32ss/printing/base/spoolsv/printerdrivers.c [new file with mode: 0644]
reactos/win32ss/printing/base/spoolsv/printers.c
reactos/win32ss/printing/base/spoolsv/printprocessors.c
reactos/win32ss/printing/base/spoolsv/printproviders.c [new file with mode: 0644]
reactos/win32ss/printing/base/spoolsv/rpcstubs.c
reactos/win32ss/printing/base/spoolsv/xcv.c [new file with mode: 0644]
reactos/win32ss/printing/base/winspool/CMakeLists.txt
reactos/win32ss/printing/base/winspool/jobs.c
reactos/win32ss/printing/base/winspool/monitors.c [new file with mode: 0644]
reactos/win32ss/printing/base/winspool/ports.c [new file with mode: 0644]
reactos/win32ss/printing/base/winspool/printers.c
reactos/win32ss/printing/base/winspool/printprocessors.c
reactos/win32ss/printing/base/winspool/winspool.spec

index 4eb05e7..9f26127 100644 (file)
@@ -3,16 +3,22 @@ include_directories(${REACTOS_SOURCE_DIR}/include/reactos/idl)
 add_rpc_files(server ${REACTOS_SOURCE_DIR}/include/reactos/idl/winspool.idl)
 
 list(APPEND SOURCE
+    forms.c
     init.c
     jobs.c
     main.c
     monitors.c
+    notifications.c
     ports.c
+    precomp.h
+    printerdata.c
+    printerdrivers.c
     printers.c
     printprocessors.c
-    precomp.h
+    printproviders.c
     rpcserver.c
     rpcstubs.c
+    xcv.c
     ${CMAKE_CURRENT_BINARY_DIR}/winspool_s.c)
 
 add_executable(spoolsv ${SOURCE} spoolsv.rc)
diff --git a/reactos/win32ss/printing/base/spoolsv/forms.c b/reactos/win32ss/printing/base/spoolsv/forms.c
new file mode 100644 (file)
index 0000000..45950e7
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Forms
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER* pFormInfoContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeleteForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pForm, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName, DWORD Level, BYTE* pForm, DWORD cbBuf, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcSetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pFormName, WINSPOOL_FORM_CONTAINER* pFormInfoContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
index 28af0f8..1f2bc72 100644 (file)
@@ -7,10 +7,41 @@
 
 #include "precomp.h"
 
+static void
+_MarshallDownMonitorInfo(PBYTE pMonitorInfo, DWORD Level)
+{
+    PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)pMonitorInfo;        // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W
+
+    // Replace absolute pointer addresses in the output by relative offsets.
+    pMonitorInfo2->pName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pName - (ULONG_PTR)pMonitorInfo2);
+
+    if (Level == 2)
+    {
+        pMonitorInfo2->pDLLName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pDLLName - (ULONG_PTR)pMonitorInfo2);
+        pMonitorInfo2->pEnvironment = (PWSTR)((ULONG_PTR)pMonitorInfo2->pEnvironment - (ULONG_PTR)pMonitorInfo2);
+    }
+}
+
+DWORD
+_RpcAddMonitor(WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER* pMonitorContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeleteMonitor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pMonitorName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
 _RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
 {
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pMonitor;
 
     dwErrorCode = RpcImpersonateClient(NULL);
     if (dwErrorCode != ERROR_SUCCESS)
@@ -22,6 +53,20 @@ _RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf
     EnumMonitorsW(pName, Level, pMonitor, cbBuf, pcbNeeded, pcReturned);
     dwErrorCode = GetLastError();
 
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace absolute pointer addresses in the output by relative offsets.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallDownMonitorInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(MONITOR_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(MONITOR_INFO_2W);
+        }
+    }
+
     RpcRevertToSelf();
     return dwErrorCode;
 }
diff --git a/reactos/win32ss/printing/base/spoolsv/notifications.c b/reactos/win32ss/printing/base/spoolsv/notifications.c
new file mode 100644 (file)
index 0000000..8b99825
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Printer Configuration Data
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcClientFindFirstPrinterChangeNotification()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcFindClosePrinterChangeNotification()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcFindNextPrinterChangeNotification()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRemoteFindFirstPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR* pszLocalMachine, DWORD dwPrinterLocal, DWORD cbBuffer, BYTE* pBuffer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRemoteFindFirstPrinterChangeNotificationEx(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR* pszLocalMachine, DWORD dwPrinterLocal, WINSPOOL_V2_NOTIFY_OPTIONS* pOptions)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcReplyClosePrinter(WINSPOOL_PRINTER_HANDLE* phNotify)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcReplyOpenPrinter(WINSPOOL_HANDLE pMachine, WINSPOOL_PRINTER_HANDLE* phPrinterNotify, DWORD dwPrinterRemote, DWORD dwType, DWORD cbBuffer, BYTE* pBuffer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRouterFindFirstPrinterChangeNotificationOld()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRouterRefreshPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwColor, WINSPOOL_V2_NOTIFY_OPTIONS* pOptions, WINSPOOL_V2_NOTIFY_INFO** ppInfo)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRouterReplyPrinter(WINSPOOL_PRINTER_HANDLE hNotify, DWORD fdwFlags, DWORD cbBuffer, BYTE* pBuffer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcRouterReplyPrinterEx(WINSPOOL_PRINTER_HANDLE hNotify, DWORD dwColor, DWORD fdwFlags, DWORD* pdwResult, DWORD dwReplyType, WINSPOOL_V2_UREPLY_PRINTER Reply)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcWaitForPrinterChange(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Flags, DWORD* pFlags)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
index befab8d..cb3d993 100644 (file)
@@ -7,10 +7,55 @@
 
 #include "precomp.h"
 
+static void
+_MarshallDownPortInfo(PBYTE pPortInfo, DWORD Level)
+{
+    PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)pPortInfo;         // PORT_INFO_1W is a subset of PORT_INFO_2W
+
+    // Replace absolute pointer addresses in the output by relative offsets.
+    pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName - (ULONG_PTR)pPortInfo2);
+
+    if (Level == 2)
+    {
+        pPortInfo2->pDescription = (PWSTR)((ULONG_PTR)pPortInfo2->pDescription - (ULONG_PTR)pPortInfo2);
+        pPortInfo2->pMonitorName = (PWSTR)((ULONG_PTR)pPortInfo2->pMonitorName - (ULONG_PTR)pPortInfo2);
+    }
+}
+
+DWORD
+_RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pMonitorName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcAddPortEx(WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER* pPortContainer, WINSPOOL_PORT_VAR_CONTAINER* pPortVarContainer, WCHAR* pMonitorName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcConfigurePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pPortName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR* pPortName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
 _RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pPort, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
 {
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pPort;
 
     dwErrorCode = RpcImpersonateClient(NULL);
     if (dwErrorCode != ERROR_SUCCESS)
@@ -22,6 +67,27 @@ _RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pPort, DWORD cbBuf, DWOR
     EnumPortsW(pName, Level, pPort, cbBuf, pcbNeeded, pcReturned);
     dwErrorCode = GetLastError();
 
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace absolute pointer addresses in the output by relative offsets.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallDownPortInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(PORT_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(PORT_INFO_2W);
+        }
+    }
+
     RpcRevertToSelf();
     return dwErrorCode;
 }
+
+DWORD
+_RpcSetPort(WINSPOOL_HANDLE pName, WCHAR* pPortName, WINSPOOL_PORT_CONTAINER* pPortContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
diff --git a/reactos/win32ss/printing/base/spoolsv/printerdata.c b/reactos/win32ss/printing/base/spoolsv/printerdata.c
new file mode 100644 (file)
index 0000000..1ffb0af
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Printer Configuration Data
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcDeletePrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcEnumPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwIndex, WCHAR* pValueName, DWORD cbValueName, DWORD* pcbValueName, DWORD* pType, BYTE* pData, DWORD cbData, DWORD* pcbData)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcEnumPrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, WCHAR* pSubkey, DWORD cbSubkey, DWORD* pcbSubkey)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcEnumPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, BYTE* pEnumValues, DWORD cbEnumValues, DWORD* pcbEnumValues, DWORD* pnEnumValues)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName, DWORD* pType, BYTE* pData, DWORD nSize, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName, DWORD* pType, BYTE* pData, DWORD nSize, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcSetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pValueName, DWORD Type, BYTE* pData, DWORD cbData)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcSetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pKeyName, const WCHAR* pValueName, DWORD Type, BYTE* pData, DWORD cbData)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
diff --git a/reactos/win32ss/printing/base/spoolsv/printerdrivers.c b/reactos/win32ss/printing/base/spoolsv/printerdrivers.c
new file mode 100644 (file)
index 0000000..a56f0db
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Printer Drivers
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer, DWORD dwFileCopyFlags)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDrivers, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD* pdwServerMaxVersion, DWORD* pdwServerMinVersion)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDriverDirectory, DWORD cbBuf, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
index bd50d2b..fb20f04 100644 (file)
@@ -7,8 +7,68 @@
 
 #include "precomp.h"
 
+static void
+_MarshallDownPrinterInfo(PBYTE pPrinterInfo, DWORD Level)
+{
+    PPRINTER_INFO_1W pPrinterInfo1;
+    PPRINTER_INFO_2W pPrinterInfo2;
+
+    // Replace absolute pointer addresses in the output by relative offsets.
+    if (Level == 1)
+    {
+        pPrinterInfo1 = (PPRINTER_INFO_1W)pPrinterInfo;
+
+        pPrinterInfo1->pName = (PWSTR)((ULONG_PTR)pPrinterInfo1->pName - (ULONG_PTR)pPrinterInfo1);
+        pPrinterInfo1->pDescription = (PWSTR)((ULONG_PTR)pPrinterInfo1->pDescription - (ULONG_PTR)pPrinterInfo1);
+        pPrinterInfo1->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo1->pComment - (ULONG_PTR)pPrinterInfo1);
+    }
+    else if (Level == 2)
+    {
+        pPrinterInfo2 = (PPRINTER_INFO_2W)pPrinterInfo;
+
+        pPrinterInfo2->pPrinterName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrinterName - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pShareName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pShareName - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pPortName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPortName - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDriverName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDriverName - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo2->pComment - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pLocation = (PWSTR)((ULONG_PTR)pPrinterInfo2->pLocation - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDevMode = (PDEVMODEW)((ULONG_PTR)pPrinterInfo2->pDevMode - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pSepFile = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSepFile - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pPrintProcessor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrintProcessor - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDatatype = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDatatype - (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pParameters = (PWSTR)((ULONG_PTR)pPrinterInfo2->pParameters - (ULONG_PTR)pPrinterInfo2);
+
+        if (pPrinterInfo2->pServerName)
+            pPrinterInfo2->pServerName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pServerName - (ULONG_PTR)pPrinterInfo2);
+
+        if (pPrinterInfo2->pSecurityDescriptor)
+            pPrinterInfo2->pSecurityDescriptor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSecurityDescriptor - (ULONG_PTR)pPrinterInfo2);
+    }
+}
+
+DWORD
+_RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcAddPrinter(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, WINSPOOL_PRINTER_HANDLE* pHandle)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcAddPrinterEx(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, WINSPOOL_SPLCLIENT_CONTAINER* pClientInfo, WINSPOOL_PRINTER_HANDLE* pHandle)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
-_RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter)
+_RpcClosePrinter(WINSPOOL_PRINTER_HANDLEphPrinter)
 {
     DWORD dwErrorCode;
 
@@ -28,6 +88,13 @@ _RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter)
     return dwErrorCode;
 }
 
+DWORD
+_RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
 _RpcEndDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
 {
@@ -70,6 +137,8 @@ DWORD
 _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
 {
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pPrinterEnum;
 
     dwErrorCode = RpcImpersonateClient(NULL);
     if (dwErrorCode != ERROR_SUCCESS)
@@ -81,10 +150,38 @@ _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterE
     EnumPrintersW(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
     dwErrorCode = GetLastError();
 
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace absolute pointer addresses in the output by relative offsets.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallDownPrinterInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(PRINTER_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(PRINTER_INFO_2W);
+        }
+    }
+
     RpcRevertToSelf();
     return dwErrorCode;
 }
 
+DWORD
+_RpcFlushPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcWritten, DWORD cSleep)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcGetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE* pPrinter, DWORD cbBuf, DWORD* pcbNeeded)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
 _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* phPrinter, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, DWORD AccessRequired)
 {
@@ -110,7 +207,14 @@ _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* phPrinter
 }
 
 DWORD
-_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcNoBytesRead)
+_RpcOpenPrinterEx(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* pHandle, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, DWORD AccessRequired, WINSPOOL_SPLCLIENT_CONTAINER* pClientInfo)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcNoBytesRead)
 {
     DWORD dwErrorCode;
 
@@ -128,6 +232,34 @@ _RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD
     return dwErrorCode;
 }
 
+DWORD
+_RpcResetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcResetPrinterEx()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcSeekPrinter()
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcSetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_PRINTER_CONTAINER* pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, WINSPOOL_SECURITY_CONTAINER* pSecurityContainer, DWORD Command)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
 _RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER* pDocInfoContainer, DWORD* pJobId)
 {
@@ -167,7 +299,7 @@ _RpcStartPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
 }
 
 DWORD
-_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten)
+_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcWritten)
 {
     DWORD dwErrorCode;
 
index 173f7f4..ef224e5 100644 (file)
@@ -7,17 +7,40 @@
 
 #include "precomp.h"
 
+static void
+_MarshallDownDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1)
+{
+    // Replace absolute pointer addresses in the output by relative offsets.
+    pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName - (ULONG_PTR)pDatatypesInfo1);
+}
+
+static void
+_MarshallDownPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1)
+{
+    // Replace absolute pointer addresses in the output by relative offsets.
+    pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName - (ULONG_PTR)pPrintProcessorInfo1);
+}
+
+DWORD
+_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
 DWORD
-_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPathName, WCHAR *pPrintProcessorName)
+_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
 }
 
 DWORD
-_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR *pPrintProcessorName, DWORD Level, BYTE *pDatatypes, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
+_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
 {
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pDatatypes;
 
     dwErrorCode = RpcImpersonateClient(NULL);
     if (dwErrorCode != ERROR_SUCCESS)
@@ -29,14 +52,26 @@ _RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR *pPrintProcessorNam
     EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
     dwErrorCode = GetLastError();
 
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace absolute pointer addresses in the output by relative offsets.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallDownDatatypesInfo((PDATATYPES_INFO_1W)p);
+            p += sizeof(DATATYPES_INFO_1W);
+        }
+    }
+
     RpcRevertToSelf();
     return dwErrorCode;
 }
 
 DWORD
-_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorInfo, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
+_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)
@@ -48,12 +83,22 @@ _RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level,
     EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned);
     dwErrorCode = GetLastError();
 
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace absolute pointer addresses in the output by relative offsets.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallDownPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p);
+            p += sizeof(PRINTPROCESSOR_INFO_1W);
+        }
+    }
+
     RpcRevertToSelf();
     return dwErrorCode;
 }
 
 DWORD
-_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorDirectory, DWORD cbBuf, DWORD *pcbNeeded)
+_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorDirectory, DWORD cbBuf, DWORD* pcbNeeded)
 {
     DWORD dwErrorCode;
 
diff --git a/reactos/win32ss/printing/base/spoolsv/printproviders.c b/reactos/win32ss/printing/base/spoolsv/printproviders.c
new file mode 100644 (file)
index 0000000..eafd50b
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Print Providers
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcAddPrintProvidor(WINSPOOL_HANDLE pName, WINSPOOL_PROVIDOR_CONTAINER* pProvidorContainer)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
+
+DWORD
+_RpcDeletePrintProvidor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProviderName)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
index e4a797c..857e78f 100644 (file)
 #include "precomp.h"
 
 DWORD
-_RpcAddPrinter(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, WINSPOOL_PRINTER_HANDLE *pHandle)
+_RpcCreatePrinterIC(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_GDI_HANDLE* pHandle, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
 }
 
 DWORD
-_RpcDeletePrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
+_RpcPlayGdiScriptOnPrinterIC(WINSPOOL_GDI_HANDLE hPrinterIC, BYTE* pIn, DWORD cIn, BYTE* pOut, DWORD cOut, DWORD ul)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
 }
 
 DWORD
-_RpcSetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, DWORD Command)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pPrinter, DWORD cbBuf, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDrivers, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDriverDirectory, DWORD cbBuf, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName, DWORD *pType, BYTE *pData, DWORD nSize, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcSetPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName, DWORD Type, BYTE *pData, DWORD cbData)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcWaitForPrinterChange(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Flags, DWORD *pFlags)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeleteForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcSetForm(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pFormName, WINSPOOL_FORM_CONTAINER *pFormInfoContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pForm, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pMonitorName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcConfigurePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pPortName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcCreatePrinterIC(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_GDI_HANDLE *pHandle, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcPlayGdiScriptOnPrinterIC(WINSPOOL_GDI_HANDLE hPrinterIC, BYTE *pIn, DWORD cIn, BYTE *pOut, DWORD cOut, DWORD ul)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrinterIC(WINSPOOL_GDI_HANDLE *phPrinterIC)
+_RpcDeletePrinterIC(WINSPOOL_GDI_HANDLE* phPrinterIC)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
@@ -190,147 +43,7 @@ _RpcDeletePrinterConnection(WINSPOOL_HANDLE pName)
 }
 
 DWORD
-_RpcPrinterMessageBox(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Error, ULONG_PTR hWnd, WCHAR *pText, WCHAR *pCaption, DWORD dwType)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddMonitor(WINSPOOL_HANDLE pName, WINSPOOL_MONITOR_CONTAINER *pMonitorContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeleteMonitor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pMonitorName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPrintProcessorName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPrintProvidor(WINSPOOL_HANDLE pName, WINSPOOL_PROVIDOR_CONTAINER *pProvidorContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrintProvidor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPrintProviderName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcResetPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pDatatype, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD *pdwServerMaxVersion, DWORD *pdwServerMinVersion)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcClientFindFirstPrinterChangeNotification()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcFindNextPrinterChangeNotification()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcFindClosePrinterChangeNotification()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRouterFindFirstPrinterChangeNotificationOld()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcReplyOpenPrinter(WINSPOOL_HANDLE pMachine, WINSPOOL_PRINTER_HANDLE *phPrinterNotify, DWORD dwPrinterRemote, DWORD dwType, DWORD cbBuffer, BYTE *pBuffer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRouterReplyPrinter(WINSPOOL_PRINTER_HANDLE hNotify, DWORD fdwFlags, DWORD cbBuffer, BYTE *pBuffer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcReplyClosePrinter(WINSPOOL_PRINTER_HANDLE *phNotify)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPortEx(WINSPOOL_HANDLE pName, WINSPOOL_PORT_CONTAINER *pPortContainer, WINSPOOL_PORT_VAR_CONTAINER *pPortVarContainer, WCHAR *pMonitorName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRemoteFindFirstPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR *pszLocalMachine, DWORD dwPrinterLocal, DWORD cbBuffer, BYTE *pBuffer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcResetPrinterEx()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRemoteFindFirstPrinterChangeNotificationEx(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD fdwFlags, DWORD fdwOptions, WCHAR *pszLocalMachine, DWORD dwPrinterLocal, WINSPOOL_V2_NOTIFY_OPTIONS *pOptions)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRouterReplyPrinterEx(WINSPOOL_PRINTER_HANDLE hNotify, DWORD dwColor, DWORD fdwFlags, DWORD *pdwResult, DWORD dwReplyType, WINSPOOL_V2_UREPLY_PRINTER Reply)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcRouterRefreshPrinterChangeNotification(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwColor, WINSPOOL_V2_NOTIFY_OPTIONS *pOptions, WINSPOOL_V2_NOTIFY_INFO **ppInfo)
+_RpcPrinterMessageBox(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Error, ULONG_PTR hWnd, WCHAR* pText, WCHAR* pCaption, DWORD dwType)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
@@ -343,41 +56,6 @@ _RpcSetAllocFailCount()
     return ERROR_INVALID_FUNCTION;
 }
 
-DWORD
-_RpcOpenPrinterEx(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE *pHandle, WCHAR *pDatatype, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, DWORD AccessRequired, WINSPOOL_SPLCLIENT_CONTAINER *pClientInfo)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPrinterEx(WINSPOOL_HANDLE pName, WINSPOOL_PRINTER_CONTAINER *pPrinterContainer, WINSPOOL_DEVMODE_CONTAINER *pDevModeContainer, WINSPOOL_SECURITY_CONTAINER *pSecurityContainer, WINSPOOL_SPLCLIENT_CONTAINER *pClientInfo, WINSPOOL_PRINTER_HANDLE *pHandle)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcSetPort(WINSPOOL_HANDLE pName, WCHAR *pPortName, WINSPOOL_PORT_CONTAINER *pPortContainer)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumPrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwIndex, WCHAR *pValueName, DWORD cbValueName, DWORD *pcbValueName, DWORD *pType, BYTE *pData, DWORD cbData, DWORD *pcbData)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrinterData(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pValueName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
 DWORD
 _RpcClusterSplOpen()
 {
@@ -400,91 +78,21 @@ _RpcClusterSplIsAlive()
 }
 
 DWORD
-_RpcSetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName, DWORD Type, BYTE *pData, DWORD cbData)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcGetPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName, DWORD *pType, BYTE *pData, DWORD nSize, DWORD *pcbNeeded)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumPrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, BYTE *pEnumValues, DWORD cbEnumValues, DWORD *pcbEnumValues, DWORD *pnEnumValues)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumPrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, WCHAR *pSubkey, DWORD cbSubkey, DWORD *pcbSubkey)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrinterDataEx(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName, const WCHAR *pValueName)
+_RpcAddPerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR* pPrinterName, const WCHAR* pPrintServer, const WCHAR* pProvider)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
 }
 
 DWORD
-_RpcDeletePrinterKey(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pKeyName)
+_RpcDeletePerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR* pPrinterName)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
 }
 
 DWORD
-_RpcSeekPrinter()
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR *pPrinterName, const WCHAR *pPrintServer, const WCHAR *pProvider)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcDeletePerMachineConnection(WINSPOOL_HANDLE pServer, const WCHAR *pPrinterName)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcEnumPerMachineConnections(WINSPOOL_HANDLE pServer, BYTE *pPrinterEnum, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcXcvData(WINSPOOL_PRINTER_HANDLE hXcv, const WCHAR *pszDataName, BYTE *pInputData, DWORD cbInputData, BYTE *pOutputData, DWORD cbOutputData, DWORD *pcbOutputNeeded, DWORD *pdwStatus)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer, DWORD dwFileCopyFlags)
+_RpcEnumPerMachineConnections(WINSPOOL_HANDLE pServer, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
@@ -519,14 +127,7 @@ _RpcCloseSpoolFileHandle()
 }
 
 DWORD
-_RpcFlushPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten, DWORD cSleep)
-{
-    UNIMPLEMENTED;
-    return ERROR_INVALID_FUNCTION;
-}
-
-DWORD
-_RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR *pAction, WINSPOOL_BIDI_REQUEST_CONTAINER *pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER **ppRespData)
+_RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pAction, WINSPOOL_BIDI_REQUEST_CONTAINER* pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData)
 {
     UNIMPLEMENTED;
     return ERROR_INVALID_FUNCTION;
diff --git a/reactos/win32ss/printing/base/spoolsv/xcv.c b/reactos/win32ss/printing/base/spoolsv/xcv.c
new file mode 100644 (file)
index 0000000..e02f1bd
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * PROJECT:     ReactOS Print Spooler Service
+ * LICENSE:     GNU GPLv2 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Xcv* functions
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+DWORD
+_RpcXcvData(WINSPOOL_PRINTER_HANDLE hXcv, const WCHAR* pszDataName, BYTE* pInputData, DWORD cbInputData, BYTE* pOutputData, DWORD cbOutputData, DWORD* pcbOutputNeeded, DWORD* pdwStatus)
+{
+    UNIMPLEMENTED;
+    return ERROR_INVALID_FUNCTION;
+}
index 4a35782..3f9036c 100644 (file)
@@ -6,6 +6,8 @@ spec2def(winspool.drv winspool.spec ADD_IMPORTLIB)
 list(APPEND SOURCE
     jobs.c
     main.c
+    monitors.c
+    ports.c
     precomp.h
     printers.c
     printprocessors.c
index bc6dfa0..f5553f6 100644 (file)
@@ -13,7 +13,7 @@ _MarshallUpJobInfo(PBYTE pJobInfo, DWORD Level)
     PJOB_INFO_1W pJobInfo1;
     PJOB_INFO_2W pJobInfo2;
 
-    // Replace absolute pointer addresses in the output by relative offsets.
+    // Replace relative offset addresses in the output by absolute pointers.
     if (Level == 1)
     {
         pJobInfo1 = (PJOB_INFO_1W)pJobInfo;
diff --git a/reactos/win32ss/printing/base/winspool/monitors.c b/reactos/win32ss/printing/base/winspool/monitors.c
new file mode 100644 (file)
index 0000000..91bb80e
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * PROJECT:     ReactOS Spooler API
+ * LICENSE:     GNU LGPL v2.1 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Print Monitors
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+static void
+_MarshallUpMonitorInfo(PBYTE pMonitorInfo, DWORD Level)
+{
+    PMONITOR_INFO_2W pMonitorInfo2 = (PMONITOR_INFO_2W)pMonitorInfo;        // MONITOR_INFO_1W is a subset of MONITOR_INFO_2W
+
+    // Replace relative offset addresses in the output by absolute pointers.
+    pMonitorInfo2->pName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pName + (ULONG_PTR)pMonitorInfo2);
+
+    if (Level == 2)
+    {
+        pMonitorInfo2->pDLLName = (PWSTR)((ULONG_PTR)pMonitorInfo2->pDLLName + (ULONG_PTR)pMonitorInfo2);
+        pMonitorInfo2->pEnvironment = (PWSTR)((ULONG_PTR)pMonitorInfo2->pEnvironment + (ULONG_PTR)pMonitorInfo2);
+    }
+}
+
+BOOL WINAPI
+EnumMonitorsW(PWSTR pName, DWORD Level, PBYTE pMonitors, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
+{
+    DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pMonitors;
+
+    // Do the RPC call
+    RpcTryExcept
+    {
+        dwErrorCode = _RpcEnumMonitors(pName, Level, pMonitors, cbBuf, pcbNeeded, pcReturned);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        dwErrorCode = RpcExceptionCode();
+        ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode);
+    }
+    RpcEndExcept;
+
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace relative offset addresses in the output by absolute pointers.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallUpMonitorInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(MONITOR_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(MONITOR_INFO_2W);
+        }
+    }
+
+    SetLastError(dwErrorCode);
+    return (dwErrorCode == ERROR_SUCCESS);
+}
diff --git a/reactos/win32ss/printing/base/winspool/ports.c b/reactos/win32ss/printing/base/winspool/ports.c
new file mode 100644 (file)
index 0000000..07b5fcd
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * PROJECT:     ReactOS Spooler API
+ * LICENSE:     GNU LGPL v2.1 or any later version as published by the Free Software Foundation
+ * PURPOSE:     Functions related to Ports
+ * COPYRIGHT:   Copyright 2015 Colin Finck <colin@reactos.org>
+ */
+
+#include "precomp.h"
+
+static void
+_MarshallUpPortInfo(PBYTE pPortInfo, DWORD Level)
+{
+    PPORT_INFO_2W pPortInfo2 = (PPORT_INFO_2W)pPortInfo;         // PORT_INFO_1W is a subset of PORT_INFO_2W
+
+    // Replace relative offset addresses in the output by absolute pointers.
+    pPortInfo2->pPortName = (PWSTR)((ULONG_PTR)pPortInfo2->pPortName + (ULONG_PTR)pPortInfo2);
+
+    if (Level == 2)
+    {
+        pPortInfo2->pDescription = (PWSTR)((ULONG_PTR)pPortInfo2->pDescription + (ULONG_PTR)pPortInfo2);
+        pPortInfo2->pMonitorName = (PWSTR)((ULONG_PTR)pPortInfo2->pMonitorName + (ULONG_PTR)pPortInfo2);
+    }
+}
+
+BOOL WINAPI
+EnumPortsW(PWSTR pName, DWORD Level, PBYTE pPorts, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
+{
+    DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pPorts;
+
+    // Do the RPC call
+    RpcTryExcept
+    {
+        dwErrorCode = _RpcEnumPorts(pName, Level, pPorts, cbBuf, pcbNeeded, pcReturned);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        dwErrorCode = RpcExceptionCode();
+        ERR("_RpcEnumPorts failed with exception code %lu!\n", dwErrorCode);
+    }
+    RpcEndExcept;
+
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace relative offset addresses in the output by absolute pointers.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallUpPortInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(PORT_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(PORT_INFO_2W);
+        }
+    }
+
+    SetLastError(dwErrorCode);
+    return (dwErrorCode == ERROR_SUCCESS);
+}
index c4b95ea..c447778 100644 (file)
@@ -7,6 +7,45 @@
 
 #include "precomp.h"
 
+static void
+_MarshallUpPrinterInfo(PBYTE pPrinterInfo, DWORD Level)
+{
+    PPRINTER_INFO_1W pPrinterInfo1;
+    PPRINTER_INFO_2W pPrinterInfo2;
+
+    // Replace relative offset addresses in the output by absolute pointers.
+    if (Level == 1)
+    {
+        pPrinterInfo1 = (PPRINTER_INFO_1W)pPrinterInfo;
+
+        pPrinterInfo1->pName = (PWSTR)((ULONG_PTR)pPrinterInfo1->pName + (ULONG_PTR)pPrinterInfo1);
+        pPrinterInfo1->pDescription = (PWSTR)((ULONG_PTR)pPrinterInfo1->pDescription + (ULONG_PTR)pPrinterInfo1);
+        pPrinterInfo1->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo1->pComment + (ULONG_PTR)pPrinterInfo1);
+    }
+    else if (Level == 2)
+    {
+        pPrinterInfo2 = (PPRINTER_INFO_2W)pPrinterInfo;
+
+        pPrinterInfo2->pPrinterName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrinterName + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pShareName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pShareName + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pPortName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPortName + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDriverName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDriverName + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pComment = (PWSTR)((ULONG_PTR)pPrinterInfo2->pComment + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pLocation = (PWSTR)((ULONG_PTR)pPrinterInfo2->pLocation + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDevMode = (PDEVMODEW)((ULONG_PTR)pPrinterInfo2->pDevMode + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pSepFile = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSepFile + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pPrintProcessor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pPrintProcessor + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pDatatype = (PWSTR)((ULONG_PTR)pPrinterInfo2->pDatatype + (ULONG_PTR)pPrinterInfo2);
+        pPrinterInfo2->pParameters = (PWSTR)((ULONG_PTR)pPrinterInfo2->pParameters + (ULONG_PTR)pPrinterInfo2);
+
+        if (pPrinterInfo2->pServerName)
+            pPrinterInfo2->pServerName = (PWSTR)((ULONG_PTR)pPrinterInfo2->pServerName + (ULONG_PTR)pPrinterInfo2);
+
+        if (pPrinterInfo2->pSecurityDescriptor)
+            pPrinterInfo2->pSecurityDescriptor = (PWSTR)((ULONG_PTR)pPrinterInfo2->pSecurityDescriptor + (ULONG_PTR)pPrinterInfo2);
+    }
+}
+
 static DWORD
 _StartDocPrinterSpooled(PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1, PADDJOB_INFO_1W pAddJobInfo1)
 {
@@ -95,33 +134,6 @@ _StartDocPrinterWithRPC(PSPOOLER_HANDLE pHandle, PDOC_INFO_1W pDocInfo1)
     return dwErrorCode;
 }
 
-BOOL WINAPI
-EnumPrintersA(DWORD Flags, LPSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
-{
-    return FALSE;
-}
-
-BOOL WINAPI
-EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
-{
-    DWORD dwErrorCode;
-
-    // Do the RPC call
-    RpcTryExcept
-    {
-        dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
-    }
-    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
-    {
-        dwErrorCode = RpcExceptionCode();
-        ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode);
-    }
-    RpcEndExcept;
-
-    SetLastError(dwErrorCode);
-    return (dwErrorCode == ERROR_SUCCESS);
-}
-
 BOOL WINAPI
 ClosePrinter(HANDLE hPrinter)
 {
@@ -275,6 +287,49 @@ Cleanup:
     return (dwErrorCode == ERROR_SUCCESS);
 }
 
+BOOL WINAPI
+EnumPrintersA(DWORD Flags, PSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
+{
+    return FALSE;
+}
+
+BOOL WINAPI
+EnumPrintersW(DWORD Flags, PWSTR Name, DWORD Level, PBYTE pPrinterEnum, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
+{
+    DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pPrinterEnum;
+
+    // Do the RPC call
+    RpcTryExcept
+    {
+        dwErrorCode = _RpcEnumPrinters(Flags, Name, Level, pPrinterEnum, cbBuf, pcbNeeded, pcReturned);
+    }
+    RpcExcept(EXCEPTION_EXECUTE_HANDLER)
+    {
+        dwErrorCode = RpcExceptionCode();
+        ERR("_RpcEnumPrinters failed with exception code %lu!\n", dwErrorCode);
+    }
+    RpcEndExcept;
+
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace relative offset addresses in the output by absolute pointers.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallUpPrinterInfo(p, Level);
+
+            if (Level == 1)
+                p += sizeof(PRINTER_INFO_1W);
+            else if (Level == 2)
+                p += sizeof(PRINTER_INFO_2W);
+        }
+    }
+
+    SetLastError(dwErrorCode);
+    return (dwErrorCode == ERROR_SUCCESS);
+}
+
 BOOL WINAPI
 GetDefaultPrinterA(LPSTR pszBuffer, LPDWORD pcchBuffer)
 {
index 66b8336..5a5493c 100644 (file)
@@ -7,58 +7,94 @@
 
 #include "precomp.h"
 
+static void
+_MarshallUpDatatypesInfo(PDATATYPES_INFO_1W pDatatypesInfo1)
+{
+    // Replace relative offset addresses in the output by absolute pointers.
+    pDatatypesInfo1->pName = (PWSTR)((ULONG_PTR)pDatatypesInfo1->pName + (ULONG_PTR)pDatatypesInfo1);
+}
+
+static void
+_MarshallUpPrintProcessorInfo(PPRINTPROCESSOR_INFO_1W pPrintProcessorInfo1)
+{
+    // Replace relative offset addresses in the output by absolute pointers.
+    pPrintProcessorInfo1->pName = (PWSTR)((ULONG_PTR)pPrintProcessorInfo1->pName + (ULONG_PTR)pPrintProcessorInfo1);
+}
+
 BOOL WINAPI
-EnumPrintProcessorDatatypesA(LPSTR pName, LPSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
+EnumPrintProcessorDatatypesA(PSTR pName, LPSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 {
     return FALSE;
 }
 
 BOOL WINAPI
-EnumPrintProcessorDatatypesW(LPWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, LPBYTE pDatatypes, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
+EnumPrintProcessorDatatypesW(PWSTR pName, LPWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 {
-    BOOL bReturnValue = FALSE;
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pDatatypes;
 
     // Do the RPC call
     RpcTryExcept
     {
         dwErrorCode = _RpcEnumPrintProcessorDatatypes(pName, pPrintProcessorName, Level, pDatatypes, cbBuf, pcbNeeded, pcReturned);
-        SetLastError(dwErrorCode);
-        bReturnValue = (dwErrorCode == ERROR_SUCCESS);
     }
     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
     {
-        ERR("_RpcEnumPrintProcessorDatatypes failed with exception code %lu!\n", RpcExceptionCode());
+        dwErrorCode = RpcExceptionCode();
+        ERR("_RpcEnumPrintProcessorDatatypes failed with exception code %lu!\n", dwErrorCode);
     }
     RpcEndExcept;
 
-    return bReturnValue;
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace relative offset addresses in the output by absolute pointers.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallUpDatatypesInfo((PDATATYPES_INFO_1W)p);
+            p += sizeof(DATATYPES_INFO_1W);
+        }
+    }
+
+    SetLastError(dwErrorCode);
+    return (dwErrorCode == ERROR_SUCCESS);
 }
 
 BOOL WINAPI
-EnumPrintProcessorsW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
+EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
 {
-    BOOL bReturnValue = FALSE;
     DWORD dwErrorCode;
+    DWORD i;
+    PBYTE p = pPrintProcessorInfo;
 
     // Do the RPC call
     RpcTryExcept
     {
         dwErrorCode = _RpcEnumPrintProcessors(pName, pEnvironment, Level, pPrintProcessorInfo, cbBuf, pcbNeeded, pcReturned);
-        SetLastError(dwErrorCode);
-        bReturnValue = (dwErrorCode == ERROR_SUCCESS);
     }
     RpcExcept(EXCEPTION_EXECUTE_HANDLER)
     {
-        ERR("_RpcEnumPrintProcessors failed with exception code %lu!\n", RpcExceptionCode());
+        dwErrorCode = RpcExceptionCode();
+        ERR("_RpcEnumPrintProcessors failed with exception code %lu!\n", dwErrorCode);
     }
     RpcEndExcept;
 
-    return bReturnValue;
+    if (dwErrorCode == ERROR_SUCCESS)
+    {
+        // Replace relative offset addresses in the output by absolute pointers.
+        for (i = 0; i < *pcReturned; i++)
+        {
+            _MarshallUpPrintProcessorInfo((PPRINTPROCESSOR_INFO_1W)p);
+            p += sizeof(PRINTPROCESSOR_INFO_1W);
+        }
+    }
+
+    SetLastError(dwErrorCode);
+    return (dwErrorCode == ERROR_SUCCESS);
 }
 
 BOOL WINAPI
-GetPrintProcessorDirectoryW(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded)
+GetPrintProcessorDirectoryW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
 {
     BOOL bReturnValue = FALSE;
     DWORD dwErrorCode;
index 9f056aa..6ae26d4 100644 (file)
@@ -86,9 +86,9 @@
 185 stdcall EnumJobsA(long long long long ptr long ptr ptr)
 186 stdcall EnumJobsW(long long long long ptr long ptr ptr)
 187 stub EnumMonitorsA
-188 stub EnumMonitorsW
+188 stdcall EnumMonitorsW(wstr long ptr long ptr ptr)
 189 stub EnumPortsA
-190 stub EnumPortsW
+190 stdcall EnumPortsW(wstr long ptr long ptr ptr)
 191 stdcall EnumPrintProcessorDatatypesA(ptr ptr long ptr long ptr ptr)
 192 stdcall EnumPrintProcessorDatatypesW(ptr ptr long ptr long ptr ptr)
 193 stub EnumPrintProcessorsA