[Printing] Update and Add Functions

Fix and Update WinSpool.idl.

Start forwards to LocalSpl.
This commit is contained in:
James Tabor 2020-08-02 14:49:06 -05:00
parent a77a65ab6d
commit 89e716a7f7
14 changed files with 330 additions and 41 deletions

View file

@ -834,10 +834,10 @@ typedef [switch_type(DWORD)] union _WINSPOOL_V2_UREPLY_PRINTER
} }
WINSPOOL_V2_UREPLY_PRINTER; WINSPOOL_V2_UREPLY_PRINTER;
typedef struct _WINSPOOL_FILE_INFO typedef struct _WINSPOOL_FILE_INFO_1
{ {
BOOL bInheritHandle; BOOL bInheritHandle;
HANDLE hSpoolFileHandle; WINSPOOL_HANDLE hSpoolFileHandle;
DWORD dwOptions; DWORD dwOptions;
} }
WINSPOOL_FILE_INFO_1; WINSPOOL_FILE_INFO_1;
@ -1575,22 +1575,50 @@ interface winspool {
/* TODO */ /* TODO */
); );
/* Function 0x5B (TODO) */ /* Function 0x5B */
DWORD _RpcGetSpoolFileInfo( DWORD _RpcGetSpoolFileInfo(
/* TODO */ [in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in] WINSPOOL_HANDLE hProcessHandle,
[in] DWORD Level,
[in] WINSPOOL_FILE_INFO_1* pFileInfo,
[in] DWORD dwSize,
[in] DWORD* dwNeeded
); );
/* Function 0x5C (TODO) */ /* Function 0x5C */
DWORD _RpcCommitSpoolData( DWORD _RpcCommitSpoolData(
/* TODO */ [in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in] WINSPOOL_HANDLE hProcessHandle,
[in] DWORD cbCommit,
[in] DWORD Level,
[in] WINSPOOL_FILE_INFO_1* pFileInfo,
[in] DWORD dwSize,
[in] DWORD* dwNeeded
); );
/* Function 0x5D (TODO) */ /* Function 0x5D */
DWORD _RpcCloseSpoolFileHandle( DWORD _RpcGetSpoolFileInfo2(
/* TODO */ [in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in] DWORD dwProcessId,
[in] DWORD Level,
[in] WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer
); );
/* Function 0x5E */ /* Function 0x5E */
DWORD _RpcCommitSpoolData2(
[in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in] DWORD dwProcessId,
[in] DWORD cbCommit,
[in] DWORD Level,
[in] WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer
);
/* Function 0x5F */
DWORD _RpcCloseSpoolFileHandle(
[in] WINSPOOL_PRINTER_HANDLE hPrinter
);
/* Function 0x60 */
DWORD _RpcFlushPrinter( DWORD _RpcFlushPrinter(
[in] WINSPOOL_PRINTER_HANDLE hPrinter, [in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in, size_is(cbBuf)] BYTE* pBuf, [in, size_is(cbBuf)] BYTE* pBuf,
@ -1599,7 +1627,7 @@ interface winspool {
[in] DWORD cSleep [in] DWORD cSleep
); );
/* Function 0x5F */ /* Function 0x61 */
DWORD _RpcSendRecvBidiData( DWORD _RpcSendRecvBidiData(
[in] WINSPOOL_PRINTER_HANDLE hPrinter, [in] WINSPOOL_PRINTER_HANDLE hPrinter,
[in, string, unique] const WCHAR* pAction, [in, string, unique] const WCHAR* pAction,
@ -1607,7 +1635,7 @@ interface winspool {
[out] WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData [out] WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData
); );
/* Function 0x60 (TODO) */ /* Function 0x62 (TODO) */
DWORD _RpcAddDriverCatalog( DWORD _RpcAddDriverCatalog(
/* TODO */ /* TODO */
); );

View file

@ -12,6 +12,7 @@ list(APPEND SOURCE
printerdata.c printerdata.c
printers.c printers.c
printprocessors.c printprocessors.c
spoolfile.c
tools.c) tools.c)
list(APPEND PCH_SKIP_SOURCE list(APPEND PCH_SKIP_SOURCE

View file

@ -52,4 +52,12 @@ SPOOLSS_PRINTER_HANDLE, *PSPOOLSS_PRINTER_HANDLE;
extern HANDLE hProcessHeap; extern HANDLE hProcessHeap;
extern LIST_ENTRY PrintProviderList; extern LIST_ENTRY PrintProviderList;
// spoolfile.c
typedef struct _FILE_INFO_1
{
BOOL bInheritHandle;
HANDLE hSpoolFileHandle;
DWORD dwOptions;
} FILE_INFO_1, *PFILE_INFO_1;
#endif #endif

View file

@ -0,0 +1,88 @@
/*
* PROJECT: ReactOS Spooler Router
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Functions related to Spool File
* COPYRIGHT: Copyright 1998-2022 ReactOS
*/
#include "precomp.h"
BOOL WINAPI
SplGetSpoolFileInfo(
HANDLE hPrinter,
HANDLE hProcessHandle,
DWORD Level,
PFILE_INFO_1 pFileInfo,
DWORD dwSize,
DWORD* dwNeeded )
{
BOOL Ret;
HANDLE hHandle, hSourceProcessHandle;
PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter;
// Sanity checks.
if (!pHandle)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
hSourceProcessHandle = GetCurrentProcess();
// No Local? Ok, what ever...
Ret = pHandle->pPrintProvider->PrintProvider.fpGetSpoolFileInfo( pHandle->hPrinter,
NULL,
&hHandle,
hProcessHandle,
hSourceProcessHandle );
if ( Ret )
{
pFileInfo->hSpoolFileHandle = hHandle;
pFileInfo->bInheritHandle = TRUE;
pFileInfo->dwOptions = DUPLICATE_CLOSE_SOURCE;
}
return Ret;
}
BOOL WINAPI
SplCommitSpoolData(
HANDLE hPrinter,
HANDLE hProcessHandle,
DWORD cbCommit,
DWORD Level,
PFILE_INFO_1 pFileInfo,
DWORD dwSize,
DWORD* dwNeeded )
{
PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter;
// Sanity checks.
if (!pHandle)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
pFileInfo->hSpoolFileHandle = INVALID_HANDLE_VALUE;
pFileInfo->bInheritHandle = TRUE;
pFileInfo->dwOptions = DUPLICATE_CLOSE_SOURCE;
return pHandle->pPrintProvider->PrintProvider.fpCommitSpoolData( hPrinter, cbCommit );
}
BOOL WINAPI
SplCloseSpoolFileHandle( HANDLE hPrinter )
{
PSPOOLSS_PRINTER_HANDLE pHandle = (PSPOOLSS_PRINTER_HANDLE)hPrinter;
// Sanity checks.
if (!pHandle)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
return pHandle->pPrintProvider->PrintProvider.fpCloseSpoolFileHandle( pHandle->hPrinter );
}

View file

@ -142,10 +142,10 @@
@ stdcall SetPrinterDataExW(long wstr wstr long ptr long) @ stdcall SetPrinterDataExW(long wstr wstr long ptr long)
@ stdcall SetPrinterDataW(long wstr long ptr long) @ stdcall SetPrinterDataW(long wstr long ptr long)
@ stub SetPrinterW @ stub SetPrinterW
@ stub SplCloseSpoolFileHandle @ stdcall SplCloseSpoolFileHandle(ptr)
@ stub SplCommitSpoolData @ stdcall SplCommitSpoolData(ptr ptr long long ptr long ptr)
@ stub SplDriverUnloadComplete @ stub SplDriverUnloadComplete
@ stub SplGetSpoolFileInfo @ stdcall SplGetSpoolFileInfo(ptr ptr long ptr long ptr)
@ stdcall SplInitializeWinSpoolDrv(ptr) @ stdcall SplInitializeWinSpoolDrv(ptr)
@ stub SplIsSessionZero @ stub SplIsSessionZero
@ stdcall SplIsUpgrade() @ stdcall SplIsUpgrade()

View file

@ -18,6 +18,7 @@ list(APPEND SOURCE
printproviders.c printproviders.c
rpcserver.c rpcserver.c
rpcstubs.c rpcstubs.c
spoolfile.c
xcv.c xcv.c
${CMAKE_CURRENT_BINARY_DIR}/winspool_s.c) ${CMAKE_CURRENT_BINARY_DIR}/winspool_s.c)

View file

@ -28,4 +28,27 @@ WINE_DEFAULT_DEBUG_CHANNEL(spoolsv);
// rpcserver.c // rpcserver.c
DWORD WINAPI LrpcThreadProc(LPVOID lpParameter); DWORD WINAPI LrpcThreadProc(LPVOID lpParameter);
// spoolfile.c
BOOL WINAPI
SplGetSpoolFileInfo(
HANDLE hPrinter,
HANDLE hProcessHandle,
DWORD Level,
WINSPOOL_FILE_INFO_1 *pFileInfo,
DWORD dwSize,
DWORD* dwNeeded );
BOOL WINAPI
SplCommitSpoolData(
HANDLE hPrinter,
HANDLE hProcessHandle,
DWORD cbCommit,
DWORD Level,
WINSPOOL_FILE_INFO_1 *pFileInfo,
DWORD dwSize,
DWORD* dwNeeded );
BOOL WINAPI
SplCloseSpoolFileHandle( HANDLE hPrinter );
#endif #endif

View file

@ -105,27 +105,6 @@ _RpcSplOpenPrinter(VOID)
return ERROR_INVALID_FUNCTION; return ERROR_INVALID_FUNCTION;
} }
DWORD
_RpcGetSpoolFileInfo(VOID)
{
UNIMPLEMENTED;
return ERROR_INVALID_FUNCTION;
}
DWORD
_RpcCommitSpoolData(VOID)
{
UNIMPLEMENTED;
return ERROR_INVALID_FUNCTION;
}
DWORD
_RpcCloseSpoolFileHandle(VOID)
{
UNIMPLEMENTED;
return ERROR_INVALID_FUNCTION;
}
DWORD DWORD
_RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pAction, WINSPOOL_BIDI_REQUEST_CONTAINER* pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData) _RpcSendRecvBidiData(WINSPOOL_PRINTER_HANDLE hPrinter, const WCHAR* pAction, WINSPOOL_BIDI_REQUEST_CONTAINER* pReqData, WINSPOOL_BIDI_RESPONSE_CONTAINER** ppRespData)
{ {

View file

@ -0,0 +1,120 @@
/*
* PROJECT: ReactOS Print Spooler Service
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Spool File RPC calls
* COPYRIGHT: Copyright 2020 ReactOS
*/
#include "precomp.h"
DWORD
_RpcGetSpoolFileInfo( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD Level, WINSPOOL_FILE_INFO_1* pFileInfo, DWORD dwSize, DWORD* dwNeeded )
{
DWORD dwErrorCode;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
{
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
return dwErrorCode;
}
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, pFileInfo, dwSize, dwNeeded ) )
dwErrorCode = GetLastError();
RpcRevertToSelf();
return dwErrorCode;
}
DWORD
_RpcCommitSpoolData( WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_HANDLE hProcessHandle, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_1* pFileInfo, DWORD dwSize, DWORD* dwNeeded )
{
DWORD dwErrorCode;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
{
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
return dwErrorCode;
}
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, pFileInfo, dwSize, dwNeeded ) )
dwErrorCode = GetLastError();
RpcRevertToSelf();
return dwErrorCode;
}
DWORD
_RpcGetSpoolFileInfo2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer )
{
DWORD dwErrorCode, dwNeeded = 0;
HANDLE hProcessHandle;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
{
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
return dwErrorCode;
}
hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
if (!SplGetSpoolFileInfo( hPrinter, hProcessHandle, Level, pFileInfoContainer->FileInfo.pFileInfo1, sizeof(WINSPOOL_FILE_INFO_1), &dwNeeded ) )
dwErrorCode = GetLastError();
if ( hProcessHandle )
{
CloseHandle( hProcessHandle );
}
RpcRevertToSelf();
return dwErrorCode;
}
DWORD
_RpcCommitSpoolData2( WINSPOOL_PRINTER_HANDLE hPrinter, DWORD dwProcessId, DWORD cbCommit, DWORD Level, WINSPOOL_FILE_INFO_CONTAINER* pFileInfoContainer )
{
DWORD dwErrorCode, dwNeeded = 0;
HANDLE hProcessHandle;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
{
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
return dwErrorCode;
}
hProcessHandle = OpenProcess( PROCESS_DUP_HANDLE, FALSE, dwProcessId );
if (!SplCommitSpoolData( hPrinter, hProcessHandle, cbCommit, Level, pFileInfoContainer->FileInfo.pFileInfo1, sizeof(WINSPOOL_FILE_INFO_1), &dwNeeded ) )
dwErrorCode = GetLastError();
if ( hProcessHandle )
{
CloseHandle( hProcessHandle );
}
RpcRevertToSelf();
return dwErrorCode;
}
DWORD
_RpcCloseSpoolFileHandle( WINSPOOL_PRINTER_HANDLE hPrinter )
{
DWORD dwErrorCode;
dwErrorCode = RpcImpersonateClient(NULL);
if (dwErrorCode != ERROR_SUCCESS)
{
ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
return dwErrorCode;
}
if (!SplCloseSpoolFileHandle( hPrinter ) )
dwErrorCode = GetLastError();
RpcRevertToSelf();
return dwErrorCode;
}

