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 11 _RpcGetSpoolFileInfo( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD Level, WINSPOOL_FILE_INFO_1* pFileInfo, DWORD dwSize, DWORD* dwNeeded ) 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 25 RpcRevertToSelf(); 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 44 RpcRevertToSelf(); 45 return dwErrorCode; 46 } 47 48 DWORD 49 _RpcGetSpoolFileInfo2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer ) 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 72 RpcRevertToSelf(); 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 99 RpcRevertToSelf(); 100 return dwErrorCode; 101 } 102 103 DWORD 104 _RpcCloseSpoolFileHandle( WINSPOOL_PRINTER_HANDLE hPrinter ) 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 } 121