1 /* 2 * PROJECT: ReactOS Print Spooler Service 3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+) 4 * PURPOSE: Functions related to Print Processors 5 * COPYRIGHT: Copyright 2015-2018 Colin Finck (colin@reactos.org) 6 */ 7 8 #include "precomp.h" 9 #include <marshalling/printprocessors.h> 10 11 DWORD 12 _RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName) 13 { 14 UNIMPLEMENTED; 15 return ERROR_INVALID_FUNCTION; 16 } 17 18 DWORD 19 _RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName) 20 { 21 UNIMPLEMENTED; 22 return ERROR_INVALID_FUNCTION; 23 } 24 25 DWORD 26 _RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) 27 { 28 DWORD dwErrorCode; 29 PBYTE pDatatypesAligned; 30 31 dwErrorCode = RpcImpersonateClient(NULL); 32 if (dwErrorCode != ERROR_SUCCESS) 33 { 34 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); 35 return dwErrorCode; 36 } 37 38 pDatatypesAligned = AlignRpcPtr(pDatatypes, &cbBuf); 39 40 if (EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypesAligned, cbBuf, pcbNeeded, pcReturned)) 41 { 42 // Replace absolute pointer addresses in the output by relative offsets. 43 MarshallDownStructuresArray(pDatatypesAligned, *pcReturned, DatatypesInfo1Marshalling.pInfo, DatatypesInfo1Marshalling.cbStructureSize, TRUE); 44 } 45 else 46 { 47 dwErrorCode = GetLastError(); 48 } 49 50 RpcRevertToSelf(); 51 UndoAlignRpcPtr(pDatatypes, pDatatypesAligned, cbBuf, pcbNeeded); 52 53 return dwErrorCode; 54 } 55 56 DWORD 57 _RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) 58 { 59 DWORD dwErrorCode; 60 PBYTE pPrintProcessorInfoAligned; 61 62 dwErrorCode = RpcImpersonateClient(NULL); 63 if (dwErrorCode != ERROR_SUCCESS) 64 { 65 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); 66 return dwErrorCode; 67 } 68 69 pPrintProcessorInfoAligned = AlignRpcPtr(pPrintProcessorInfo, &cbBuf); 70 71 if (EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfoAligned, cbBuf, pcbNeeded, pcReturned)) 72 { 73 // Replace absolute pointer addresses in the output by relative offsets. 74 MarshallDownStructuresArray(pPrintProcessorInfoAligned, *pcReturned, PrintProcessorInfo1Marshalling.pInfo, PrintProcessorInfo1Marshalling.cbStructureSize, TRUE); 75 } 76 else 77 { 78 dwErrorCode = GetLastError(); 79 } 80 81 RpcRevertToSelf(); 82 UndoAlignRpcPtr(pPrintProcessorInfo, pPrintProcessorInfoAligned, cbBuf, pcbNeeded); 83 84 return dwErrorCode; 85 } 86 87 DWORD 88 _RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorDirectory, DWORD cbBuf, DWORD* pcbNeeded) 89 { 90 DWORD dwErrorCode; 91 92 dwErrorCode = RpcImpersonateClient(NULL); 93 if (dwErrorCode != ERROR_SUCCESS) 94 { 95 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); 96 return dwErrorCode; 97 } 98 99 if (!GetPrintProcessorDirectoryW(pName, pEnvironment, Level, pPrintProcessorDirectory, cbBuf, pcbNeeded)) 100 dwErrorCode = GetLastError(); 101 102 RpcRevertToSelf(); 103 return dwErrorCode; 104 } 105