View file

@ -172,7 +172,7 @@
271 stdcall ResetPrinterA(ptr ptr) 271 stdcall ResetPrinterA(ptr ptr)
272 stdcall ResetPrinterW(ptr ptr) 272 stdcall ResetPrinterW(ptr ptr)
273 stdcall ScheduleJob(ptr long) 273 stdcall ScheduleJob(ptr long)
274 stub SeekPrinter 274 stdcall -stub SeekPrinter(ptr int64 ptr long long)
275 stub SetAllocFailCount 275 stub SetAllocFailCount
276 stdcall SetFormA(ptr str long str) 276 stdcall SetFormA(ptr str long str)
277 stdcall SetFormW(ptr str long str) 277 stdcall SetFormW(ptr str long str)

View file

@ -14,6 +14,7 @@ list(APPEND SOURCE
printers.c printers.c
printingthread.c printingthread.c
printprocessors.c printprocessors.c
spoolfile.c
tools.c) tools.c)
add_library(localspl MODULE add_library(localspl MODULE

View file

@ -112,9 +112,9 @@ static const PRINTPROVIDOR _PrintProviderFunctions = {
NULL, // fpAddPrinterDriverEx NULL, // fpAddPrinterDriverEx
NULL, // fpSplReadPrinter NULL, // fpSplReadPrinter
NULL, // fpDriverUnloadComplete NULL, // fpDriverUnloadComplete
NULL, // fpGetSpoolFileInfo LocalGetSpoolFileInfo, // fpGetSpoolFileInfo
NULL, // fpCommitSpoolData LocalCommitSpoolData, // fpCommitSpoolData
NULL, // fpCloseSpoolFileHandle LocalCloseSpoolFileHandle, // fpCloseSpoolFileHandle
NULL, // fpFlushPrinter NULL, // fpFlushPrinter
NULL, // fpSendRecvBidiData NULL, // fpSendRecvBidiData
NULL, // fpAddDriverCatalog NULL, // fpAddDriverCatalog

View file

@ -316,6 +316,11 @@ BOOL WINAPI LocalEnumPrintProcessorDatatypes(LPWSTR pName, LPWSTR pPrintProcesso
BOOL WINAPI LocalEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned); BOOL WINAPI LocalEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned);
BOOL WINAPI LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded); BOOL WINAPI LocalGetPrintProcessorDirectory(LPWSTR pName, LPWSTR pEnvironment, DWORD Level, LPBYTE pPrintProcessorInfo, DWORD cbBuf, LPDWORD pcbNeeded);
// spoolfile.c
BOOL WINAPI LocalGetSpoolFileInfo(HANDLE hPrinter,LPWSTR *pSpoolDir,LPHANDLE phFile,HANDLE hSpoolerProcess,HANDLE hAppProcess);
BOOL WINAPI LocalCommitSpoolData(HANDLE hPrinter,DWORD cbCommit);
BOOL WINAPI LocalCloseSpoolFileHandle(HANDLE hPrinter);
// tools.c // tools.c
PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName); PWSTR AllocAndRegQueryWSZ(HKEY hKey, PCWSTR pwszValueName);
PDEVMODEW DuplicateDevMode(PDEVMODEW pInput); PDEVMODEW DuplicateDevMode(PDEVMODEW pInput);

View file

@ -0,0 +1,35 @@
/*
* PROJECT: ReactOS Local Spooler
* LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
* PURPOSE: Functions related to Spool Files and printing
* COPYRIGHT: Copyright 1998-2020 ReactOS)
*/
#include "precomp.h"
BOOL WINAPI
LocalGetSpoolFileInfo(
HANDLE hPrinter,
LPWSTR *pSpoolDir,
LPHANDLE phFile,
HANDLE hSpoolerProcess,
HANDLE hAppProcess )
{
FIXME("LocalGetSpoolFileInfo(%p, %S, %p, %p, %p)\n", hPrinter, pSpoolDir, phFile, hSpoolerProcess, hAppProcess);
return FALSE;
}
BOOL WINAPI
LocalCommitSpoolData( HANDLE hPrinter, DWORD cbCommit)
{
FIXME("LocalCommitSpoolData(%p, %lu)\n", hPrinter, cbCommit);
return FALSE;
}
BOOL WINAPI
LocalCloseSpoolFileHandle( HANDLE hPrinter)
{
FIXME("LocalCloseSpoolFileHandle(%p)\n", hPrinter);
return FALSE;
}