diff --git a/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt b/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt index 9bbe4bef852..4eb05e76dd1 100644 --- a/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt +++ b/reactos/win32ss/printing/base/spoolsv/CMakeLists.txt @@ -6,6 +6,8 @@ list(APPEND SOURCE init.c jobs.c main.c + monitors.c + ports.c printers.c printprocessors.c precomp.h diff --git a/reactos/win32ss/printing/base/spoolsv/monitors.c b/reactos/win32ss/printing/base/spoolsv/monitors.c new file mode 100644 index 00000000000..28af0f8ae66 --- /dev/null +++ b/reactos/win32ss/printing/base/spoolsv/monitors.c @@ -0,0 +1,27 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Print Monitors + * COPYRIGHT: Copyright 2015 Colin Finck + */ + +#include "precomp.h" + +DWORD +_RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pMonitor, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + EnumMonitorsW(pName, Level, pMonitor, cbBuf, pcbNeeded, pcReturned); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} diff --git a/reactos/win32ss/printing/base/spoolsv/ports.c b/reactos/win32ss/printing/base/spoolsv/ports.c new file mode 100644 index 00000000000..befab8dbce9 --- /dev/null +++ b/reactos/win32ss/printing/base/spoolsv/ports.c @@ -0,0 +1,27 @@ +/* + * PROJECT: ReactOS Print Spooler Service + * LICENSE: GNU GPLv2 or any later version as published by the Free Software Foundation + * PURPOSE: Functions related to Ports + * COPYRIGHT: Copyright 2015 Colin Finck + */ + +#include "precomp.h" + +DWORD +_RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE* pPort, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + EnumPortsW(pName, Level, pPort, cbBuf, pcbNeeded, pcReturned); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} diff --git a/reactos/win32ss/printing/base/spoolsv/printers.c b/reactos/win32ss/printing/base/spoolsv/printers.c index ff1ec6e7d3b..bd50d2ba833 100644 --- a/reactos/win32ss/printing/base/spoolsv/printers.c +++ b/reactos/win32ss/printing/base/spoolsv/printers.c @@ -7,6 +7,65 @@ #include "precomp.h" +DWORD +_RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + if (ClosePrinter(*phPrinter)) + *phPrinter = NULL; + + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcEndDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + EndDocPrinter(hPrinter); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcEndPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + EndPagePrinter(hPrinter); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + DWORD _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { @@ -49,3 +108,79 @@ _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* phPrinter RpcRevertToSelf(); return dwErrorCode; } + +DWORD +_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcNoBytesRead) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + ReadPrinter(hPrinter, pBuf, cbBuf, pcNoBytesRead); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER* pDocInfoContainer, DWORD* pJobId) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + *pJobId = StartDocPrinterW(hPrinter, pDocInfoContainer->Level, (PBYTE)pDocInfoContainer->DocInfo.pDocInfo1); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcStartPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + StartPagePrinter(hPrinter); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} + +DWORD +_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten) +{ + DWORD dwErrorCode; + + dwErrorCode = RpcImpersonateClient(NULL); + if (dwErrorCode != ERROR_SUCCESS) + { + ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); + return dwErrorCode; + } + + WritePrinter(hPrinter, pBuf, cbBuf, pcWritten); + dwErrorCode = GetLastError(); + + RpcRevertToSelf(); + return dwErrorCode; +} diff --git a/reactos/win32ss/printing/base/spoolsv/rpcstubs.c b/reactos/win32ss/printing/base/spoolsv/rpcstubs.c index 209f529d4e3..e4a797c5abf 100644 --- a/reactos/win32ss/printing/base/spoolsv/rpcstubs.c +++ b/reactos/win32ss/printing/base/spoolsv/rpcstubs.c @@ -70,34 +70,6 @@ _RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriv return ERROR_INVALID_FUNCTION; } -DWORD -_RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER *pDocInfoContainer, DWORD *pJobId) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcStartPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcWritten) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEndPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - DWORD _RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) { @@ -105,20 +77,6 @@ _RpcAbortPrinter(WINSPOOL_PRINTER_HANDLE hPrinter) return ERROR_INVALID_FUNCTION; } -DWORD -_RpcReadPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE *pBuf, DWORD cbBuf, DWORD *pcNoBytesRead) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEndDocPrinter(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) { @@ -140,13 +98,6 @@ _RpcWaitForPrinterChange(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Flags, DWORD *p return ERROR_INVALID_FUNCTION; } -DWORD -_RpcClosePrinter(WINSPOOL_PRINTER_HANDLE *phPrinter) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - DWORD _RpcAddForm(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_FORM_CONTAINER *pFormInfoContainer) { @@ -182,20 +133,6 @@ _RpcEnumForms(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD Level, BYTE *pForm, DWORD return ERROR_INVALID_FUNCTION; } -DWORD -_RpcEnumPorts(WINSPOOL_HANDLE pName, DWORD Level, BYTE *pPort, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - -DWORD -_RpcEnumMonitors(WINSPOOL_HANDLE pName, DWORD Level, BYTE *pMonitor, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned) -{ - UNIMPLEMENTED; - return ERROR_INVALID_FUNCTION; -} - DWORD _RpcAddPort(WINSPOOL_HANDLE pName, ULONG_PTR hWnd, WCHAR *pMonitorName) {