ReactOS 0.4.16-dev-311-g9382aa2
spoolfile.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: Spool File RPC calls
5 * COPYRIGHT: Copyright 2020 ReactOS
6 */
7
8#include "precomp.h"
9
12{
13 DWORD dwErrorCode;
14
15 dwErrorCode = RpcImpersonateClient(NULL);
16 if (dwErrorCode != ERROR_SUCCESS)
17 {
18 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
19 return dwErrorCode;
20 }
21
22 if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, (FILE_INFO_1*)pFileInfo, dwSize, dwNeeded ) )
23 dwErrorCode = GetLastError();
24
26 return dwErrorCode;
27}
28
31{
32 DWORD dwErrorCode;
33
34 dwErrorCode = RpcImpersonateClient(NULL);
35 if (dwErrorCode != ERROR_SUCCESS)
36 {
37 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
38 return dwErrorCode;
39 }
40
41 if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, (FILE_INFO_1*)pFileInfo, dwSize, dwNeeded ) )
42 dwErrorCode = GetLastError();
43
45 return dwErrorCode;
46}
47
50{
51 DWORD dwErrorCode, dwNeeded = 0;
52 HANDLE hProcessHandle;
53
54 dwErrorCode = RpcImpersonateClient(NULL);
55 if (dwErrorCode != ERROR_SUCCESS)
56 {
57 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
58 return dwErrorCode;
59 }
60
61 hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
62
63
64 if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, (FILE_INFO_1*)pFileInfoContainer->FileInfo.pFileInfo1, sizeof(FILE_INFO_1), &dwNeeded ) )
65 dwErrorCode = GetLastError();
66
67 if ( hProcessHandle )
68 {
69 CloseHandle( hProcessHandle );
70 }
71
73 return dwErrorCode;
74}
75
77_RpcCommitSpoolData2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer )
78{
79 DWORD dwErrorCode, dwNeeded = 0;
80 HANDLE hProcessHandle;
81
82 dwErrorCode = RpcImpersonateClient(NULL);
83 if (dwErrorCode != ERROR_SUCCESS)
84 {
85 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
86 return dwErrorCode;
87 }
88
89 hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
90
91 if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, (FILE_INFO_1*)pFileInfoContainer->FileInfo.pFileInfo1, sizeof(FILE_INFO_1), &dwNeeded ) )
92 dwErrorCode = GetLastError();
93
94 if ( hProcessHandle )
95 {
96 CloseHandle( hProcessHandle );
97 }
98
100 return dwErrorCode;
101}
102
103DWORD
105{
106 DWORD dwErrorCode;
107
108 dwErrorCode = RpcImpersonateClient(NULL);
109 if (dwErrorCode != ERROR_SUCCESS)
110 {
111 ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
112 return dwErrorCode;
113 }
114
115 if (!SplCloseSpoolFileHandle( hPrinter ) )
116 dwErrorCode = GetLastError();
117
119 return dwErrorCode;
120}
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL WINAPI SplGetSpoolFileInfo(HANDLE hPrinter, HANDLE hProcessHandle, DWORD Level, PFILE_INFO_1 pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:11
BOOL WINAPI SplCommitSpoolData(HANDLE hPrinter, HANDLE hProcessHandle, DWORD cbCommit, DWORD Level, PFILE_INFO_1 pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:50
BOOL WINAPI SplCloseSpoolFileHandle(HANDLE hPrinter)
Definition: spoolfile.c:76
DWORD _RpcGetSpoolFileInfo2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:49
DWORD _RpcCommitSpoolData2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:77
DWORD _RpcCloseSpoolFileHandle(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: spoolfile.c:104
DWORD _RpcGetSpoolFileInfo(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD Level, WINSPOOL_FILE_INFO_1 *pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:11
DWORD _RpcCommitSpoolData(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_1 *pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:30
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
unsigned long DWORD
Definition: ntddk_ex.h:95
#define PROCESS_DUP_HANDLE
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1463
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1056
union _WINSPOOL_FILE_INFO_CONTAINER::@3447 FileInfo
WINSPOOL_FILE_INFO_1 * pFileInfo1
Definition: winspool.idl:852
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56