ReactOS  0.4.15-dev-509-g96a357b
printerdrivers.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 Printer Drivers
5  * COPYRIGHT: Copyright 2015 Colin Finck (colin@reactos.org)
6  */
7 
8 #include "precomp.h"
10 
11 DWORD
13 {
16 }
17 
18 DWORD
20 {
23 }
24 
25 DWORD
27 {
30 }
31 
32 DWORD
33 _RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)
34 {
37 }
38 
39 DWORD
40 _RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDrivers, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
41 {
44 }
45 
46 DWORD
48 {
49  DWORD dwErrorCode;
50  PBYTE pDriverAligned;
51 
52  ERR("_RpcGetPrinterDriver(%p, %lu, %lu, %p, %lu, %p)\n", hPrinter, pEnvironment, Level, pDriver, cbBuf, pcbNeeded);
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  pDriverAligned = AlignRpcPtr(pDriver, &cbBuf);
62 
63  if (GetPrinterDriverW(hPrinter, pEnvironment, Level, pDriverAligned, cbBuf, pcbNeeded))
64  {
65  // Replace relative offset addresses in the output by absolute pointers.
66  ASSERT(Level >= 1 && Level <= 5);
67  MarshallDownStructure(pDriverAligned, pPrinterDriverMarshalling[Level]->pInfo, pPrinterDriverMarshalling[Level]->cbStructureSize, TRUE);
68  }
69  else
70  {
71  dwErrorCode = GetLastError();
72  }
73 
75  UndoAlignRpcPtr(pDriver, pDriverAligned, cbBuf, pcbNeeded);
76 
77  return dwErrorCode;
78 }
79 
80 DWORD
81 _RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD* pdwServerMaxVersion, DWORD* pdwServerMinVersion)
82 {
85 }
86 
87 DWORD
89 {
92 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_INVALID_FUNCTION
Definition: dderror.h:6
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:55
DWORD _RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD *pdwServerMaxVersion, DWORD *pdwServerMinVersion)
DWORD _RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer)
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
RPC_STATUS WINAPI RpcRevertToSelf(void)
Definition: rpc_binding.c:1459
static LPSTR pName
Definition: security.c:75
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOL WINAPI MarshallDownStructure(PVOID pStructure, const MARSHALLING_INFO *pInfo, DWORD cbStructureSize, BOOL bSomeBoolean)
Definition: marshalling.c:38
DWORD _RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDrivers, DWORD cbBuf, DWORD *pcbNeeded, DWORD *pcReturned)
unsigned char BYTE
Definition: xxhash.c:193
#define ERR(fmt,...)
Definition: debug.h:110
DWORD _RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName)
PVOID WINAPI AlignRpcPtr(PVOID pBuffer, PDWORD pcbBuffer)
Definition: memory.c:29
_In_ DWORD _Out_ PDWORD pcbNeeded
Definition: winddi.h:3827
PDWORD WINAPI UndoAlignRpcPtr(PVOID pDestinationBuffer, PVOID pSourceBuffer, DWORD cbBuffer, PDWORD pcbNeeded)
Definition: memory.c:239
DWORD _RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, WCHAR *pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)
RPC_STATUS WINAPI RpcImpersonateClient(RPC_BINDING_HANDLE BindingHandle)
Definition: rpc_binding.c:1052
DWORD _RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR *pEnvironment, DWORD Level, BYTE *pDriverDirectory, DWORD cbBuf, DWORD *pcbNeeded)
#define UNIMPLEMENTED
Definition: debug.h:115
DWORD _RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER *pDriverContainer, DWORD dwFileCopyFlags)
DWORD _RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR *pEnvironment, DWORD Level, BYTE *pDriver, DWORD cbBuf, DWORD *pcbNeeded)
BYTE * PBYTE
Definition: pedump.c:66
WCHAR * WINSPOOL_HANDLE
Definition: winspool.idl:15
static const MARSHALLING * pPrinterDriverMarshalling[]