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"
9 #include "marshalling/printerdrivers.h"
10 
11 DWORD
12 _RpcAddPrinterDriver(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer)
13 {
14     UNIMPLEMENTED;
15     return ERROR_INVALID_FUNCTION;
16 }
17 
18 DWORD
19 _RpcAddPrinterDriverEx(WINSPOOL_HANDLE pName, WINSPOOL_DRIVER_CONTAINER* pDriverContainer, DWORD dwFileCopyFlags)
20 {
21     UNIMPLEMENTED;
22     return ERROR_INVALID_FUNCTION;
23 }
24 
25 DWORD
26 _RpcDeletePrinterDriver(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName)
27 {
28     UNIMPLEMENTED;
29     return ERROR_INVALID_FUNCTION;
30 }
31 
32 DWORD
33 _RpcDeletePrinterDriverEx(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, WCHAR* pDriverName, DWORD dwDeleteFlag, DWORD dwVersionNum)
34 {
35     UNIMPLEMENTED;
36     return ERROR_INVALID_FUNCTION;
37 }
38 
39 DWORD
40 _RpcEnumPrinterDrivers(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDrivers, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned)
41 {
42     UNIMPLEMENTED;
43     return ERROR_INVALID_FUNCTION;
44 }
45 
46 DWORD
47 _RpcGetPrinterDriver(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded)
48 {
49     DWORD dwErrorCode;
50     PBYTE pDriverAligned;
51 
52     dwErrorCode = RpcImpersonateClient(NULL);
53     if (dwErrorCode != ERROR_SUCCESS)
54     {
55         ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode);
56         return dwErrorCode;
57     }
58 
59     pDriverAligned = AlignRpcPtr(pDriver, &cbBuf);
60 
61     if (GetPrinterDriverW(hPrinter, pEnvironment, Level, pDriverAligned, cbBuf, pcbNeeded))
62     {
63         // Replace relative offset addresses in the output by absolute pointers.
64         ASSERT(Level >= 1 && Level <= 3);
65         MarshallDownStructure(pDriverAligned, pPrinterDriverMarshalling[Level]->pInfo, pPrinterDriverMarshalling[Level]->cbStructureSize, TRUE);
66     }
67     else
68     {
69         dwErrorCode = GetLastError();
70     }
71 
72     RpcRevertToSelf();
73     UndoAlignRpcPtr(pDriver, pDriverAligned, cbBuf, pcbNeeded);
74 
75     return dwErrorCode;
76 }
77 
78 DWORD
79 _RpcGetPrinterDriver2(WINSPOOL_PRINTER_HANDLE hPrinter, WCHAR* pEnvironment, DWORD Level, BYTE* pDriver, DWORD cbBuf, DWORD* pcbNeeded, DWORD dwClientMajorVersion, DWORD dwClientMinorVersion, DWORD* pdwServerMaxVersion, DWORD* pdwServerMinVersion)
80 {
81     UNIMPLEMENTED;
82     return ERROR_INVALID_FUNCTION;
83 }
84 
85 DWORD
86 _RpcGetPrinterDriverDirectory(WINSPOOL_HANDLE pName, WCHAR* pEnvironment, DWORD Level, BYTE* pDriverDirectory, DWORD cbBuf, DWORD* pcbNeeded)
87 {
88     UNIMPLEMENTED;
89     return ERROR_INVALID_FUNCTION;
90 }
91