ReactOS  0.4.14-dev-293-g2b39b42
printprocessors.c
Go to the documentation of this file.
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"
10 
11 DWORD
12 _RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName)
13 {
16 }
17 
18 DWORD
19 _RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName)
20 {
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.
44  }
45  else
46  {
47  dwErrorCode = GetLastError();
48  }
49 
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.
75  }
76  else
77  {
78  dwErrorCode = GetLastError();
79  }
80 
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 }
DWORD cbStructureSize
Definition: marshalling.h:25
MARSHALLING_INFO pInfo[]
Definition: marshalling.h:26
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
static const MARSHALLING DatatypesInfo1Marshalling
smooth NULL
Definition: ftsmooth.c:416
DWORD _RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPathName, WCHAR *pPrintProcessorName)
DWORD _RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR *pPrintProcessorName, DWORD Level, BYTE *pDatatypes, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1460
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GetPrintProcessorDirectoryW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
unsigned char BYTE
Definition: mem.h:68
DWORD _RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorInfo, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
DWORD _RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPrintProcessorName)
static const MARSHALLING PrintProcessorInfo1Marshalling
#define ERR(fmt,...)
Definition: debug.h:109
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:236
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1053
BOOL WINAPI EnumPrintProcessorDatatypesW(PWSTR pName, PWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
#define UNIMPLEMENTED
Definition: debug.h:114
DWORD _RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorDirectory, DWORD cbBuf, DWORD *pcbNeeded)
BYTE * PBYTE
Definition: pedump.c:66
BOOL WINAPI MarshallDownStructuresArray(PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:91
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
BOOL WINAPI EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)