ReactOS 0.4.15-dev-7924-g5949c20
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
12_RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPathName, WCHAR* pPrintProcessorName)
13{
14 DWORD dwErrorCode;
15
16 dwErrorCode = RpcImpersonateClient(NULL);
17 if (dwErrorCode != ERROR_SUCCESS)
18 {
19 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
20 return dwErrorCode;
21 }
22
23 if (!AddPrintProcessorW(pName, pEnvironment, pPathName, pPrintProcessorName))
24 dwErrorCode = GetLastError();
25
27 return dwErrorCode;
28}
29
31_RpcDeletePrintProcessor(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pPrintProcessorName)
32{
33 DWORD dwErrorCode;
34
35 dwErrorCode = RpcImpersonateClient(NULL);
36 if (dwErrorCode != ERROR_SUCCESS)
37 {
38 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
39 return dwErrorCode;
40 }
41
42 if (!DeletePrintProcessorW(pName, pEnvironment, pPrintProcessorName))
43 dwErrorCode = GetLastError();
44
46 return dwErrorCode;
47}
48
50_RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR* pPrintProcessorName, DWORD Level, BYTE* pDatatypes, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
51{
52 DWORD dwErrorCode;
53 PBYTE pDatatypesAligned;
54
55 dwErrorCode = RpcImpersonateClient(NULL);
56 if (dwErrorCode != ERROR_SUCCESS)
57 {
58 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
59 return dwErrorCode;
60 }
61
62 pDatatypesAligned = AlignRpcPtr(pDatatypes, &cbBuf);
63
64 if (EnumPrintProcessorDatatypesW(pName, pPrintProcessorName, Level, pDatatypesAligned, cbBuf, pcbNeeded, pcReturned))
65 {
66 // Replace absolute pointer addresses in the output by relative offsets.
68 }
69 else
70 {
71 dwErrorCode = GetLastError();
72 }
73
75 UndoAlignRpcPtr(pDatatypes, pDatatypesAligned, cbBuf, pcbNeeded);
76
77 return dwErrorCode;
78}
79
81_RpcEnumPrintProcessors(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorInfo, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
82{
83 DWORD dwErrorCode;
84 PBYTE pPrintProcessorInfoAligned;
85
86 dwErrorCode = RpcImpersonateClient(NULL);
87 if (dwErrorCode != ERROR_SUCCESS)
88 {
89 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
90 return dwErrorCode;
91 }
92
93 pPrintProcessorInfoAligned = AlignRpcPtr(pPrintProcessorInfo, &cbBuf);
94
95 if (EnumPrintProcessorsW(pName, pEnvironment, Level, pPrintProcessorInfoAligned, cbBuf, pcbNeeded, pcReturned))
96 {
97 // Replace absolute pointer addresses in the output by relative offsets.
99 }
100 else
101 {
102 dwErrorCode = GetLastError();
103 }
104
106 UndoAlignRpcPtr(pPrintProcessorInfo, pPrintProcessorInfoAligned, cbBuf, pcbNeeded);
107
108 return dwErrorCode;
109}
110
111DWORD
112_RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pPrintProcessorDirectory, DWORD cbBuf, DWORD* pcbNeeded)
113{
114 DWORD dwErrorCode;
115
116 dwErrorCode = RpcImpersonateClient(NULL);
117 if (dwErrorCode != ERROR_SUCCESS)
118 {
119 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
120 return dwErrorCode;
121 }
122
123 if (!GetPrintProcessorDirectoryW(pName, pEnvironment, Level, pPrintProcessorDirectory, cbBuf, pcbNeeded))
124 dwErrorCode = GetLastError();
125
127 return dwErrorCode;
128}
BOOL WINAPI EnumPrintProcessorDatatypesW(PWSTR pName, PWSTR pPrintProcessorName, DWORD Level, PBYTE pDatatypes, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
BOOL WINAPI GetPrintProcessorDirectoryW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded)
BOOL WINAPI AddPrintProcessorW(PWSTR pName, PWSTR pEnvironment, PWSTR pPathName, PWSTR pPrintProcessorName)
BOOL WINAPI DeletePrintProcessorW(PWSTR pName, PWSTR pEnvironment, PWSTR pPrintProcessorName)
BOOL WINAPI EnumPrintProcessorsW(PWSTR pName, PWSTR pEnvironment, DWORD Level, PBYTE pPrintProcessorInfo, DWORD cbBuf, PDWORD pcbNeeded, PDWORD pcReturned)
DWORD _RpcAddPrintProcessor(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pPathName, WCHAR *pPrintProcessorName)
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)
DWORD _RpcGetPrintProcessorDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pPrintProcessorDirectory, DWORD cbBuf, DWORD *pcbNeeded)
DWORD _RpcEnumPrintProcessorDatatypes(WINSPOOL_HANDLE pName, WCHAR *pPrintProcessorName, DWORD Level, BYTE *pDatatypes, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
#define ERR(fmt,...)
Definition: debug.h:110
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI MarshallDownStructuresArray(PVOID pStructuresArray, DWORD cElements, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:91
static LPSTR pName
Definition: security.c:75
BYTE * PBYTE
Definition: pedump.c:66
static const MARSHALLING DatatypesInfo1Marshalling
static const MARSHALLING PrintProcessorInfo1Marshalling
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
MARSHALLING_INFO pInfo[]
Definition: marshalling.h:26
DWORD cbStructureSize
Definition: marshalling.h:25
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3828
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193