ReactOS  0.4.15-dev-1207-g698a8e6
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 
10 DWORD
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 
29 DWORD
30 _RpcCommitSpoolData( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_1* pFileInfo, DWORD dwSize, DWORD* dwNeeded )
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 
48 DWORD
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 
76 DWORD
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 
103 DWORD
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 
118  RpcRevertToSelf();
119  return dwErrorCode;
120 }
DWORD _RpcGetSpoolFileInfo(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD Level, WINSPOOL_FILE_INFO_1 *pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:11
#define CloseHandle
Definition: compat.h:598
#define ERROR_SUCCESS
Definition: deptool.c:10
BOOL WINAPI SplCommitSpoolData(HANDLE hPrinter, HANDLE hProcessHandle, DWORD cbCommit, DWORD Level, PFILE_INFO_1 pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:50
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
union _WINSPOOL_FILE_INFO_CONTAINER::@3410 FileInfo
DWORD _RpcCommitSpoolData2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:77
#define FALSE
Definition: types.h:117
#define PROCESS_DUP_HANDLE
BOOL WINAPI SplCloseSpoolFileHandle(HANDLE hPrinter)
Definition: spoolfile.c:76
smooth NULL
Definition: ftsmooth.c:416
DWORD _RpcGetSpoolFileInfo2(WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER *pFileInfoContainer)
Definition: spoolfile.c:49
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
BOOL WINAPI SplGetSpoolFileInfo(HANDLE hPrinter, HANDLE hProcessHandle, DWORD Level, PFILE_INFO_1 pFileInfo, DWORD dwSize, DWORD *dwNeeded)
Definition: spoolfile.c:11
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD _RpcCloseSpoolFileHandle(WINSPOOL_PRINTER_HANDLE hPrinter)
Definition: spoolfile.c:104
#define ERR(fmt,...)
Definition: debug.h:110
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
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
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
WINSPOOL_FILE_INFO_1 * pFileInfo1
Definition: winspool.idl:852